Codebase list ido-ubiquitous / 125beaf
New upstream version 3.16 Lev Lamberov 6 years ago
6 changed file(s) with 147 addition(s) and 125 deletion(s). Raw diff Collapse all Expand all
0 2017-03-13 Ryan C. Thompson <rct@thompsonclan.org>
1
2 * ido-ubiquitous.el (ido-cr+--explain-fallback): Fix
3 ido-ubiquitous-debug-mode messages.
4
5 2016-06-23 Ryan C. Thompson <rct@thompsonclan.org>
6
7 * ido-ubiquitous.el (ido-ubiquitous-default-command-overrides):
8 Remove the recently-added overrides for "describe-function" and
9 "describe-variable". Ido completion interferes with a new feature
10 of the completion for these functions, so it should be disabled
11 unless ido can be made compatible with this feature.
12
013 2016-06-18 Ryan C. Thompson <rct@thompsonclan.org>
114
215 * ido-ubiquitous.el (completing-read-ido-ubiquitous): Fix an edge
2222
2323 If you are using this package, you probably want to enable ido
2424 everywhere that it is possible to do so. Here are all the places to
25 enable ido that I'm aware of. (Note that most of these variables can
26 also be set via `M-x customize-variable` if you prefer that.)
25 enable ido that I'm aware of. (Note that most of these variables/modes
26 can also be set/enabled via `M-x customize-variable` if you prefer
27 that.)
2728
2829 ## Ido itself ##
2930
4546 Smex allows you to use ido for completion of commands in M-x, with
4647 enhancements like putting your most-used commands at the front of the
4748 list. First install the [smex](https://github.com/nonsequitur/smex)
48 package, then follow the directions to set up key-bindings for it.
49 package, then follow the directions to load it and replace your normal
50 M-x key-binding with smex:
51
52 (require 'smex) ; Not needed if you use package.el
53 (smex-initialize) ; Can be omitted. This might cause a (minimal) delay
54 ; when Smex is auto-initialized on its first run.
55 (global-set-key (kbd "M-x") 'smex)
56 (global-set-key (kbd "M-X") 'smex-major-mode-commands)
57 ;; This is your old M-x.
58 (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
59
60 (These directions are the same ones given in the smex README file.)
4961
5062 ## ido-yes-or-no ##
5163
8496
8597 * Magit: `(setq magit-completing-read-function 'magit-ido-completing-read)`
8698 * Gnus: `(setq gnus-completing-read-function 'gnus-ido-completing-read)`
87
88 (You can also use `M-x customize-variable` to set all of these
89 options.)
9099
91100 # Frequently asked questions #
92101
44 ;; Filename: ido-completing-read+.el
55 ;; Author: Ryan Thompson
66 ;; Created: Sat Apr 4 13:41:20 2015 (-0700)
7 ;; Version: 3.14
7 ;; Version: 3.16
88 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
99 ;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous
1010 ;; Keywords: ido, completion, convenience
4040 ;;
4141 ;;; Code:
4242
43 (defconst ido-completing-read+-version "3.14"
43 (defconst ido-completing-read+-version "3.16"
4444 "Currently running version of ido-ubiquitous.
4545
4646 Note that when you update ido-completing-read+, this variable may
5959 :global t
6060 :group 'ido-completing-read-plus)
6161
62 ;; Defined as a macro for efficiency (args are not evaluated unless
63 ;; debug mode is on)
64 (defmacro ido-cr+--debug-message (format-string &rest args)
65 `(when ido-cr+-debug-mode
66 (message (concat "ido-completing-read+: " ,format-string) ,@args)))
62 (defun ido-cr+--debug-message (format-string &rest args)
63 (when ido-cr+-debug-mode
64 (apply #'message (concat "ido-completing-read+: " format-string) args)))
6765
6866 ;;; Core code
6967
142140 (when ido-cr+-debug-mode
143141 (when (and (listp arg)
144142 (eq (car arg) 'ido-cr+-fallback))
145 (setq arg (cdr arg)))
143 (setq arg (cadr arg)))
146144 (ido-cr+--debug-message "Falling back to `%s' because %s."
147 ido-cr+-fallback-function arg)))
145 ido-cr+-fallback-function arg)))
148146
149147 ;;;###autoload
150148 (defun ido-completing-read+ (prompt collection &optional predicate
168166 (cond
169167 (inherit-input-method
170168 (signal 'ido-cr+-fallback
171 "ido cannot handle non-nil INHERIT-INPUT-METHOD"))
169 '("ido cannot handle non-nil INHERIT-INPUT-METHOD")))
172170 ((bound-and-true-p completion-extra-properties)
173171 (signal 'ido-cr+-fallback
174 "ido cannot handle non-nil `completion-extra-properties'"))
172 '("ido cannot handle non-nil `completion-extra-properties'")))
175173 ((functionp collection)
176174 (signal 'ido-cr+-fallback
177 "ido cannot handle COLLECTION being a function")))
175 '("ido cannot handle COLLECTION being a function"))))
178176 ;; Expand all possible completions
179177 (setq collection (all-completions "" collection predicate))
180178 ;; Check for excessively large collection
181179 (when (and ido-cr+-max-items
182180 (> (length collection) ido-cr+-max-items))
183181 (signal 'ido-cr+-fallback
184 (format
185 "there are more than %i items in COLLECTION (see `ido-cr+-max-items')"
186 ido-cr+-max-items)))
182 (list
183 (format
184 "there are more than %i items in COLLECTION (see `ido-cr+-max-items')"
185 ido-cr+-max-items))))
187186 ;; ido doesn't natively handle DEF being a list. If DEF is a
188187 ;; list, prepend it to COLLECTION and set DEF to just the
189188 ;; car of the default list.
218217 ;; This detects when the user triggered fallback mode
219218 ;; manually.
220219 (when (eq ido-exit 'fallback)
221 (signal 'ido-cr+-fallback "user manually triggered fallback"))))
220 (signal 'ido-cr+-fallback '("user manually triggered fallback")))))
222221 ;; Handler for ido-cr+-fallback signal
223222 (ido-cr+-fallback
224223 (ido-cr+--explain-fallback sig)
301300 (not (member ido-text (with-no-warnings ido-cur-list))))
302301 (progn
303302 (ido-cr+--debug-message
304 "Overriding C-j behavior for require-match: performing completion instead of exiting.")
303 "Overriding C-j behavior for require-match: performing completion instead of exiting with current text. (This might still exit with a match if `ido-confirm-unique-completion' is nil)")
305304 (ido-complete))
306305 ad-do-it))
307306
33
44 ;; Author: Ryan C. Thompson
55 ;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous
6 ;; Version: 3.14
6 ;; Version: 3.16
77 ;; Created: 2011-09-01
88 ;; Keywords: convenience, completion, ido
99 ;; EmacsWiki: InteractivelyDoThings
10 ;; Package-Requires: ((emacs "24.1") (ido-completing-read+ "3.14") (cl-lib "0.5"))
10 ;; Package-Requires: ((emacs "24.1") (ido-completing-read+ "3.16") (cl-lib "0.5"))
1111 ;; Filename: ido-ubiquitous.el
1212
1313 ;; This file is NOT part of GNU Emacs.
6868 ;;
6969 ;;; Code:
7070
71 (defconst ido-ubiquitous-version "3.14"
71 (defconst ido-ubiquitous-version "3.16"
7272 "Currently running version of ido-ubiquitous.
7373
7474 Note that when you update ido-ubiquitous, this variable may not
101101 :global t
102102 :group 'ido-ubiquitous)
103103
104 ;; Defined as a macro for efficiency (args are not evaluated unless
105 ;; debug mode is on)
106 (defmacro ido-ubiquitous--debug-message (format-string &rest args)
107 `(when ido-ubiquitous-debug-mode
108 (message (concat "ido-ubiquitous: " ,format-string) ,@args)))
104 (defun ido-ubiquitous--debug-message (format-string &rest args)
105 (when ido-ubiquitous-debug-mode
106 (apply #'message (concat "ido-ubiquitous: " format-string) args)))
109107
110108 (defun ido-ubiquitous--explain-fallback (arg)
111109 ;; This function accepts a string, or an ido-ubiquitous-fallback
113111 (when ido-ubiquitous-debug-mode
114112 (when (and (listp arg)
115113 (eq (car arg) 'ido-ubiquitous-fallback))
116 (setq arg (cdr arg)))
114 (setq arg (cadr arg)))
117115 (ido-ubiquitous--debug-message "Falling back to `%s' because %s."
118116 ido-cr+-fallback-function arg)))
119117
332330 (enable exact "find-tag")
333331 ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/89
334332 (enable prefix "etags-select-")
335 ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/110
336 (enable regexp "\\`describe-\\(function\\|variable\\)\\'")
337333 ) ; Close paren on separate line for better VC diffs
338334 "Default value of `ido-ubiquitous-command-overrides'.
339335
365361 (enable exact "imenu--completion-buffer")
366362 ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/74
367363 (enable-old exact "auto-insert")
364 ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/116
365 (enable exact "project--completing-read-strict")
368366 ) ; Close paren on separate line for better VC diffs
369367 "Default value of `ido-ubiquitous-function-overrides'.
370368
666664 ;; If ido-ubiquitous is disabled this time, fall back
667665 (when (eq ido-ubiquitous-active-state 'disable)
668666 (signal 'ido-ubiquitous-fallback
669 "`ido-ubiquitous-active-state' is `disable'"))
667 '("`ido-ubiquitous-active-state' is `disable'")))
670668 ;; Handle a collection that is a function: either expand
671669 ;; completion list now or fall back
672670 (when (functionp collection)
678676 ;; so it now becomes redundant.
679677 predicate nil)
680678 (signal 'ido-ubiquitous-fallback
681 "COLLECTION is a function and there is no override")))
679 '("COLLECTION is a function and there is no override"))))
682680 (let ((ido-ubiquitous-enable-next-call t))
683681 (ido-completing-read+
684682 prompt collection predicate require-match
685683 initial-input hist def inherit-input-method)))
684 ;; Pass through any known fallback signals to the outer
685 ;; `condition-case'
686 (ido-ubiquitous-fallback
687 (signal (car err) (cdr err)))
688 ;; Convert any other error into a fallback signal.
686689 (error
687690 (signal 'ido-ubiquitous-fallback
688 (format "ido-ubiquitous encountered an unexpected error: %S"
689 err))))
691 (list (format "ido-ubiquitous encountered an unexpected error: %S"
692 err)))))
690693 ;; Handler for ido-ubiquitous-fallback signal
691694 (ido-ubiquitous-fallback
692695 (ido-ubiquitous--explain-fallback sig)
102102 ido-ubiquitous-function-overrides
103103 ido-cr+-fallback-function
104104 ido-cr+-max-items
105 ido-cr+-replace-completely))
105 ido-cr+-replace-completely
106 ido-confirm-unique-completion))
106107 (idu-bindings
107108 (cl-loop for var in ido-ubiquitous-options collect
108109 (list var
212213 (completing-read "Prompt: " collection))
213214 (all-completions "b" collection))
214215 :tag tag))
215 (case override
216 (cl-case override
216217 (enable
217218 ;; Test for new style
218219 (should-with-tag
341342 (ert-deftest ido-cr+-require-match ()
342343 :tags '(ido ido-cr+)
343344 "Test whether require-match works."
344 ;; "C-j" should be allowed to return an empty string even if
345 ;; require-match is non-nil, as long as default is nil
346 (should
347 (string=
348 ""
349 (with-simulated-input "C-j"
350 (ido-completing-read+
351 "Prompt: "
352 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
353 ;; "C-j" should NOT be allowed to return an empty string if
354 ;; require-match and default are both non-nil.
355 (should-error
356 (with-simulated-input "C-j"
357 (ido-completing-read+
358 "Prompt: "
359 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t nil nil "yellow")))
360 ;; Multiple presses of C-j won't just select the first match
361 (should-error
362 (with-simulated-input "b C-j C-j C-j"
363 (ido-completing-read+
364 "Prompt: "
365 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
366 ;; First press of C-j should complete unique common prefix after the
367 ;; first b, but then get stuck on the choice for the second b.
368 (should-error
369 (with-simulated-input "b C-j b C-j C-j"
370 (ido-completing-read+
371 "Prompt: "
372 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
373 ;; This should complete to "blueberry" via 2 rounds of unique common
374 ;; prefix completion, and then return on the 3rd "C-j"
375 (should
376 (string=
377 "blueberry"
378 (with-simulated-input "b C-j b C-j e C-j C-j"
379 (ido-completing-read+
380 "Prompt: "
381 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
382 ;; The "C-j" should complete to "bluegrass" but should
383 ;; not return.
384 (should-error
385 (with-simulated-input "b l u e g C-j"
386 (ido-completing-read+
387 "Prompt: "
388 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
389 ;; The first "C-j" should complete to "bluegrass", and the second
390 ;; should return.
391 (should
392 (string=
393 "bluegrass"
394 (with-simulated-input "b l u e g C-j C-j"
395 (ido-completing-read+
396 "Prompt: "
397 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
398 ;; Finally, a few tests for the expected wrong behavior without
399 ;; ido-cr+. If ido.el ever fixes this bug, it will cause this test
400 ;; to fail as a signal that the workaround can be phased out.
401 (should
402 (string=
403 ""
404 (with-simulated-input "C-j"
405 (ido-completing-read
406 "Prompt: "
407 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
408 (should
409 (string=
410 "b"
411 (with-simulated-input "b C-j"
412 (ido-completing-read
413 "Prompt: "
414 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))))
345 (with-ido-ubiquitous-standard-env
346 ;; "C-j" should be allowed to return an empty string even if
347 ;; require-match is non-nil, as long as default is nil
348 (should
349 (string=
350 ""
351 (with-simulated-input "C-j"
352 (ido-completing-read+
353 "Prompt: "
354 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
355 ;; "C-j" should NOT be allowed to return an empty string if
356 ;; require-match and default are both non-nil.
357 (should-error
358 (with-simulated-input "C-j"
359 (ido-completing-read+
360 "Prompt: "
361 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t nil nil "yellow")))
362 ;; Multiple presses of C-j won't just select the first match
363 (should-error
364 (with-simulated-input "b C-j C-j C-j"
365 (ido-completing-read+
366 "Prompt: "
367 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
368 ;; First press of C-j should complete unique common prefix after the
369 ;; first b, but then get stuck on the choice for the second b.
370 (should-error
371 (with-simulated-input "b C-j b C-j C-j"
372 (ido-completing-read+
373 "Prompt: "
374 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
375 ;; This should complete to "blueberry" via 2 rounds of unique common
376 ;; prefix completion, and then return on the 3rd "C-j"
377 (should
378 (string=
379 "blueberry"
380 (with-simulated-input "b C-j b C-j e C-j C-j"
381 (ido-completing-read+
382 "Prompt: "
383 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
384 ;; The "C-j" should complete to "bluegrass" and return, because
385 ;; `ido-confirm-unique-completion is nil.
386 (should
387 (string=
388 "bluegrass"
389 (with-simulated-input "b l u e g C-j"
390 (ido-completing-read+
391 "Prompt: "
392 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
393 (let ((ido-confirm-unique-completion t))
394 ;; Now the first "C-j" should complete to "bluegrass" but should
395 ;; not return.
396 (should-error
397 (with-simulated-input "b l u e g C-j"
398 (ido-completing-read+
399 "Prompt: "
400 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
401 ;; The first "C-j" should complete to "bluegrass", and the second
402 ;; should return.
403 (should
404 (string=
405 "bluegrass"
406 (with-simulated-input "b l u e g C-j C-j"
407 (ido-completing-read+
408 "Prompt: "
409 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))))
410 ;; Finally, a few tests for the expected wrong behavior without
411 ;; ido-cr+. If ido.el ever fixes this bug, it will cause this test
412 ;; to fail as a signal that the workaround can be phased out.
413 (should
414 (string=
415 ""
416 (with-simulated-input "C-j"
417 (ido-completing-read
418 "Prompt: "
419 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
420 (should
421 (string=
422 "b"
423 (with-simulated-input "b C-j"
424 (ido-completing-read
425 "Prompt: "
426 '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))))
415427
416428 ;; Functions to define overrides on for testing
417429 (defun idu-no-override-testfunc ()
44 ;; Filename: test-helper.el
55 ;; Author: Ryan C. Thompson
66 ;; Created: Sat Nov 21 15:27:00 2015 (-0800)
7 ;; Version:
8 ;; Package-Requires: ()
9 ;; URL:
10 ;; Keywords:
11
12 ;; This file is NOT part of GNU Emacs.
13
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15 ;;
16 ;;; Commentary:
17
18 ;;
197
208 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
219 ;;
4937 (require 'ido-completing-read+)
5038 (require 'ido-ubiquitous)
5139
52 (provide 'test-helper)
53
5440 ;;; test-helper.el ends here