[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 172f7e5: Support PREDICATE in ido-read-buffer
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master 172f7e5: Support PREDICATE in ido-read-buffer |
Date: |
Wed, 28 Feb 2018 08:43:51 -0500 (EST) |
branch: master
commit 172f7e5488ff91e2bef2d8217a91ffda0defb368
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Support PREDICATE in ido-read-buffer
* lisp/ido.el (ido-predicate): New variable.
(ido-read-buffer): Bind it.
(ido-make-buffer-list): Use it.
---
lisp/ido.el | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lisp/ido.el b/lisp/ido.el
index da0c9d4..7ff3d68 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -1135,6 +1135,9 @@ selected.")
(defvar ido-current-directory nil
"Current directory for `ido-find-file'.")
+(defvar ido-predicate nil
+ "Current completion predicate.")
+
(defvar ido-auto-merge-timer nil
"Delay timer for auto merge.")
@@ -3480,6 +3483,11 @@ it is put to the start of the list."
(if ido-temp-list
(nconc ido-temp-list ido-current-buffers)
(setq ido-temp-list ido-current-buffers))
+ (if ido-predicate
+ (setq ido-temp-list (seq-filter
+ (lambda (name)
+ (funcall ido-predicate (cons name (get-buffer
name))))
+ ido-temp-list)))
(if default
(setq ido-temp-list
(cons default (delete default ido-temp-list))))
@@ -4845,10 +4853,13 @@ Modified from `icomplete-completions'."
Return the name of a buffer selected.
PROMPT is the prompt to give to the user. DEFAULT if given is the default
buffer to be selected, which will go to the front of the list.
-If REQUIRE-MATCH is non-nil, an existing buffer must be selected."
+If REQUIRE-MATCH is non-nil, an existing buffer must be selected.
+Optional arg PREDICATE if non-nil is a function limiting the
+buffers that can be considered."
(let* ((ido-current-directory nil)
(ido-directory-nonreadable nil)
(ido-directory-too-big nil)
+ (ido-predicate predicate)
(ido-context-switch-command 'ignore)
(buf (ido-read-internal 'buffer prompt 'ido-buffer-history default
require-match)))
(if (eq ido-exit 'fallback)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 172f7e5: Support PREDICATE in ido-read-buffer,
Dmitry Gutov <=