(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."
: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)
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))
(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)
^^^^^^^^^^^^^^---------------------------------------------------
^ ^ _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)
("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)
(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.
(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.