diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-22 12:40:02 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-22 12:40:02 +0200 |
commit | f5b5172d9d16a463739b6154f694981a9bc237cd (patch) | |
tree | 4afca310c393a3e94f1070b2e62c913c15e2718a /helm.el | |
parent | dde10dd03c07280e38593156141220d919ccf440 (diff) |
Bind mouse and set help-echo when marking selection (#1746).
* helm.el (helm-bind-mouse-for-selection): New.
(helm-mouse-select-candidate): Use it.
(helm-move-selection-common): Reset help-echo from here too.
(helm-mark-current-line): Bind mouse-2 and set overlay from here.
Diffstat (limited to 'helm.el')
-rw-r--r-- | helm.el | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -3700,11 +3700,21 @@ respectively `helm-cand-num' and `helm-cur-source'." 'help-echo (replace-match "mouse-1: select candidate" t t help-echo))))) +(defun helm-bind-mouse-for-selection (pos) + (let ((map (get-text-property pos 'keymap))) + (define-key map [mouse-2] 'helm-maybe-exit-minibuffer) + (put-text-property + helm-selection-point + (overlay-end helm-selection-overlay) + 'help-echo (helm-aif (get-text-property pos 'help-echo) + (if (string-match "mouse-1: select candidate" it) + (replace-match "mouse-2: execute action" t t it) + "mouse-2: execute action\nmouse-3: menu actions"))))) + (defun helm-mouse-select-candidate (event) (interactive "e") (let* ((window (posn-window (event-end event))) - (pos (posn-point (event-end event))) - (map (get-text-property pos 'keymap))) + (pos (posn-point (event-end event)))) (unwind-protect (with-current-buffer (window-buffer window) (helm-mouse-reset-selection-help-echo) @@ -3713,17 +3723,9 @@ respectively `helm-cand-num' and `helm-cur-source'." (goto-char (or (helm-get-previous-candidate-separator-pos) (helm-get-previous-header-pos))) (forward-line 1)) - (helm-mark-current-line) - (define-key map [mouse-2] 'helm-maybe-exit-minibuffer) - (put-text-property - helm-selection-point - (overlay-end helm-selection-overlay) - 'help-echo (helm-aif (get-text-property pos 'help-echo) - (if (string-match "mouse-1: select candidate" it) - (replace-match "mouse-2: execute action" t t it) - "mouse-2: execute action\nmouse-3: menu actions"))) + (helm-mark-current-line)) (select-window (minibuffer-window)) - (set-buffer (window-buffer window)))))) + (set-buffer (window-buffer window))))) (put 'helm-mouse-select-candidate 'helm-only t) (defun helm-insert-header-from-source (source) @@ -4238,7 +4240,8 @@ Key arg DIRECTION can be one of: (unless (or (helm-empty-buffer-p (helm-buffer-get)) (not (helm-window))) (with-helm-window - (when helm-allow-mouse (helm-mouse-reset-selection-help-echo)) + (when helm-allow-mouse + (helm-mouse-reset-selection-help-echo)) (helm-log-run-hook 'helm-move-selection-before-hook) (funcall move-func) (and (memq direction '(next previous)) @@ -4491,7 +4494,9 @@ candidates." header-pos (point-max))) (1+ (point-at-eol)))) - (setq helm-selection-point (overlay-start helm-selection-overlay)))) + (setq helm-selection-point (overlay-start helm-selection-overlay)) + (when helm-allow-mouse + (helm-bind-mouse-for-selection helm-selection-point)))) (defun helm-confirm-and-exit-minibuffer () "Maybe ask for confirmation when exiting helm. |