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

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

[elpa] master 7100925 302/348: ivy.el (ivy-completing-read-handlers-alis


From: Oleh Krehel
Subject: [elpa] master 7100925 302/348: ivy.el (ivy-completing-read-handlers-alist): New defcustom
Date: Sat, 8 Apr 2017 11:04:19 -0400 (EDT)

branch: master
commit 7100925470283d943768c34bdd113a82c9b14cd1
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-completing-read-handlers-alist): New defcustom
    
    Fixes #892
---
 ivy.el | 68 +++++++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 38 insertions(+), 30 deletions(-)

diff --git a/ivy.el b/ivy.el
index 774a276..1e2f83d 100644
--- a/ivy.el
+++ b/ivy.el
@@ -188,6 +188,12 @@ See 
https://github.com/abo-abo/swiper/wiki/ivy-display-function.";
   '((ivy-completion-in-region . ivy-display-function-overlay))
   "An alist for customizing `ivy-display-function'.")
 
+(defcustom ivy-completing-read-handlers-alist
+  '((tmm-menubar . completing-read-default)
+    (tmm-shortcut . completing-read-default))
+  "An alist of handlers to replace `completing-read' in `ivy-mode'."
+  :type '(alist :key-type function :value-type function))
+
 (defvar ivy--actions-list nil
   "A list of extra actions per command.")
 
@@ -1746,36 +1752,38 @@ INITIAL-INPUT is a string inserted into the minibuffer 
initially.
 HISTORY is a list of previously selected inputs.
 DEF is the default value.
 INHERIT-INPUT-METHOD is currently ignored."
-  (if (memq this-command '(tmm-menubar tmm-shortcut))
-      (completing-read-default prompt collection
-                               predicate require-match
-                               initial-input history
-                               def inherit-input-method)
-    ;; See the doc of `completing-read'.
-    (when (consp history)
-      (when (numberp (cdr history))
-        (setq initial-input (nth (1- (cdr history))
-                                 (symbol-value (car history)))))
-      (setq history (car history)))
-    (ivy-read (replace-regexp-in-string "%" "%%" prompt)
-              collection
-              :predicate predicate
-              :require-match require-match
-              :initial-input (if (consp initial-input)
-                                 (car initial-input)
-                               (if (and (stringp initial-input)
-                                        (string-match "\\+" initial-input))
-                                   (replace-regexp-in-string
-                                    "\\+" "\\\\+" initial-input)
-                                 initial-input))
-              :preselect (if (listp def) (car def) def)
-              :history history
-              :keymap nil
-              :sort
-              (let ((sort (assoc this-command ivy-sort-functions-alist)))
-                (if sort
-                    (ivy--sort-function (car sort))
-                  (or (ivy--sort-function t) t))))))
+  (let ((handler (assoc this-command ivy-completing-read-handlers-alist)))
+    (if handler
+        (funcall (cdr handler)
+                 prompt collection
+                 predicate require-match
+                 initial-input history
+                 def inherit-input-method)
+      ;; See the doc of `completing-read'.
+      (when (consp history)
+        (when (numberp (cdr history))
+          (setq initial-input (nth (1- (cdr history))
+                                   (symbol-value (car history)))))
+        (setq history (car history)))
+      (ivy-read (replace-regexp-in-string "%" "%%" prompt)
+                collection
+                :predicate predicate
+                :require-match require-match
+                :initial-input (if (consp initial-input)
+                                   (car initial-input)
+                                 (if (and (stringp initial-input)
+                                          (string-match "\\+" initial-input))
+                                     (replace-regexp-in-string
+                                      "\\+" "\\\\+" initial-input)
+                                   initial-input))
+                :preselect (if (listp def) (car def) def)
+                :history history
+                :keymap nil
+                :sort
+                (let ((sort (assoc this-command ivy-sort-functions-alist)))
+                  (if sort
+                      (ivy--sort-function (car sort))
+                    (or (ivy--sort-function t) t)))))))
 
 (defvar ivy-completion-beg nil
   "Completion bounds start.")



reply via email to

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