branch: master
commit c009b28337f408fe571b24be7bdb304bbc596a76
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el: Breaking change for alist type collection actions
* ivy.el (ivy-call): The action will be called with collection's ITEM,
instead of (cdr ITEM) like before.
* ivy-test.el (ivy-read): Update test. It's easy to see the breaking
change by looking at this test update.
* counsel.el (counsel-descbinds-action-describe):
(counsel-descbinds-action-find):
(counsel-descbinds-action-info):
(counsel-imenu):
(counsel-rhythmbox-play-song):
(counsel-rhythmbox-enqueue-song):
(counsel-linux-app-action-default):
(counsel-linux-app-action-file): Update.
---
counsel.el | 20 +++++++++++---------
ivy-test.el | 2 +-
ivy.el | 18 +++++++++++-------
3 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/counsel.el b/counsel.el
index 3a05c8b..9bfaa08 100644
--- a/counsel.el
+++ b/counsel.el
@@ -801,15 +801,15 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
(nreverse res)))
(defun counsel-descbinds-action-describe (x)
- (let ((cmd (cdr x)))
+ (let ((cmd (cddr x)))
(describe-function cmd)))
(defun counsel-descbinds-action-find (x)
- (let ((cmd (cdr x)))
+ (let ((cmd (cddr x)))
(counsel--find-symbol (symbol-name cmd))))
(defun counsel-descbinds-action-info (x)
- (let ((cmd (cdr x)))
+ (let ((cmd (cddr x)))
(counsel-info-lookup-symbol (symbol-name cmd))))
;;;###autoload
@@ -1976,7 +1976,7 @@ PREFIX is used to create the key."
(with-ivy-window
;; In org-mode, (imenu candidate) will expand child
node
;; after jump to the candidate position
- (imenu candidate)))
+ (imenu (cdr candidate))))
:caller 'counsel-imenu)))
;;** `counsel-list-processes'
@@ -2105,21 +2105,21 @@ And insert it into the minibuffer. Useful during
(declare-function dbus-call-method "dbus")
(declare-function dbus-get-property "dbus")
-(defun counsel-rhythmbox-play-song (uri)
- "Let Rhythmbox enqueue SONG."
+(defun counsel-rhythmbox-play-song (song)
+ "Let Rhythmbox play SONG."
(let ((service "org.gnome.Rhythmbox3")
(path "/org/mpris/MediaPlayer2")
(interface "org.mpris.MediaPlayer2.Player"))
(dbus-call-method :session service path interface
- "OpenUri" uri)))
+ "OpenUri" (cdr song))))
-(defun counsel-rhythmbox-enqueue-song (uri)
+(defun counsel-rhythmbox-enqueue-song (song)
"Let Rhythmbox enqueue SONG."
(let ((service "org.gnome.Rhythmbox3")
(path "/org/gnome/Rhythmbox3/PlayQueue")
(interface "org.gnome.Rhythmbox3.PlayQueue"))
(dbus-call-method :session service path interface
- "AddToQueue" uri)))
+ "AddToQueue" (cdr song))))
(defvar counsel-rhythmbox-history nil
"History for `counsel-rhythmbox'.")
@@ -2217,11 +2217,13 @@ And insert it into the minibuffer. Useful during
(defun counsel-linux-app-action-default (desktop-shortcut)
"Launch DESKTOP-SHORTCUT."
+ (setq desktop-shortcut (cdr desktop-shortcut))
(call-process-shell-command
(format "gtk-launch %s" (file-name-nondirectory desktop-shortcut))))
(defun counsel-linux-app-action-file (desktop-shortcut)
"Launch DESKTOP-SHORTCUT with a selected file."
+ (setq desktop-shortcut (cdr desktop-shortcut))
(let* ((entry (rassoc desktop-shortcut counsel-linux-apps-alist))
(short-name (and entry
(string-match "\\([^ ]*\\) " (car entry))
diff --git a/ivy-test.el b/ivy-test.el
index a0ccb9c..9cc9313 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -88,7 +88,7 @@
(ivy-read "test" '(("foo" . "bar"))
:action (lambda (x) (prin1 x))))
"f C-m")
- "\"bar\""))
+ "(\"foo\" . \"bar\")"))
(should (equal
(ivy-with
'(with-output-to-string
diff --git a/ivy.el b/ivy.el
index 97bca32..550a97b 100644
--- a/ivy.el
+++ b/ivy.el
@@ -938,13 +938,17 @@ Example use:
(let ((action (ivy--get-action ivy-last)))
(when action
(let* ((collection (ivy-state-collection ivy-last))
- (x (cond ((and (consp collection)
- (consp (car collection))
- (cdr (assoc ivy--current collection))))
- ((equal ivy--current "")
- ivy-text)
- (t
- ivy--current))))
+ (x (cond
+ ;; Alist type.
+ ((and (consp collection)
+ (consp (car collection))
+ ;; Previously, the cdr of the selected candidate
would be returned.
+ ;; Now, the whole candidate is returned.
+ (assoc ivy--current collection)))
+ ((equal ivy--current "")
+ ivy-text)
+ (t
+ ivy--current))))
(prog1 (funcall action x)
(unless (or (eq ivy-exit 'done)
(equal (selected-window)