branch: master
commit 51c5874c75c0f5d0d1c6ce2cce9517aa7d5a5894
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-find-file-map): Bind "`" to bookmarks
* ivy.el (ivy-make-magic-action): Add.
Re #1937
---
counsel.el | 1 +
ivy.el | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/counsel.el b/counsel.el
index b07ad91..6afb0d4 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1748,6 +1748,7 @@ currently checked out."
(define-key map (kbd "C-DEL") 'counsel-up-directory)
(define-key map (kbd "C-<backspace>") 'counsel-up-directory)
(define-key map (kbd "C-M-y") 'counsel-yank-directory)
+ (define-key map (kbd "`") (ivy-make-magic-action "b"))
map))
(defun counsel-yank-directory ()
diff --git a/ivy.el b/ivy.el
index 211c110..261075c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2855,6 +2855,18 @@ Possible choices are
'ivy-magic-slash-non-match-cd-selected,
(ivy--cd-maybe))
(insert last-input-event)))
+(defun ivy-make-magic-action (key)
+ "Return a command that does the equivalent of `ivy-read-action' and KEY.
+This happens only when the input is empty.
+The intention is to bind the result to keys that are typically
+bound to `self-insert-command'."
+ (lambda (&optional arg)
+ (interactive "p")
+ (if (string= "" ivy-text)
+ (execute-kbd-macro
+ (kbd (concat "M-o " key)))
+ (self-insert-command arg))))
+
(defcustom ivy-magic-tilde t
"When non-nil, ~ will move home when selecting files.
Otherwise, ~/ will move home."