[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d289b78 15/63: Add a new interface to customize additional
From: |
Oleh Krehel |
Subject: |
[elpa] master d289b78 15/63: Add a new interface to customize additional exit points |
Date: |
Fri, 21 Aug 2015 12:08:33 +0000 |
branch: master
commit d289b78a9301f24b12a803358cdc251375d142cc
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add a new interface to customize additional exit points
* ivy.el (ivy--actions-list): New defvar. Store the exit points per
command.
(ivy-set-actions): New defun. Use this to set the extra exit points for
each command.
(ivy-read): Account for `ivy--actions-list'.
(ivy-switch-buffer): Set extra action to kill the buffer. Update the
call to `ivy-read'.
* counsel.el (counsel-locate): Use the single action in the function and
customize the rest via `ivy-set-actions'.
Re #164
---
counsel.el | 15 ++++++++-------
ivy.el | 36 ++++++++++++++++++++++++++----------
2 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/counsel.el b/counsel.el
index cf33413..5f48f30 100644
--- a/counsel.el
+++ b/counsel.el
@@ -446,6 +446,11 @@ Skip some dotfiles unless `ivy-text' requires them."
(defvar counsel-locate-history nil
"History for `counsel-locate'.")
+(ivy-set-actions
+ 'counsel-locate
+ '(("xdg-open" counsel-locate-action-extern)
+ ("dired" counsel-locate-action-dired)))
+
;;;###autoload
(defun counsel-locate ()
"Call locate shell command."
@@ -454,13 +459,9 @@ Skip some dotfiles unless `ivy-text' requires them."
:dynamic-collection #'counsel-locate-function
:history 'counsel-locate-history
:action
- (cons
- 1
- '(("default" (lambda (val)
- (when val
- (find-file val))))
- ("xdg-open" counsel-locate-action-extern)
- ("dired" counsel-locate-action-dired)))))
+ (lambda (val)
+ (when val
+ (find-file val)))))
(defun counsel--generic (completion-fn)
"Complete thing at point with COMPLETION-FN."
diff --git a/ivy.el b/ivy.el
index 27f76d1..dc6c412 100644
--- a/ivy.el
+++ b/ivy.el
@@ -90,6 +90,14 @@ Only \"./\" and \"../\" apply here. They appear in reverse
order."
"When non-nil, add `recentf-mode' and bookmarks to the list of buffers."
:type 'boolean)
+(defvar ivy--actions-list nil
+ "A list of extra actions per command.")
+
+(defun ivy-set-actions (cmd actions)
+ "Set CMD extra exit points to ACTIONS."
+ (setq ivy--actions-list
+ (plist-put ivy--actions-list cmd actions)))
+
;;* Keymap
(require 'delsel)
(defvar ivy-minibuffer-map
@@ -783,6 +791,12 @@ MATCHER can completely override matching.
DYNAMIC-COLLECTION is a function to call to update the list of
candidates with each input."
+ (let ((extra-actions (plist-get ivy--actions-list this-command)))
+ (when extra-actions
+ (setq action
+ `(1
+ ("default" ,action)
+ ,@extra-actions))))
(setq ivy-last
(make-ivy-state
:prompt prompt
@@ -1487,21 +1501,23 @@ BUFFER may be a string or nil."
(defvar ivy-switch-buffer-map (make-sparse-keymap))
+(ivy-set-actions
+ 'ivy-switch-buffer
+ '(("kill"
+ (lambda (x)
+ (kill-buffer x)
+ (ivy--reset-state ivy-last)))))
+
(defun ivy-switch-buffer ()
"Switch to another buffer."
(interactive)
(if (not ivy-mode)
(call-interactively 'switch-to-buffer)
- (ivy-read "Switch to buffer: " 'internal-complete-buffer
- :preselect (buffer-name (other-buffer (current-buffer)))
- :action (cons
- 1
- '(("default" ivy--switch-buffer-action)
- ("kill"
- (lambda (x)
- (kill-buffer x)
- (ivy--reset-state ivy-last)))))
- :keymap ivy-switch-buffer-map)))
+ (let ((this-command 'ivy-switch-buffer))
+ (ivy-read "Switch to buffer: " 'internal-complete-buffer
+ :preselect (buffer-name (other-buffer (current-buffer)))
+ :action #'ivy--switch-buffer-action
+ :keymap ivy-switch-buffer-map))))
(defun ivy-recentf ()
"Find a file on `recentf-list'."
- [elpa] master 783f7c5 13/63: Update index formatting logic, (continued)
- [elpa] master 783f7c5 13/63: Update index formatting logic, Oleh Krehel, 2015/08/21
- [elpa] master 3164753 14/63: counsel.el (counsel-locate-history): Add, Oleh Krehel, 2015/08/21
- [elpa] master 19dcc0f 16/63: ivy.el (ivy--regex): Improve for trailing backslash, Oleh Krehel, 2015/08/21
- [elpa] master ea6525e 18/63: ivy.el (ivy-read): Improve ivy-set-actions interaction, Oleh Krehel, 2015/08/21
- [elpa] master e9c2538 19/63: counsel.el (counsel-rhythmbox-history): Add, Oleh Krehel, 2015/08/21
- [elpa] master 21007c2 17/63: Add counsel-rhythmbox, Oleh Krehel, 2015/08/21
- [elpa] master de2e819 20/63: Allow % in prompt string, Oleh Krehel, 2015/08/21
- [elpa] master 22ee8a6 23/63: swiper.el (swiper-font-lock-ensure): Ignore Man-mode, Oleh Krehel, 2015/08/21
- [elpa] master 8c91662 22/63: ivy.el (ivy-call): Bind to "C-M-m" or "M-RET", Oleh Krehel, 2015/08/21
- [elpa] master 3df2d8e 26/63: ivy-hydra.el: Add featurep for hydra, Oleh Krehel, 2015/08/21
- [elpa] master d289b78 15/63: Add a new interface to customize additional exit points,
Oleh Krehel <=
- [elpa] master 1092e2d 24/63: swiper.el: Update avy--goto -> avy-action-goto, Oleh Krehel, 2015/08/21
- [elpa] master adad288 27/63: ivy.el (ivy-call): Add selected-window work-around for M-x, Oleh Krehel, 2015/08/21
- [elpa] master 9ca6f48 30/63: Allow "C-g" to interrupt ivy-dispatching-done, Oleh Krehel, 2015/08/21
- [elpa] master 5480079 28/63: ivy.el (ivy-dispatching-done): New command on "M-o", Oleh Krehel, 2015/08/21
- [elpa] master 6062903 21/63: ivy.el (ivy-count-format): Improve docstring, Oleh Krehel, 2015/08/21
- [elpa] master e91a4eb 31/63: ivy.el (ivy-dispatching-done): Display the candidate, Oleh Krehel, 2015/08/21
- [elpa] master 3464362 33/63: Add actions for counsel-describe-variable, Oleh Krehel, 2015/08/21
- [elpa] master 31d664a 32/63: ivy.el (ivy-dispatching-done): Add a trailing newline, Oleh Krehel, 2015/08/21
- [elpa] master 107ebff 34/63: Add actions for counsel-describe-function, Oleh Krehel, 2015/08/21
- [elpa] master 2fbcfb9 29/63: ivy.el (ivy--preselect-index): Add matcher to arglist, Oleh Krehel, 2015/08/21