Skip to content

Commit

Permalink
Execute default action on nth candidate before and after selection (#…
Browse files Browse the repository at this point in the history
…1257).

* helm.el (helm-map): Bind keys from 1 to 9.
(helm-execute-selection-action-at-nth): The function to jump to nth cand
and execute action.
  • Loading branch information
Thierry Volpiatto committed Nov 17, 2015
1 parent 3e84cab commit f97ea41
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helm.el
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ so don't use strings, vectors or whatever to define them."
`(lambda ()
(interactive)
(helm-select-nth-action ,n))))
;; Bind keys to allow executing default action
;; on first 9 candidates before and after selection.
(cl-loop for n from 1 to 9
for key = (format "C-c %d" n)
for key- = (format "C-x %d" n)
for fn = `(lambda ()
(interactive)
(helm-execute-selection-action-at-nth ,n))
for fn- = `(lambda ()
(interactive)
(helm-execute-selection-action-at-nth ,(- n)))
do (progn
(define-key map (kbd key) fn)
(define-key map (kbd key-) fn-)))
map)
"Keymap for helm.")

Expand Down Expand Up @@ -4932,6 +4946,15 @@ Possible values are 'left 'right 'below or 'above."
(t
(error "Error in `helm-select-nth-action'"))))

(defun helm-execute-selection-action-at-nth (linum)
"Allow to execute default action on candidate at LINUM."
(let ((prefarg current-prefix-arg))
(if (>= linum 0)
(helm-next-line linum)
(helm-previous-line (lognot (1- linum))))
(setq current-prefix-arg prefarg)
(helm-exit-minibuffer)))

;; Utility: Persistent Action
(defmacro with-helm-display-same-window (&rest body)
"Execute BODY in the window used for persistent action.
Expand Down

0 comments on commit f97ea41

Please sign in to comment.