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

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

[elpa] externals/ivy-hydra 8783d92 321/395: ivy.el: Remove most minibuff


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 8783d92 321/395: ivy.el: Remove most minibuffer-only commands from the counsel-M-x list
Date: Thu, 25 Feb 2021 08:32:29 -0500 (EST)

branch: externals/ivy-hydra
commit 8783d92d1b5de244cc89c421a0347243929eafb2
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    ivy.el: Remove most minibuffer-only commands from the counsel-M-x list
---
 ivy-hydra.el |  15 +++++--
 ivy.el       | 142 ++++++++++++++++++++++++++++++-----------------------------
 2 files changed, 85 insertions(+), 72 deletions(-)

diff --git a/ivy-hydra.el b/ivy-hydra.el
index 0c701a6..aaac828 100644
--- a/ivy-hydra.el
+++ b/ivy-hydra.el
@@ -55,8 +55,7 @@
                 (cl-decf ivy-height))
     (window-resize nil -1)))
 
-(defhydra hydra-ivy (:hint nil
-                           :color pink)
+(defhydra hydra-ivy (:hint nil :color pink)
   "
 ^ ^ ^ ^ ^ ^ | ^Call^      ^ ^  | ^Cancel^ | ^Options^ | Action _w_/_s_/_a_: 
%-14s(ivy-action-name)
 
^-^-^-^-^-^-+-^-^---------^-^--+-^-^------+-^-^-------+-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------
@@ -99,6 +98,17 @@ _h_ ^+^ _l_ | _d_one      ^ ^  | _o_ops   | _M_: matcher 
%-5s(ivy--matcher-desc)
   ("D" (ivy-exit-with-action
         (lambda (_) (find-function 'hydra-ivy/body)))
    :exit t))
+(dolist (sym '(
+               ;; these cmds have a binding here
+               ivy-next-action ivy-prev-action
+               ivy-unmark-backward ivy-toggle-case-fold
+               ivy-minibuffer-grow ivy-minibuffer-shrink
+               ivy-rotate-preferred-builders ivy-toggle-calling
+               ;; no binding
+               ivy-next-line-or-history ivy-previous-line-or-history
+               ivy-toggle-fuzzy ivy-yank-symbol
+               ivy-occur-next-error))
+  (put sym 'no-counsel-M-x t))
 
 (defvar ivy-dispatching-done-columns 2
   "Number of columns to use if the hint does not fit on one line.")
@@ -112,7 +122,6 @@ _h_ ^+^ _l_ | _d_one      ^ ^  | _o_ops   | _M_: matcher 
%-5s(ivy--matcher-desc)
 
 (defun ivy-hydra-read-action (actions)
   "Select one of the available actions and call `ivy-done'."
-  (interactive)
   (let* ((extra-actions ivy-dispatching-done-hydra-exit-keys)
          (doc (concat "action: "
                       (mapconcat
diff --git a/ivy.el b/ivy.el
index 21aa522..7444bfc 100644
--- a/ivy.el
+++ b/ivy.el
@@ -137,8 +137,8 @@ Examples of properties include associated `:cleanup' 
functions.")
     (t . nil))
   "An alist for customizing where to display the candidates.
 
-Each key is a caller symbol. When the value is nil (the default),
-the candidates are shown in the minibuffer. Otherwise, the value
+Each key is a caller symbol.  When the value is nil (the default),
+the candidates are shown in the minibuffer.  Otherwise, the value
 is a function which takes a string argument comprising the
 current matching candidates and displays it somewhere.
 
@@ -300,58 +300,64 @@ action functions.")
 
 ;;* Keymap
 (require 'delsel)
+(defun ivy-define-key (keymap key def)
+  "Forward to (`ivy-define-key' KEYMAP KEY DEF).
+Remove DEF from `counsel-M-x' list."
+  (put def 'no-counsel-M-x t)
+  (define-key keymap key def))
+
 (defvar ivy-minibuffer-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-m") 'ivy-done)
+    (ivy-define-key map (kbd "C-m") 'ivy-done)
     (define-key map [down-mouse-1] 'ignore)
-    (define-key map [mouse-1] 'ivy-mouse-done)
-    (define-key map [mouse-3] 'ivy-mouse-dispatching-done)
-    (define-key map (kbd "C-M-m") 'ivy-call)
-    (define-key map (kbd "C-j") 'ivy-alt-done)
-    (define-key map (kbd "C-M-j") 'ivy-immediate-done)
-    (define-key map (kbd "TAB") 'ivy-partial-or-done)
-    (define-key map [remap next-line] 'ivy-next-line)
-    (define-key map [remap previous-line] 'ivy-previous-line)
-    (define-key map (kbd "C-r") 'ivy-reverse-i-search)
+    (ivy-define-key map [mouse-1] 'ivy-mouse-done)
+    (ivy-define-key map [mouse-3] 'ivy-mouse-dispatching-done)
+    (ivy-define-key map (kbd "C-M-m") 'ivy-call)
+    (ivy-define-key map (kbd "C-j") 'ivy-alt-done)
+    (ivy-define-key map (kbd "C-M-j") 'ivy-immediate-done)
+    (ivy-define-key map (kbd "TAB") 'ivy-partial-or-done)
+    (ivy-define-key map [remap next-line] 'ivy-next-line)
+    (ivy-define-key map [remap previous-line] 'ivy-previous-line)
+    (ivy-define-key map (kbd "C-r") 'ivy-reverse-i-search)
     (define-key map (kbd "SPC") 'self-insert-command)
-    (define-key map [remap delete-backward-char] 'ivy-backward-delete-char)
-    (define-key map [remap backward-delete-char-untabify] 
'ivy-backward-delete-char)
-    (define-key map [remap backward-kill-word] 'ivy-backward-kill-word)
-    (define-key map [remap delete-char] 'ivy-delete-char)
-    (define-key map [remap forward-char] 'ivy-forward-char)
-    (define-key map (kbd "<right>") 'ivy-forward-char)
-    (define-key map [remap kill-word] 'ivy-kill-word)
-    (define-key map [remap beginning-of-buffer] 'ivy-beginning-of-buffer)
-    (define-key map [remap end-of-buffer] 'ivy-end-of-buffer)
-    (define-key map (kbd "M-n") 'ivy-next-history-element)
-    (define-key map (kbd "M-p") 'ivy-previous-history-element)
+    (ivy-define-key map [remap delete-backward-char] 'ivy-backward-delete-char)
+    (ivy-define-key map [remap backward-delete-char-untabify] 
'ivy-backward-delete-char)
+    (ivy-define-key map [remap backward-kill-word] 'ivy-backward-kill-word)
+    (ivy-define-key map [remap delete-char] 'ivy-delete-char)
+    (ivy-define-key map [remap forward-char] 'ivy-forward-char)
+    (ivy-define-key map (kbd "<right>") 'ivy-forward-char)
+    (ivy-define-key map [remap kill-word] 'ivy-kill-word)
+    (ivy-define-key map [remap beginning-of-buffer] 'ivy-beginning-of-buffer)
+    (ivy-define-key map [remap end-of-buffer] 'ivy-end-of-buffer)
+    (ivy-define-key map (kbd "M-n") 'ivy-next-history-element)
+    (ivy-define-key map (kbd "M-p") 'ivy-previous-history-element)
     (define-key map (kbd "C-g") 'minibuffer-keyboard-quit)
-    (define-key map [remap scroll-up-command] 'ivy-scroll-up-command)
-    (define-key map [remap scroll-down-command] 'ivy-scroll-down-command)
-    (define-key map (kbd "<next>") 'ivy-scroll-up-command)
-    (define-key map (kbd "<prior>") 'ivy-scroll-down-command)
-    (define-key map (kbd "C-v") 'ivy-scroll-up-command)
-    (define-key map (kbd "M-v") 'ivy-scroll-down-command)
-    (define-key map (kbd "C-M-n") 'ivy-next-line-and-call)
-    (define-key map (kbd "C-M-p") 'ivy-previous-line-and-call)
-    (define-key map (kbd "M-a") 'ivy-toggle-marks)
-    (define-key map (kbd "M-r") 'ivy-toggle-regexp-quote)
-    (define-key map (kbd "M-j") 'ivy-yank-word)
-    (define-key map (kbd "M-i") 'ivy-insert-current)
-    (define-key map (kbd "C-M-y") 'ivy-insert-current-full)
-    (define-key map (kbd "C-o") 'hydra-ivy/body)
-    (define-key map (kbd "M-o") 'ivy-dispatching-done)
-    (define-key map (kbd "C-M-o") 'ivy-dispatching-call)
-    (define-key map [remap kill-line] 'ivy-kill-line)
-    (define-key map [remap kill-whole-line] 'ivy-kill-whole-line)
-    (define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
-    (define-key map [remap kill-ring-save] 'ivy-kill-ring-save)
-    (define-key map (kbd "C-M-a") 'ivy-read-action)
-    (define-key map (kbd "C-c C-o") 'ivy-occur)
-    (define-key map (kbd "C-c C-a") 'ivy-toggle-ignore)
-    (define-key map (kbd "C-c C-s") 'ivy-rotate-sort)
-    (define-key map [remap describe-mode] 'ivy-help)
-    (define-key map "$" 'ivy-magic-read-file-env)
+    (ivy-define-key map [remap scroll-up-command] 'ivy-scroll-up-command)
+    (ivy-define-key map [remap scroll-down-command] 'ivy-scroll-down-command)
+    (ivy-define-key map (kbd "<next>") 'ivy-scroll-up-command)
+    (ivy-define-key map (kbd "<prior>") 'ivy-scroll-down-command)
+    (ivy-define-key map (kbd "C-v") 'ivy-scroll-up-command)
+    (ivy-define-key map (kbd "M-v") 'ivy-scroll-down-command)
+    (ivy-define-key map (kbd "C-M-n") 'ivy-next-line-and-call)
+    (ivy-define-key map (kbd "C-M-p") 'ivy-previous-line-and-call)
+    (ivy-define-key map (kbd "M-a") 'ivy-toggle-marks)
+    (ivy-define-key map (kbd "M-r") 'ivy-toggle-regexp-quote)
+    (ivy-define-key map (kbd "M-j") 'ivy-yank-word)
+    (ivy-define-key map (kbd "M-i") 'ivy-insert-current)
+    (ivy-define-key map (kbd "C-M-y") 'ivy-insert-current-full)
+    (ivy-define-key map (kbd "C-o") 'hydra-ivy/body)
+    (ivy-define-key map (kbd "M-o") 'ivy-dispatching-done)
+    (ivy-define-key map (kbd "C-M-o") 'ivy-dispatching-call)
+    (ivy-define-key map [remap kill-line] 'ivy-kill-line)
+    (ivy-define-key map [remap kill-whole-line] 'ivy-kill-whole-line)
+    (ivy-define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
+    (ivy-define-key map [remap kill-ring-save] 'ivy-kill-ring-save)
+    (ivy-define-key map (kbd "C-M-a") 'ivy-read-action)
+    (ivy-define-key map (kbd "C-c C-o") 'ivy-occur)
+    (ivy-define-key map (kbd "C-c C-a") 'ivy-toggle-ignore)
+    (ivy-define-key map (kbd "C-c C-s") 'ivy-rotate-sort)
+    (ivy-define-key map [remap describe-mode] 'ivy-help)
+    (ivy-define-key map "$" 'ivy-magic-read-file-env)
     map)
   "Keymap used in the minibuffer.")
 (autoload 'hydra-ivy/body "ivy-hydra" "" t)
@@ -359,10 +365,8 @@ action functions.")
 
 (defvar ivy-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [remap switch-to-buffer]
-      'ivy-switch-buffer)
-    (define-key map [remap switch-to-buffer-other-window]
-      'ivy-switch-buffer-other-window)
+    (ivy-define-key map [remap switch-to-buffer] 'ivy-switch-buffer)
+    (ivy-define-key map [remap switch-to-buffer-other-window] 
'ivy-switch-buffer-other-window)
     map)
   "Keymap for `ivy-mode'.")
 
@@ -716,10 +720,10 @@ candidate, not the prompt."
 
 (defvar ivy-mouse-1-tooltip
   "Exit the minibuffer with the selected candidate."
-  "The doc visible in the tooltip for mouse-1 binding in the minibuffer")
+  "The doc visible in the tooltip for mouse-1 binding in the minibuffer.")
 (defvar ivy-mouse-3-tooltip
   "Display alternative actions."
-  "The doc visible in the tooltip for mouse-3 binding in the minibuffer")
+  "The doc visible in the tooltip for mouse-3 binding in the minibuffer.")
 
 (defun ivy-mouse-offset (event)
   "Compute the offset between the candidate at point and the selected one."
@@ -4397,7 +4401,7 @@ BUFFER may be a string or nil."
 
 (defvar ivy-switch-buffer-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-k") 'ivy-switch-buffer-kill)
+    (ivy-define-key map (kbd "C-k") 'ivy-switch-buffer-kill)
     map))
 
 (defun ivy-switch-buffer-kill ()
@@ -4734,7 +4738,7 @@ This list can be rotated with 
`ivy-rotate-preferred-builders'."
 
 (defvar ivy-reverse-i-search-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-k") 'ivy-reverse-i-search-kill)
+    (ivy-define-key map (kbd "C-k") 'ivy-reverse-i-search-kill)
     map))
 
 (defun ivy-history-contents (history)
@@ -4802,20 +4806,20 @@ buffer would modify `ivy-last'.")
 
 (defvar ivy-occur-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-1] 'ivy-occur-click)
-    (define-key map (kbd "RET") 'ivy-occur-press-and-switch)
-    (define-key map (kbd "j") 'ivy-occur-next-line)
-    (define-key map (kbd "k") 'ivy-occur-previous-line)
+    (ivy-define-key map [mouse-1] 'ivy-occur-click)
+    (ivy-define-key map (kbd "RET") 'ivy-occur-press-and-switch)
+    (ivy-define-key map (kbd "j") 'ivy-occur-next-line)
+    (ivy-define-key map (kbd "k") 'ivy-occur-previous-line)
     (define-key map (kbd "h") 'backward-char)
     (define-key map (kbd "l") 'forward-char)
-    (define-key map (kbd "f") 'ivy-occur-press)
-    (define-key map (kbd "g") 'ivy-occur-revert-buffer)
-    (define-key map (kbd "a") 'ivy-occur-read-action)
-    (define-key map (kbd "o") 'ivy-occur-dispatch)
-    (define-key map (kbd "c") 'ivy-occur-toggle-calling)
+    (ivy-define-key map (kbd "f") 'ivy-occur-press)
+    (ivy-define-key map (kbd "g") 'ivy-occur-revert-buffer)
+    (ivy-define-key map (kbd "a") 'ivy-occur-read-action)
+    (ivy-define-key map (kbd "o") 'ivy-occur-dispatch)
+    (ivy-define-key map (kbd "c") 'ivy-occur-toggle-calling)
     (define-key map (kbd "q") 'quit-window)
     (define-key map (kbd "R") 'read-only-mode)
-    (define-key map (kbd "C-d") 'ivy-occur-delete-candidate)
+    (ivy-define-key map (kbd "C-d") 'ivy-occur-delete-candidate)
     map)
   "Keymap for Ivy Occur mode.")
 
@@ -4906,8 +4910,8 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
 
 (defvar ivy-occur-grep-mode-map
   (let ((map (copy-keymap ivy-occur-mode-map)))
-    (define-key map (kbd "C-x C-q") 'ivy-wgrep-change-to-wgrep-mode)
-    (define-key map "w" 'ivy-wgrep-change-to-wgrep-mode)
+    (ivy-define-key map (kbd "C-x C-q") 'ivy-wgrep-change-to-wgrep-mode)
+    (ivy-define-key map "w" 'ivy-wgrep-change-to-wgrep-mode)
     map)
   "Keymap for Ivy Occur Grep mode.")
 



reply via email to

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