emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/helm a23bf2fa7b: Fix #2506 predicate in read-buffer


From: ELPA Syncer
Subject: [nongnu] elpa/helm a23bf2fa7b: Fix #2506 predicate in read-buffer
Date: Wed, 4 May 2022 04:58:20 -0400 (EDT)

branch: elpa/helm
commit a23bf2fa7b5553d2a3a8d61efa504416f876ec20
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Fix #2506 predicate in read-buffer
    
    Some predicates for read-buffer assume entries in collection like
    (BUF-NAME . BUF-OBJ) but helm candidates are strings, so modify
    predicate so that it handles both kind of entries.
---
 helm-mode.el | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/helm-mode.el b/helm-mode.el
index 1ac8e6a4c7..9d3b1c98a8 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -1149,10 +1149,25 @@ Don't use it directly."
 (defun helm--generic-read-buffer (prompt &optional default require-match 
predicate)
   "The `read-buffer-function' for `helm-mode'.
 Affects `switch-to-buffer' `kill-buffer' and related."
-  (helm--completing-read-default
-   prompt (or minibuffer-completion-table
-              (internal-complete-buffer "" nil t))
-   predicate require-match nil nil default))
+  ;; `read-buffer' is using internally `Vbuffer_alist' which is an
+  ;; alist with elements like (BUF-NAME . BUF-OBJ), therefore some
+  ;; predicates in Emacs are working only on such cons cells.
+  ;; However, helm is transforming COLLECTION in a list of strings and
+  ;; such predicates are failing because they expect cons cells (see
+  ;; bug#2506 with `project-switch-to-buffer'), even if they should
+  ;; handle strings as well according to `read-buffer'
+  ;; documentation.
+  (let ((pred (when predicate
+                (lambda (buffer)
+                  (let ((buf (cons buffer (get-buffer buffer))))
+                    (condition-case _err
+                        (funcall predicate buffer)
+                      (wrong-type-argument
+                       (funcall predicate buf))))))))
+    (helm--completing-read-default
+     prompt (or minibuffer-completion-table
+                (internal-complete-buffer "" nil t))
+     pred require-match nil nil default)))
 
 (defun helm-mode--get-default-handler-for (comp-or-file entry)
   ;; Use 'comp for completing-read and 'file for 'read-file-name as



reply via email to

[Prev in Thread] Current Thread [Next in Thread]