[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1c45b29 150/272: ivy-occur-mode: new commands on "j", "k",
From: |
Oleh Krehel |
Subject: |
[elpa] master 1c45b29 150/272: ivy-occur-mode: new commands on "j", "k", "c" |
Date: |
Mon, 25 Apr 2016 10:13:22 +0000 |
branch: master
commit 1c45b2940432fa0ee08ec3acfc151e556939308a
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy-occur-mode: new commands on "j", "k", "c"
* ivy.el (ivy-calling): Make variable buffer-local.
(ivy-occur-toggle-calling): New command bound to "c".
(ivy-occur-next-line): New command bound to "j".
(ivy-occur-previous-line): New command bound to "k".
This makes `ivy-occur' much more convenient, instead of "gjgjgjg", just
"cjjj". Especially good for commands that change the contents of the
other window, like `describe-function' or `counsel-git-grep'.
Example:
- "C-h f" (`describe-funtion')
- "run" (`self-insert-command')
- "C-c C-o" (`ivy-occur'); "C-o u" also works.
- "cjjjjkkkk"
---
ivy.el | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/ivy.el b/ivy.el
index a09f657..8a72546 100644
--- a/ivy.el
+++ b/ivy.el
@@ -686,7 +686,7 @@ If the text hasn't changed as a result, forward to
`ivy-alt-done'."
:dynamic-collection (ivy-state-dynamic-collection ivy-last)
:caller (ivy-state-caller ivy-last))))
-(defvar ivy-calling nil
+(defvar-local ivy-calling nil
"When non-nil, call the current action when `ivy--index' changes.")
(defun ivy-set-index (index)
@@ -2677,17 +2677,44 @@ buffer would modify `ivy-last'.")
(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] 'ivy-occur-click)
(define-key map (kbd "RET") 'ivy-occur-press)
- (define-key map (kbd "j") 'next-line)
- (define-key map (kbd "k") 'previous-line)
+ (define-key map (kbd "j") 'ivy-occur-next-line)
+ (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 "g") 'ivy-occur-press)
(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)
(define-key map (kbd "q") 'quit-window)
map)
"Keymap for Ivy Occur mode.")
+(defun ivy-occur-toggle-calling ()
+ "Toggle `ivy-calling'."
+ (interactive)
+ (if (setq ivy-calling (not ivy-calling))
+ (progn
+ (setq mode-name "Ivy-Occur [calling]")
+ (ivy-occur-press))
+ (setq mode-name "Ivy-Occur"))
+ (force-mode-line-update))
+
+(defun ivy-occur-next-line (&optional arg)
+ "Move the cursor down ARG lines.
+When `ivy-calling' isn't nil, call `ivy-occur-press'."
+ (interactive "p")
+ (forward-line arg)
+ (when ivy-calling
+ (ivy-occur-press)))
+
+(defun ivy-occur-previous-line (&optional arg)
+ "Move the cursor up ARG lines.
+When `ivy-calling' isn't nil, call `ivy-occur-press'."
+ (interactive "p")
+ (forward-line (- arg))
+ (when ivy-calling
+ (ivy-occur-press)))
+
(define-derived-mode ivy-occur-mode fundamental-mode "Ivy-Occur"
"Major mode for output from \\[ivy-occur].
- [elpa] master 41b8b0d 113/272: ivy.el (ivy-occur): Add a warning, (continued)
- [elpa] master 41b8b0d 113/272: ivy.el (ivy-occur): Add a warning, Oleh Krehel, 2016/04/25
- [elpa] master b39e449 228/272: counsel.el (counsel-ag-map): Add, Oleh Krehel, 2016/04/25
- [elpa] master 79f9cda 165/272: counsel-ag: Fix escaping problem, Oleh Krehel, 2016/04/25
- [elpa] master f1c7233 164/272: swiper.el (swiper-occur): Bind ivy--regex-function, Oleh Krehel, 2016/04/25
- [elpa] master 1de78f3 160/272: Improve window handling for ivy-occur, Oleh Krehel, 2016/04/25
- [elpa] master c90784d 087/272: doc/ivy.org: Update, Oleh Krehel, 2016/04/25
- [elpa] master d085765 146/272: ivy.el (ivy-switch-buffer): Don't fall back to switch-to-buffer, Oleh Krehel, 2016/04/25
- [elpa] master be06ae0 163/272: swiper.el: Add docstring, Oleh Krehel, 2016/04/25
- [elpa] master 587526e 138/272: counsel.el (counsel-git-grep-transformer): New defun, Oleh Krehel, 2016/04/25
- [elpa] master d40bdab 134/272: doc/ivy.org: Fix typo, Oleh Krehel, 2016/04/25
- [elpa] master 1c45b29 150/272: ivy-occur-mode: new commands on "j", "k", "c",
Oleh Krehel <=
- [elpa] master c68d2cc 189/272: ivy.el (ivy-thing-at-point): Try ffap-file-at-point, Oleh Krehel, 2016/04/25
- [elpa] master d6b18f0 151/272: ivy.el (ivy-occur-press): Pulse no longer, Oleh Krehel, 2016/04/25
- [elpa] master b3ca886 133/272: counsel.el (counsel--generic): Improve, Oleh Krehel, 2016/04/25
- [elpa] master c8013c7 053/272: counsel.el (ivy-ffap-url-functions): Add Emacs git repo, Oleh Krehel, 2016/04/25
- [elpa] master 1d3f080 263/272: ivy.el (ivy--magic-file-slash): Allow "non-existing-dir//", Oleh Krehel, 2016/04/25
- [elpa] master 37d52cc 120/272: swiper.el (swiper--update-input-ivy): Replace "\t", Oleh Krehel, 2016/04/25
- [elpa] master 07624b3 180/272: Fix compilation warnings, Oleh Krehel, 2016/04/25
- [elpa] master f3b2640 124/272: swiper.el (swiper--ivy): Update signature, Oleh Krehel, 2016/04/25
- [elpa] master 25e1444 257/272: ivy.el (ivy-use-ignore-default): New defcustom, Oleh Krehel, 2016/04/25
- [elpa] master c9b6e02 230/272: Make sure user keybindings are respected, Oleh Krehel, 2016/04/25