diff options
| author | Dmitry Gutov | 2018-02-28 15:43:40 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2018-02-28 15:43:40 +0200 |
| commit | 172f7e5488ff91e2bef2d8217a91ffda0defb368 (patch) | |
| tree | 7f6ce2e3d6074e7ceabc773345f0b9bb7c5c258c | |
| parent | 108ce84432d597f92637ea74bd0a094224d157de (diff) | |
| download | emacs-172f7e5488ff91e2bef2d8217a91ffda0defb368.tar.gz emacs-172f7e5488ff91e2bef2d8217a91ffda0defb368.zip | |
Support PREDICATE in ido-read-buffer
* lisp/ido.el (ido-predicate): New variable.
(ido-read-buffer): Bind it.
(ido-make-buffer-list): Use it.
| -rw-r--r-- | lisp/ido.el | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/ido.el b/lisp/ido.el index da0c9d463d1..7ff3d6820b4 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -1135,6 +1135,9 @@ selected.") | |||
| 1135 | (defvar ido-current-directory nil | 1135 | (defvar ido-current-directory nil |
| 1136 | "Current directory for `ido-find-file'.") | 1136 | "Current directory for `ido-find-file'.") |
| 1137 | 1137 | ||
| 1138 | (defvar ido-predicate nil | ||
| 1139 | "Current completion predicate.") | ||
| 1140 | |||
| 1138 | (defvar ido-auto-merge-timer nil | 1141 | (defvar ido-auto-merge-timer nil |
| 1139 | "Delay timer for auto merge.") | 1142 | "Delay timer for auto merge.") |
| 1140 | 1143 | ||
| @@ -3480,6 +3483,11 @@ it is put to the start of the list." | |||
| 3480 | (if ido-temp-list | 3483 | (if ido-temp-list |
| 3481 | (nconc ido-temp-list ido-current-buffers) | 3484 | (nconc ido-temp-list ido-current-buffers) |
| 3482 | (setq ido-temp-list ido-current-buffers)) | 3485 | (setq ido-temp-list ido-current-buffers)) |
| 3486 | (if ido-predicate | ||
| 3487 | (setq ido-temp-list (seq-filter | ||
| 3488 | (lambda (name) | ||
| 3489 | (funcall ido-predicate (cons name (get-buffer name)))) | ||
| 3490 | ido-temp-list))) | ||
| 3483 | (if default | 3491 | (if default |
| 3484 | (setq ido-temp-list | 3492 | (setq ido-temp-list |
| 3485 | (cons default (delete default ido-temp-list)))) | 3493 | (cons default (delete default ido-temp-list)))) |
| @@ -4845,10 +4853,13 @@ Modified from `icomplete-completions'." | |||
| 4845 | Return the name of a buffer selected. | 4853 | Return the name of a buffer selected. |
| 4846 | PROMPT is the prompt to give to the user. DEFAULT if given is the default | 4854 | PROMPT is the prompt to give to the user. DEFAULT if given is the default |
| 4847 | buffer to be selected, which will go to the front of the list. | 4855 | buffer to be selected, which will go to the front of the list. |
| 4848 | If REQUIRE-MATCH is non-nil, an existing buffer must be selected." | 4856 | If REQUIRE-MATCH is non-nil, an existing buffer must be selected. |
| 4857 | Optional arg PREDICATE if non-nil is a function limiting the | ||
| 4858 | buffers that can be considered." | ||
| 4849 | (let* ((ido-current-directory nil) | 4859 | (let* ((ido-current-directory nil) |
| 4850 | (ido-directory-nonreadable nil) | 4860 | (ido-directory-nonreadable nil) |
| 4851 | (ido-directory-too-big nil) | 4861 | (ido-directory-too-big nil) |
| 4862 | (ido-predicate predicate) | ||
| 4852 | (ido-context-switch-command 'ignore) | 4863 | (ido-context-switch-command 'ignore) |
| 4853 | (buf (ido-read-internal 'buffer prompt 'ido-buffer-history default require-match))) | 4864 | (buf (ido-read-internal 'buffer prompt 'ido-buffer-history default require-match))) |
| 4854 | (if (eq ido-exit 'fallback) | 4865 | (if (eq ido-exit 'fallback) |