diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2012-12-11 19:52:33 +0100 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2012-12-11 19:52:33 +0100 |
commit | 0b03bf4504c64d4c0d4ed481a3f9e7534417b149 (patch) | |
tree | 4ff5b4c6f511ba6d3b0c41d91ade3db893991aa7 | |
parent | 40f27180cb06a9e7f9a9b4a4f05e248281ed7bc3 (diff) |
* helm.el (helm-execute-persistent-action): Allow using a cons cell for persistent-action attr.
* helm-elisp.el: Use it in apropos functions/sources.
* helm-help.el: document it.
-rw-r--r-- | helm-elisp.el | 8 | ||||
-rw-r--r-- | helm-help.el | 8 | ||||
-rw-r--r-- | helm.el | 53 |
3 files changed, 36 insertions, 33 deletions
diff --git a/helm-elisp.el b/helm-elisp.el index 7b2229d3..0949210c 100644 --- a/helm-elisp.el +++ b/helm-elisp.el @@ -305,7 +305,7 @@ a double quote or between." `((name . "Variables") (init . (lambda () (helm-c-apropos-init 'boundp ,default))) - (persistent-action . helm-lisp-completion-persistent-action) + (persistent-action . (helm-lisp-completion-persistent-action . never-split)) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (action . (("Describe Variable" . helm-c-describe-variable) @@ -315,7 +315,7 @@ a double quote or between." `((name . "Faces") (init . (lambda () (helm-c-apropos-init 'facep ,default))) - (persistent-action . helm-lisp-completion-persistent-action) + (persistent-action . (helm-lisp-completion-persistent-action . never-split)) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (filtered-candidate-transformer . (lambda (candidates source) @@ -339,7 +339,7 @@ a double quote or between." `((name . "Commands") (init . (lambda () (helm-c-apropos-init 'commandp ,default))) - (persistent-action . helm-lisp-completion-persistent-action) + (persistent-action . (helm-lisp-completion-persistent-action . never-split)) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (action . (("Describe Function" . helm-c-describe-function) @@ -351,7 +351,7 @@ a double quote or between." (helm-c-apropos-init #'(lambda (x) (and (fboundp x) (not (commandp x)))) ,default))) - (persistent-action . helm-lisp-completion-persistent-action) + (persistent-action . (helm-lisp-completion-persistent-action . never-split)) (persistent-help . "Show brief doc in mode-line") (candidates-in-buffer) (action . (("Describe Function" . helm-c-describe-function) diff --git a/helm-help.el b/helm-help.el index 11472698..cf1529ef 100644 --- a/helm-help.el +++ b/helm-help.el @@ -896,10 +896,10 @@ HELM-ATTRIBUTE should be a symbol." useful in case of sources with lots of candidates.") (helm-document-attribute 'persistent-action "optional" - " Function called with one parameter; the selected candidate. - - An action performed by `helm-execute-persistent-action'. - If none, use the default action.") + "Can be a either a Function called with one parameter (the selected candidate) + or a cons cell where first element is this same function and second element + a symbol (e.g never-split) that inform `helm-execute-persistent-action' + to not split his window to execute this persistent action.") (helm-document-attribute 'candidates-in-buffer "optional" " Shortcut attribute for making and narrowing candidates using @@ -3346,31 +3346,34 @@ the helm window is splitted to display and keep its visibility." (interactive) (helm-log "executing persistent-action") - (with-helm-window - (save-selected-window - (helm-select-persistent-action-window - (or split-onewindow helm-onewindow-p)) - (helm-log-eval (current-buffer)) - (let ((helm-in-persistent-action t)) - (with-helm-display-same-window - (helm-execute-selection-action-1 - nil - (or (assoc-default attr (helm-get-current-source)) - (helm-get-action)) - t) - (helm-log-run-hook 'helm-after-persistent-action-hook)) - ;; A typical case is when a persistent action delete - ;; the buffer already displayed in - ;; `helm-persistent-action-display-window' and `helm-full-frame' - ;; is enabled, we end up with the `helm-buffer' - ;; displayed in two windows. - (when (and helm-onewindow-p - (> (length (window-list)) 1) - (equal (buffer-name - (window-buffer - helm-persistent-action-display-window)) - (helm-buffer-get))) - (delete-other-windows)))))) + (let* ((attr-val (assoc-default attr (helm-get-current-source))) + ;; If attr value is a cons, use its car as persistent function + ;; and its car to decide if helm window should be splitted. + (fn (if (consp attr-val) (car attr-val) attr-val)) + (no-split (and (consp attr-val) (cdr attr-val)))) + (with-helm-window + (save-selected-window + (if no-split + (helm-select-persistent-action-window) + (helm-select-persistent-action-window + (or split-onewindow helm-onewindow-p))) + (helm-log-eval (current-buffer)) + (let ((helm-in-persistent-action t)) + (with-helm-display-same-window + (helm-execute-selection-action-1 nil (or fn (helm-get-action)) t) + (helm-log-run-hook 'helm-after-persistent-action-hook)) + ;; A typical case is when a persistent action delete + ;; the buffer already displayed in + ;; `helm-persistent-action-display-window' and `helm-full-frame' + ;; is enabled, we end up with the `helm-buffer' + ;; displayed in two windows. + (when (and helm-onewindow-p + (> (length (window-list)) 1) + (equal (buffer-name + (window-buffer + helm-persistent-action-display-window)) + (helm-buffer-get))) + (delete-other-windows))))))) (defun helm-persistent-action-display-window (&optional split-onewindow) "Return the window that will be used for persistent action. |