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

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

[elpa] master d8da9c4 188/272: counsel.el (counsel-mode): Allow use of d


From: Oleh Krehel
Subject: [elpa] master d8da9c4 188/272: counsel.el (counsel-mode): Allow use of describe-prefix-bindings
Date: Mon, 25 Apr 2016 10:13:24 +0000

branch: master
commit d8da9c4b6b5ed69b4967994be26ea382780e5a29
Author: justbur <address@hidden>
Commit: justbur <address@hidden>

    counsel.el (counsel-mode): Allow use of describe-prefix-bindings
    
    Add option to let counsel-descbinds override describe-bindings in
    counsel-mode.
    
    counsel.el (counsel-descbinds): Make signature match describe-bindings
    counsel.el (counsel--descbinds-cands): Adjust for previous change
    counsel.el (counsel-mode-override-describe-bindings): New option
---
 counsel.el |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/counsel.el b/counsel.el
index 7d11eb4..cea7f4e 100644
--- a/counsel.el
+++ b/counsel.el
@@ -632,8 +632,8 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
 (defvar counsel-descbinds-history nil
   "History for `counsel-descbinds'.")
 
-(defun counsel--descbinds-cands ()
-  (let ((buffer (current-buffer))
+(defun counsel--descbinds-cands (&optional prefix buffer)
+  (let ((buffer (or buffer (current-buffer)))
         (re-exclude (regexp-opt
                      '("<vertical-line>" "<bottom-divider>" "<right-divider>"
                        "<mode-line>" "<C-down-mouse-2>" "<left-fringe>"
@@ -642,7 +642,7 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
         res)
     (with-temp-buffer
       (let ((indent-tabs-mode t))
-        (describe-buffer-bindings buffer))
+        (describe-buffer-bindings buffer prefix))
       (goto-char (point-min))
       ;; Skip the "Key translations" section
       (re-search-forward "")
@@ -679,11 +679,11 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
     (counsel-info-lookup-symbol (symbol-name cmd))))
 
 ;;;###autoload
-(defun counsel-descbinds ()
+(defun counsel-descbinds (&optional prefix buffer)
   "Show a list of all defined keys, and their definitions.
 Describe the selected candidate."
   (interactive)
-  (ivy-read "Bindings: " (counsel--descbinds-cands)
+  (ivy-read "Bindings: " (counsel--descbinds-cands prefix buffer)
             :action #'counsel-descbinds-action-describe
             :history 'counsel-descbinds-history
             :caller 'counsel-descbinds))
@@ -1886,6 +1886,12 @@ An extra action allows to switch to the process buffer."
   "Map for `counsel-mode'. Remaps built-in functions to counsel
 replacements.")
 
+(defcustom counsel-mode-override-describe-bindings nil
+  "Whether to override `describe-bindings' when `counsel-mode' is
+active."
+  :group 'ivy
+  :type 'boolean)
+
 ;;;###autoload
 (define-minor-mode counsel-mode
   "Toggle Counsel mode on or off.
@@ -1895,7 +1901,13 @@ replacements. "
   :group 'ivy
   :global t
   :keymap counsel-mode-map
-  :lighter " counsel")
+  :lighter " counsel"
+  (if counsel-mode
+      (when (and (fboundp 'advice-add)
+                 counsel-mode-override-describe-bindings)
+        (advice-add #'describe-bindings :override #'counsel-descbinds))
+    (when (fboundp 'advice-remove)
+      (advice-remove #'describe-bindings #'counsel-descbinds))))
 
 (provide 'counsel)
 



reply via email to

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