New upstream version 3.16
Lev Lamberov
6 years ago
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 | ||
0 | 13 | 2016-06-18 Ryan C. Thompson <rct@thompsonclan.org> |
1 | 14 | |
2 | 15 | * ido-ubiquitous.el (completing-read-ido-ubiquitous): Fix an edge |
22 | 22 | |
23 | 23 | If you are using this package, you probably want to enable ido |
24 | 24 | 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.) | |
27 | 28 | |
28 | 29 | ## Ido itself ## |
29 | 30 | |
45 | 46 | Smex allows you to use ido for completion of commands in M-x, with |
46 | 47 | enhancements like putting your most-used commands at the front of the |
47 | 48 | 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.) | |
49 | 61 | |
50 | 62 | ## ido-yes-or-no ## |
51 | 63 | |
84 | 96 | |
85 | 97 | * Magit: `(setq magit-completing-read-function 'magit-ido-completing-read)` |
86 | 98 | * 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.) | |
90 | 99 | |
91 | 100 | # Frequently asked questions # |
92 | 101 |
4 | 4 | ;; Filename: ido-completing-read+.el |
5 | 5 | ;; Author: Ryan Thompson |
6 | 6 | ;; Created: Sat Apr 4 13:41:20 2015 (-0700) |
7 | ;; Version: 3.14 | |
7 | ;; Version: 3.16 | |
8 | 8 | ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) |
9 | 9 | ;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous |
10 | 10 | ;; Keywords: ido, completion, convenience |
40 | 40 | ;; |
41 | 41 | ;;; Code: |
42 | 42 | |
43 | (defconst ido-completing-read+-version "3.14" | |
43 | (defconst ido-completing-read+-version "3.16" | |
44 | 44 | "Currently running version of ido-ubiquitous. |
45 | 45 | |
46 | 46 | Note that when you update ido-completing-read+, this variable may |
59 | 59 | :global t |
60 | 60 | :group 'ido-completing-read-plus) |
61 | 61 | |
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))) | |
67 | 65 | |
68 | 66 | ;;; Core code |
69 | 67 | |
142 | 140 | (when ido-cr+-debug-mode |
143 | 141 | (when (and (listp arg) |
144 | 142 | (eq (car arg) 'ido-cr+-fallback)) |
145 | (setq arg (cdr arg))) | |
143 | (setq arg (cadr arg))) | |
146 | 144 | (ido-cr+--debug-message "Falling back to `%s' because %s." |
147 | ido-cr+-fallback-function arg))) | |
145 | ido-cr+-fallback-function arg))) | |
148 | 146 | |
149 | 147 | ;;;###autoload |
150 | 148 | (defun ido-completing-read+ (prompt collection &optional predicate |
168 | 166 | (cond |
169 | 167 | (inherit-input-method |
170 | 168 | (signal 'ido-cr+-fallback |
171 | "ido cannot handle non-nil INHERIT-INPUT-METHOD")) | |
169 | '("ido cannot handle non-nil INHERIT-INPUT-METHOD"))) | |
172 | 170 | ((bound-and-true-p completion-extra-properties) |
173 | 171 | (signal 'ido-cr+-fallback |
174 | "ido cannot handle non-nil `completion-extra-properties'")) | |
172 | '("ido cannot handle non-nil `completion-extra-properties'"))) | |
175 | 173 | ((functionp collection) |
176 | 174 | (signal 'ido-cr+-fallback |
177 | "ido cannot handle COLLECTION being a function"))) | |
175 | '("ido cannot handle COLLECTION being a function")))) | |
178 | 176 | ;; Expand all possible completions |
179 | 177 | (setq collection (all-completions "" collection predicate)) |
180 | 178 | ;; Check for excessively large collection |
181 | 179 | (when (and ido-cr+-max-items |
182 | 180 | (> (length collection) ido-cr+-max-items)) |
183 | 181 | (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)))) | |
187 | 186 | ;; ido doesn't natively handle DEF being a list. If DEF is a |
188 | 187 | ;; list, prepend it to COLLECTION and set DEF to just the |
189 | 188 | ;; car of the default list. |
218 | 217 | ;; This detects when the user triggered fallback mode |
219 | 218 | ;; manually. |
220 | 219 | (when (eq ido-exit 'fallback) |
221 | (signal 'ido-cr+-fallback "user manually triggered fallback")))) | |
220 | (signal 'ido-cr+-fallback '("user manually triggered fallback"))))) | |
222 | 221 | ;; Handler for ido-cr+-fallback signal |
223 | 222 | (ido-cr+-fallback |
224 | 223 | (ido-cr+--explain-fallback sig) |
301 | 300 | (not (member ido-text (with-no-warnings ido-cur-list)))) |
302 | 301 | (progn |
303 | 302 | (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)") | |
305 | 304 | (ido-complete)) |
306 | 305 | ad-do-it)) |
307 | 306 |
3 | 3 | |
4 | 4 | ;; Author: Ryan C. Thompson |
5 | 5 | ;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous |
6 | ;; Version: 3.14 | |
6 | ;; Version: 3.16 | |
7 | 7 | ;; Created: 2011-09-01 |
8 | 8 | ;; Keywords: convenience, completion, ido |
9 | 9 | ;; 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")) | |
11 | 11 | ;; Filename: ido-ubiquitous.el |
12 | 12 | |
13 | 13 | ;; This file is NOT part of GNU Emacs. |
68 | 68 | ;; |
69 | 69 | ;;; Code: |
70 | 70 | |
71 | (defconst ido-ubiquitous-version "3.14" | |
71 | (defconst ido-ubiquitous-version "3.16" | |
72 | 72 | "Currently running version of ido-ubiquitous. |
73 | 73 | |
74 | 74 | Note that when you update ido-ubiquitous, this variable may not |
101 | 101 | :global t |
102 | 102 | :group 'ido-ubiquitous) |
103 | 103 | |
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))) | |
109 | 107 | |
110 | 108 | (defun ido-ubiquitous--explain-fallback (arg) |
111 | 109 | ;; This function accepts a string, or an ido-ubiquitous-fallback |
113 | 111 | (when ido-ubiquitous-debug-mode |
114 | 112 | (when (and (listp arg) |
115 | 113 | (eq (car arg) 'ido-ubiquitous-fallback)) |
116 | (setq arg (cdr arg))) | |
114 | (setq arg (cadr arg))) | |
117 | 115 | (ido-ubiquitous--debug-message "Falling back to `%s' because %s." |
118 | 116 | ido-cr+-fallback-function arg))) |
119 | 117 | |
332 | 330 | (enable exact "find-tag") |
333 | 331 | ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/89 |
334 | 332 | (enable prefix "etags-select-") |
335 | ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/110 | |
336 | (enable regexp "\\`describe-\\(function\\|variable\\)\\'") | |
337 | 333 | ) ; Close paren on separate line for better VC diffs |
338 | 334 | "Default value of `ido-ubiquitous-command-overrides'. |
339 | 335 | |
365 | 361 | (enable exact "imenu--completion-buffer") |
366 | 362 | ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/74 |
367 | 363 | (enable-old exact "auto-insert") |
364 | ;; https://github.com/DarwinAwardWinner/ido-ubiquitous/issues/116 | |
365 | (enable exact "project--completing-read-strict") | |
368 | 366 | ) ; Close paren on separate line for better VC diffs |
369 | 367 | "Default value of `ido-ubiquitous-function-overrides'. |
370 | 368 | |
666 | 664 | ;; If ido-ubiquitous is disabled this time, fall back |
667 | 665 | (when (eq ido-ubiquitous-active-state 'disable) |
668 | 666 | (signal 'ido-ubiquitous-fallback |
669 | "`ido-ubiquitous-active-state' is `disable'")) | |
667 | '("`ido-ubiquitous-active-state' is `disable'"))) | |
670 | 668 | ;; Handle a collection that is a function: either expand |
671 | 669 | ;; completion list now or fall back |
672 | 670 | (when (functionp collection) |
678 | 676 | ;; so it now becomes redundant. |
679 | 677 | predicate nil) |
680 | 678 | (signal 'ido-ubiquitous-fallback |
681 | "COLLECTION is a function and there is no override"))) | |
679 | '("COLLECTION is a function and there is no override")))) | |
682 | 680 | (let ((ido-ubiquitous-enable-next-call t)) |
683 | 681 | (ido-completing-read+ |
684 | 682 | prompt collection predicate require-match |
685 | 683 | 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. | |
686 | 689 | (error |
687 | 690 | (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))))) | |
690 | 693 | ;; Handler for ido-ubiquitous-fallback signal |
691 | 694 | (ido-ubiquitous-fallback |
692 | 695 | (ido-ubiquitous--explain-fallback sig) |
102 | 102 | ido-ubiquitous-function-overrides |
103 | 103 | ido-cr+-fallback-function |
104 | 104 | ido-cr+-max-items |
105 | ido-cr+-replace-completely)) | |
105 | ido-cr+-replace-completely | |
106 | ido-confirm-unique-completion)) | |
106 | 107 | (idu-bindings |
107 | 108 | (cl-loop for var in ido-ubiquitous-options collect |
108 | 109 | (list var |
212 | 213 | (completing-read "Prompt: " collection)) |
213 | 214 | (all-completions "b" collection)) |
214 | 215 | :tag tag)) |
215 | (case override | |
216 | (cl-case override | |
216 | 217 | (enable |
217 | 218 | ;; Test for new style |
218 | 219 | (should-with-tag |
341 | 342 | (ert-deftest ido-cr+-require-match () |
342 | 343 | :tags '(ido ido-cr+) |
343 | 344 | "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)))))) | |
415 | 427 | |
416 | 428 | ;; Functions to define overrides on for testing |
417 | 429 | (defun idu-no-override-testfunc () |
4 | 4 | ;; Filename: test-helper.el |
5 | 5 | ;; Author: Ryan C. Thompson |
6 | 6 | ;; 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 | ;; | |
19 | 7 | |
20 | 8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
21 | 9 | ;; |
49 | 37 | (require 'ido-completing-read+) |
50 | 38 | (require 'ido-ubiquitous) |
51 | 39 | |
52 | (provide 'test-helper) | |
53 | ||
54 | 40 | ;;; test-helper.el ends here |