summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2016-10-10 09:32:22 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2016-10-10 09:32:22 +0200
commitae61f02d3e6a8b8f3e14e7a9d076b1c73feebe62 (patch)
treedd9987064fd39053fe812ef7f13599940d3a83f6
parentb85079ac8620f64ce7df11c7a00ccc245b9e6c01 (diff)
parenta1fe6c28d06284ac025b4a0843c0d298dce41e84 (diff)
Merge branch 'action_window'
-rw-r--r--helm-sys.el5
-rw-r--r--helm.el77
2 files changed, 53 insertions, 29 deletions
diff --git a/helm-sys.el b/helm-sys.el
index 3230a0ca..0d721ec1 100644
--- a/helm-sys.el
+++ b/helm-sys.el
@@ -113,7 +113,7 @@ This affect also sorting functions in the same way."
(cancel-timer helm-top--poll-timer))
(condition-case nil
(progn
- (when (and (helm-alive-p) (null no-update))
+ (when (and (helm-alive-p) (not (helm-action-window)) (null no-update))
;; Fix quitting while process is running
;; by binding `with-local-quit' in init function
;; Issue #1521.
@@ -421,7 +421,8 @@ Show actions only on line starting by a PID."
(helm :sources 'helm-source-top
:buffer "*helm top*" :full-frame t
:candidate-number-limit 9999
- :preselect "^\\s-*[0-9]+")
+ :preselect "^\\s-*[0-9]+"
+ :truncate-lines helm-show-action-window-same-window)
(remove-hook 'helm-after-update-hook 'helm-top--skip-top-line))))
;;;###autoload
diff --git a/helm.el b/helm.el
index 94dea5c9..db5401c0 100644
--- a/helm.el
+++ b/helm.el
@@ -605,6 +605,12 @@ See `helm-log-save-maybe' for more info."
:type 'string
:group 'helm)
+(defcustom helm-show-action-window-same-window nil
+ "Show action buffer beside `helm-buffer' when non-nil.
+Note that this may not fit well with some helm window configurations,
+so it have only effect when `helm-always-two-windows' is non-nil."
+ :group 'helm
+ :type 'boolean)
;;; Faces
;;
@@ -3555,36 +3561,52 @@ If action buffer is selected, back to the helm buffer."
(setq helm-saved-selection (helm-get-selection nil nil src))
(with-selected-frame (with-helm-window (selected-frame))
(prog1
- (cond ((get-buffer-window helm-action-buffer 'visible)
- (set-window-buffer (get-buffer-window helm-action-buffer)
- helm-buffer)
- (kill-buffer helm-action-buffer)
- (setq helm-saved-selection nil)
- (helm-set-pattern helm-input 'noupdate))
- (helm-saved-selection
- (setq helm-saved-current-source src)
- (let ((actions (helm-get-actions-from-current-source src)))
- (if (functionp actions)
- (message "Sole action: %s"
- (if (or (consp actions)
- (byte-code-function-p actions))
- "Anonymous" actions))
- (helm-show-action-buffer actions)
- ;; Be sure the minibuffer is entirely deleted (#907).
- (helm--delete-minibuffer-contents-from "")
- ;; Make `helm-pattern' differs from the previous value.
- (setq helm-pattern 'dummy)
- (helm-check-minibuffer-input))))
- (t (message "No Actions available")))
+ (helm-acond ((get-buffer-window helm-action-buffer 'visible)
+ (set-window-buffer (get-buffer-window helm-action-buffer)
+ helm-buffer)
+ (helm--action-prompt 'restore)
+ (when (and helm-show-action-window-same-window
+ helm-always-two-windows)
+ (delete-window it))
+ (kill-buffer helm-action-buffer)
+ (setq helm-saved-selection nil)
+ (helm-set-pattern helm-input 'noupdate))
+ (helm-saved-selection
+ (setq helm-saved-current-source src)
+ (let ((actions (helm-get-actions-from-current-source src))
+ helm-onewindow-p)
+ (if (functionp actions)
+ (message "Sole action: %s"
+ (if (or (consp actions)
+ (byte-code-function-p actions))
+ "Anonymous" actions))
+ (helm-show-action-buffer actions)
+ ;; Be sure the minibuffer is entirely deleted (#907).
+ (helm--delete-minibuffer-contents-from "")
+ (helm--action-prompt)
+ (helm-check-minibuffer-input))))
+ (t (message "No Actions available")))
(helm-display-mode-line (helm-get-current-source))
(run-hooks 'helm-window-configuration-hook))))))
(put 'helm-select-action 'helm-only t)
+(defun helm--action-prompt (&optional restore)
+ (with-selected-window (minibuffer-window)
+ (let ((inhibit-read-only t))
+ (if restore
+ (remove-text-properties (point-min) (point-max) '(display))
+ (add-text-properties (point-min) (point-max)
+ '(display "Select action: "))))))
+
(defun helm-show-action-buffer (actions)
(with-current-buffer (get-buffer-create helm-action-buffer)
(erase-buffer)
(buffer-disable-undo)
- (set-window-buffer (get-buffer-window helm-buffer) helm-action-buffer)
+ (set-window-buffer (if (and helm-show-action-window-same-window
+ helm-always-two-windows)
+ (split-window (get-buffer-window helm-buffer) nil 'right)
+ (get-buffer-window helm-buffer))
+ helm-action-buffer)
(set (make-local-variable 'helm-sources)
(list
(helm-build-sync-source "Actions"
@@ -3684,8 +3706,9 @@ mode and header lines."
(propertize (format " [prefarg:%s]" arg)
'face 'helm-prefarg)))))
" "
- (:eval (helm-show-candidate-number
- (car-safe helm-mode-line-string)))
+ (:eval (with-helm-buffer
+ (helm-show-candidate-number
+ (car-safe helm-mode-line-string))))
" " helm--mode-line-string-real " "
(:eval (make-string (window-width) ? )))
keymap (keymap (mode-line keymap
@@ -3709,9 +3732,9 @@ mode and header lines."
(helm--set-header-line))
(helm-display-header-line
(let ((hlstr (helm-interpret-value
- (and (listp source)
- (assoc-default 'header-line source))
- source))
+ (and (listp source)
+ (assoc-default 'header-line source))
+ source))
(endstr (make-string (window-width) ? )))
(setq header-line-format
(propertize (concat " " hlstr endstr)