[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 21007c2 17/63: Add counsel-rhythmbox
From: |
Oleh Krehel |
Subject: |
[elpa] master 21007c2 17/63: Add counsel-rhythmbox |
Date: |
Fri, 21 Aug 2015 12:08:34 +0000 |
branch: master
commit 21007c2395105a14301c2f999549b533e2137e22
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add counsel-rhythmbox
* counsel.el (counsel-completion-beg):
(counsel-completion-end): Move declarations before first use.
(dired-jump): Declare.
(counsel-rhythmbox-enqueue-song): New defun.
(counsel-rhythmbox): New command. Requires `helm-rhythmbox' package, and
Rhythmbox, obviously.
* ivy.el (ivy-call): Make interactive. Add special handling for the case
when the collection is an alist. In that case, call the action not
with the collection item, but with the cdr of said item. A bit weird,
but that's the way Helm does it, and doing it in the same way means
the action functions are cross-compatible.
* ivy-hydra.el (hydra-ivy): Bind "g" to call the current action on
current candidate without exiting.
Now it's possible to make a query to Rhythmbox, "C-o" and navigate to a
song with "j" and "k". Try the song with "g". Or use "s" once and then
enqueue different songs with e.g. "jjgjjjgjgkkg".
---
counsel.el | 43 +++++++++++++++++++++++++++++++++++++------
ivy-hydra.el | 3 ++-
ivy.el | 13 +++++++++----
3 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/counsel.el b/counsel.el
index 5f48f30..0c589e1 100644
--- a/counsel.el
+++ b/counsel.el
@@ -34,6 +34,12 @@
(require 'swiper)
+(defvar counsel-completion-beg nil
+ "Completion bounds start.")
+
+(defvar counsel-completion-end nil
+ "Completion bounds end.")
+
;;;###autoload
(defun counsel-el ()
"Elisp completion at point."
@@ -75,12 +81,6 @@
:initial-input str
:action #'counsel--el-action)))
-(defvar counsel-completion-beg nil
- "Completion bounds start.")
-
-(defvar counsel-completion-end nil
- "Completion bounds end.")
-
(defun counsel--el-action (symbol)
"Insert SYMBOL, erasing the previous one."
(when (stringp symbol)
@@ -439,6 +439,7 @@ Skip some dotfiles unless `ivy-text' requires them."
shell-command-switch
(format "xdg-open %s" (shell-quote-argument x))))
+(declare-function dired-jump "dired-x")
(defun counsel-locate-action-dired (x)
"Use `dired-jump' on X."
(dired-jump nil x))
@@ -684,6 +685,36 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
(custom-available-themes))
:action #'counsel--load-theme-action))
+(defvar rhythmbox-library)
+(declare-function rhythmbox-load-library "ext:helm-rhythmbox")
+(declare-function dbus-call-method "dbus")
+(declare-function rhythmbox-song-uri "ext:helm-rhythmbox")
+(declare-function helm-rhythmbox-candidates "ext:helm-rhythmbox")
+
+(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" (rhythmbox-song-uri song))))
+
+;;;###autoload
+(defun counsel-rhythmbox ()
+ "Choose a song from the Rhythmbox library to play or enqueue."
+ (interactive)
+ (unless (require 'helm-rhythmbox nil t)
+ (error "Please install `helm-rhythmbox'"))
+ (unless rhythmbox-library
+ (rhythmbox-load-library)
+ (while (null rhythmbox-library)
+ (sit-for 0.1)))
+ (ivy-read "Rhythmbox: "
+ (helm-rhythmbox-candidates)
+ :action
+ '(1
+ ("Play song" helm-rhythmbox-play-song)
+ ("Enqueue song" counsel-rhythmbox-enqueue-song))))
(provide 'counsel)
diff --git a/ivy-hydra.el b/ivy-hydra.el
index 030978f..cdaff1f 100644
--- a/ivy-hydra.el
+++ b/ivy-hydra.el
@@ -51,7 +51,7 @@
^^^^^^^^^^^^^^---------------------------------------------------
^ ^ _k_ ^ ^ _f_ollow _i_nsert _c_: calling %s(if ivy-calling \"on\"
\"off\") _w_/_s_: %s(ivy-action-name)
_h_ ^+^ _l_ _d_one _o_ops _m_: matcher %s(if (eq ivy--regex-function
'ivy--regex-fuzzy) \"fuzzy\" \"ivy\")
-^ ^ _j_ ^ ^ ^ ^ ^ ^ _<_/_>_: shrink/grow window
+^ ^ _j_ ^ ^ _g_o ^ ^ _<_/_>_: shrink/grow window
"
;; arrows
("h" ivy-beginning-of-buffer)
@@ -66,6 +66,7 @@ _h_ ^+^ _l_ _d_one _o_ops _m_: matcher %s(if (eq
ivy--regex-function 'i
("f" ivy-alt-done :exit nil)
("C-j" ivy-alt-done :exit nil)
("d" ivy-done :exit t)
+ ("g" ivy-call)
("C-m" ivy-done :exit t)
("c" ivy-toggle-calling)
("m" ivy-toggle-fuzzy)
diff --git a/ivy.el b/ivy.el
index a768c18..876204f 100644
--- a/ivy.el
+++ b/ivy.el
@@ -539,10 +539,16 @@ If the input is empty, select the previous history
element instead."
(defun ivy-call ()
"Call the current action without exiting completion."
+ (interactive)
(let ((action (ivy--get-action ivy-last)))
(when action
- (with-selected-window (ivy-state-window ivy-last)
- (funcall action ivy--current)))))
+ (let* ((collection (ivy-state-collection ivy-last))
+ (x (if (and (consp collection)
+ (consp (car collection)))
+ (cdr (assoc ivy--current collection))
+ ivy--current)))
+ (with-selected-window (ivy-state-window ivy-last)
+ (funcall action x))))))
(defun ivy-next-line-and-call (&optional arg)
"Move cursor vertically down ARG candidates.
@@ -841,8 +847,7 @@ candidates with each input."
(remove-hook 'post-command-hook #'ivy--exhibit)
(when (setq unwind (ivy-state-unwind ivy-last))
(funcall unwind)))
- (when (setq action (ivy--get-action ivy-last))
- (funcall action ivy--current))))
+ (ivy-call)))
(defun ivy--reset-state (state)
"Reset the ivy to STATE.
- [elpa] master fe6d2b1 07/63: Make ffap work again, (continued)
- [elpa] master fe6d2b1 07/63: Make ffap work again, Oleh Krehel, 2015/08/21
- [elpa] master f6f3963 09/63: Bind case-fold-search to t when the input is all lower-case, Oleh Krehel, 2015/08/21
- [elpa] master d5af987 11/63: ivy.el (ivy--reset-state): Fixup, Oleh Krehel, 2015/08/21
- [elpa] master d1f88fa 10/63: ivy.el (ivy-read): Don't put empty string on history, Oleh Krehel, 2015/08/21
- [elpa] master f9974e8 12/63: Allow to see the candidate index via ivy-count-format, Oleh Krehel, 2015/08/21
- [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 <=
- [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, 2015/08/21
- [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