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

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

[elpa] externals/ivy-hydra 92e5a95 252/395: Add command counsel-describe


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 92e5a95 252/395: Add command counsel-describe-symbol
Date: Thu, 25 Feb 2021 08:32:14 -0500 (EST)

branch: externals/ivy-hydra
commit 92e5a953408447f013f9f976052c772aa2581389
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    Add command counsel-describe-symbol
    
    * counsel.el (counsel-describe-symbol-function): New user option.
    (counsel-describe-symbol): New command.
    (counsel-describe-symbol-history, counsel-mode-map):
    * ivy.el (ivy--occur-press-update-window):
    * README.md: List it alongside counsel-describe-variable and
    counsel-describe-function.
    
    Fixes #2509
    Fixes #2542
---
 README.md  |  1 +
 counsel.el | 39 +++++++++++++++++++++++++++++++++++++--
 ivy.el     |  4 +++-
 3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 658504f..f1ce587 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,7 @@ Ivy and Swiper wiki is here: [the 
wiki](https://github.com/abo-abo/swiper/wiki).
 (global-set-key (kbd "C-x C-f") 'counsel-find-file)
 (global-set-key (kbd "<f1> f") 'counsel-describe-function)
 (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
+(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
 (global-set-key (kbd "<f1> l") 'counsel-find-library)
 (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
 (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
diff --git a/counsel.el b/counsel.el
index 20a470f..2d1cb82 100644
--- a/counsel.el
+++ b/counsel.el
@@ -480,8 +480,8 @@ Update the minibuffer with the amount of lines collected 
every
 
 (defvar counsel-describe-symbol-history ()
   "History list for variable and function names.
-Used by commands `counsel-describe-variable' and
-`counsel-describe-function'.")
+Used by commands `counsel-describe-symbol',
+`counsel-describe-variable', and `counsel-describe-function'.")
 
 (defun counsel-find-symbol ()
   "Jump to the definition of the current symbol."
@@ -621,6 +621,40 @@ to `ivy-highlight-face'."
   :display-transformer-fn #'counsel-describe-function-transformer
   :sort-fn #'ivy-string<)
 
+;;** `counsel-describe-symbol'
+(defcustom counsel-describe-symbol-function #'describe-symbol
+  "Function to call to describe a symbol passed as parameter."
+  :type 'function)
+
+(defun counsel-describe-symbol ()
+  "Forward to `describe-symbol'."
+  (interactive)
+  (unless (functionp 'describe-symbol)
+    (user-error "This command requires Emacs 25.1 or later"))
+  (require 'help-mode)
+  (let ((enable-recursive-minibuffers t))
+    (ivy-read "Describe symbol: " obarray
+              :predicate (lambda (sym)
+                           (cl-some (lambda (backend)
+                                      (funcall (cadr backend) sym))
+                                    describe-symbol-backends))
+              :require-match t
+              :history 'counsel-describe-symbol-history
+              :keymap counsel-describe-map
+              :preselect (ivy-thing-at-point)
+              :action (lambda (x)
+                        (funcall counsel-describe-symbol-function (intern x)))
+              :caller 'counsel-describe-symbol)))
+
+(ivy-configure #'counsel-describe-symbol
+  :initial-input "^"
+  :sort-fn #'ivy-string<)
+
+(ivy-set-actions
+ #'counsel-describe-symbol
+ `(("I" ,#'counsel-info-lookup-symbol "info")
+   ("d" ,#'counsel--find-symbol "definition")))
+
 ;;** `counsel-set-variable'
 (defvar counsel-set-variable-history nil
   "Store history for `counsel-set-variable'.")
@@ -6760,6 +6794,7 @@ We update it in the callback with 
`ivy-update-candidates'."
                 (describe-bindings . counsel-descbinds)
                 (describe-function . counsel-describe-function)
                 (describe-variable . counsel-describe-variable)
+                (describe-symbol . counsel-describe-symbol)
                 (apropos-command . counsel-apropos)
                 (describe-face . counsel-describe-face)
                 (list-faces-display . counsel-faces)
diff --git a/ivy.el b/ivy.el
index 3eb6b9a..d8ae33d 100644
--- a/ivy.el
+++ b/ivy.el
@@ -5181,7 +5181,9 @@ EVENT gives the mouse position."
                   (switch-to-buffer buffer)))))))
 
     ((memq (ivy-state-caller ivy-occur-last)
-           '(counsel-describe-function counsel-describe-variable))
+           '(counsel-describe-function
+             counsel-describe-variable
+             counsel-describe-symbol))
      (setf (ivy-state-window ivy-occur-last)
            (selected-window))
      (selected-window))))



reply via email to

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