[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2f1133a 083/167: ivy.el (ivy-occur): Add and bind to "C-c
From: |
Oleh Krehel |
Subject: |
[elpa] master 2f1133a 083/167: ivy.el (ivy-occur): Add and bind to "C-c o" |
Date: |
Tue, 08 Dec 2015 10:50:07 +0000 |
branch: master
commit 2f1133a158bad191d169f0b05b08ba2546b9ab7d
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-occur): Add and bind to "C-c o"
* ivy.el (ivy-minibuffer-map): Update.
(ivy-occur-action):
(ivy-occur-last):
(ivy-occur-map): New defvar.
(ivy-occur): New command.
(ivy-occur-click): New command bound to mouse click.
(ivy-occur-press): New command bound to "RET" press.
`ivy-occur' allows to store the current completion session for further
use. An unlimited amount of these sessions can be used, each in its own
buffer.
---
ivy.el | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/ivy.el b/ivy.el
index 10c019d..aacdcf4 100644
--- a/ivy.el
+++ b/ivy.el
@@ -170,6 +170,7 @@ Only \"./\" and \"../\" apply here. They appear in reverse
order."
(define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
(define-key map (kbd "M-w") 'ivy-kill-ring-save)
(define-key map (kbd "C-'") 'ivy-avy)
+ (define-key map (kbd "C-c o") 'ivy-occur)
map)
"Keymap used in the minibuffer.")
(autoload 'hydra-ivy/body "ivy-hydra" "" t)
@@ -2063,6 +2064,74 @@ If the region is active, forward to `kill-ring-save'
instead."
ivy--old-cands
"\n"))))
+(defvar-local ivy-occur-action nil
+ "Function to call for each line in *ivy-occur* buffer.")
+
+(defvar-local ivy-occur-last nil
+ "Buffer-local value of `ivy-last'.")
+
+(defvar ivy-occur-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [mouse-1] 'ivy-occur-click)
+ (define-key map (kbd "RET") 'ivy-occur-press)
+ map)
+ "Keymap used in *ivy-occur* buffers.")
+
+(defun ivy-occur ()
+ "Stop completion and put the current matches into a new buffer.
+
+The new buffer will also remember the current action.
+
+While in the *ivy-occur* buffer, selecting a cadidate with RET or
+a mouse click will call the action for that candidate.
+
+It's possible to have an unlimited amount of *ivy-occur* buffers."
+ (interactive)
+ (ivy-quit-and-run
+ (let (caller)
+ (pop-to-buffer
+ (generate-new-buffer
+ (format "*ivy-occur%s*"
+ (if (setq caller (ivy-state-caller ivy-last))
+ (concat " " (prin1-to-string caller))
+ ""))))
+ (read-only-mode)
+ (setq ivy-occur-action (ivy--get-action ivy-last))
+ (setq-local ivy--directory ivy--directory)
+ (setq ivy-occur-last ivy-last)
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (insert (format "%d candidates:\n" (length ivy--old-cands)))
+ (dolist (cand ivy--old-cands)
+ (let ((str (concat " " cand)))
+ (add-text-properties
+ 0 (length str)
+ `(mouse-face
+ highlight
+ help-echo "mouse-1: call ivy-action"
+ keymap ,ivy-occur-map)
+ str)
+ (insert str "\n")))))))
+
+(defun ivy-occur-click (event)
+ "Execute action for the current candidate.
+EVENT gives the mouse position."
+ (interactive "e")
+ (let ((window (posn-window (event-end event)))
+ (pos (posn-point (event-end event))))
+ (with-current-buffer (window-buffer window)
+ (goto-char pos)
+ (ivy-occur-press))))
+
+(defun ivy-occur-press ()
+ "Execute action for the current candidate."
+ (interactive)
+ (let ((ivy-last ivy-occur-last))
+ (funcall ivy-occur-action
+ (buffer-substring
+ (+ 4 (line-beginning-position))
+ (line-end-position)))))
+
(defun ivy-insert-current ()
"Make the current candidate into current input.
Don't finish completion."
- [elpa] master 3ae4f1a 052/167: ivy-test.el (swiper--re-builder): Update, (continued)
- [elpa] master 3ae4f1a 052/167: ivy-test.el (swiper--re-builder): Update, Oleh Krehel, 2015/12/08
- [elpa] master 713fd6d 049/167: Try to fix the previous commit, Oleh Krehel, 2015/12/08
- [elpa] master 297f48a 074/167: ivy.el: "M-n" should prefer url at point to symbol at point, Oleh Krehel, 2015/12/08
- [elpa] master 0e6c13b 076/167: swiper.el (swiper-font-lock-ensure): Exclude eems-stream-mode, Oleh Krehel, 2015/12/08
- [elpa] master f5b8bf2 079/167: Highlight modified file buffers with 'ivy-modified-buffer face, Oleh Krehel, 2015/12/08
- [elpa] master 70f6055 077/167: counsel.el (counsel-git-grep-query-replace): Add and bind to "M-q", Oleh Krehel, 2015/12/08
- [elpa] master 86d0884 087/167: fix 1-too-far scrolling issue, Oleh Krehel, 2015/12/08
- [elpa] master 16ccb0f 084/167: swiper.el (swiper-font-lock-ensure): Exclude debbugs-gnu-mode, Oleh Krehel, 2015/12/08
- [elpa] master d41cc69 086/167: Pulse after ivy-occur-press, Oleh Krehel, 2015/12/08
- [elpa] master c6cc3f9 089/167: counsel.el (counsel-rhythmbox): Add :caller, Oleh Krehel, 2015/12/08
- [elpa] master 2f1133a 083/167: ivy.el (ivy-occur): Add and bind to "C-c o",
Oleh Krehel <=
- [elpa] master 2797a9b 090/167: ivy.el (ivy-minibuffer-map): Bind "C-M-a" to ivy-read-action, Oleh Krehel, 2015/12/08
- [elpa] master 564e235 091/167: ivy.el (ivy-occur-press): Extend with-ivy-window, Oleh Krehel, 2015/12/08
- [elpa] master e9ba89e 085/167: Make ivy work with enable-recursive-minibuffers, Oleh Krehel, 2015/12/08
- [elpa] master 7a069be 088/167: ivy.el (ivy-occur-press): Work with counsel-rhythmbox, Oleh Krehel, 2015/12/08
- [elpa] master 32025e5 098/167: Add a better ivy-occur pulse to swiper and counsel-git-grep, Oleh Krehel, 2015/12/08
- [elpa] master b948987 095/167: Input "/sudo::" goes to current directory instead of root's home, Oleh Krehel, 2015/12/08
- [elpa] master 7317848 092/167: counsel.el (counsel-M-x): Add "definition" action, Oleh Krehel, 2015/12/08
- [elpa] master adf7fd3 097/167: swiper.el (swiper--add-overlays): Take extra WND arg, Oleh Krehel, 2015/12/08
- [elpa] master b91870e 094/167: Fix /ssh: and /sudo:: broken in 71695df, Oleh Krehel, 2015/12/08
- [elpa] master 6afce97 096/167: counsel.el (counsel-git-grep-query-replace): Should exit minibuffer, Oleh Krehel, 2015/12/08