diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-25 10:52:22 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-25 11:09:42 +0200 |
commit | b43d99e3d4fb202cec904b0d030c1103b2041be2 (patch) | |
tree | c3d10cc50b4d075bc86ea2509882134e80bf8768 /helm-grep.el | |
parent | bd7be89ce02133551a95373da776b4200ef30565 (diff) |
Implement mouse usage in helm-grep-mode (#1746).
* helm-grep.el (helm-grep-save-results-1): Install mouse bindings.
(helm-grep-mode-mouse-jump): Special event to jump to candidate.
Diffstat (limited to 'helm-grep.el')
-rw-r--r-- | helm-grep.el | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/helm-grep.el b/helm-grep.el index 1c0dd39b..a123acbd 100644 --- a/helm-grep.el +++ b/helm-grep.el @@ -745,18 +745,41 @@ If N is positive go forward otherwise go backward." (helm-default-directory) default-directory)) (setq buffer-read-only t) - (let ((inhibit-read-only t)) + (let ((inhibit-read-only t) + (map (make-sparse-keymap))) (erase-buffer) (insert "-*- mode: helm-grep -*-\n\n" (format "%s Results for `%s':\n\n" src-name pattern)) (save-excursion (insert (with-current-buffer helm-buffer (goto-char (point-min)) (forward-line 1) - (buffer-substring (point) (point-max)))))) + (buffer-substring (point) (point-max))))) + (save-excursion + (while (not (eobp)) + (add-text-properties (point-at-bol) (point-at-eol) + `(keymap ,map + help-echo ,(concat + (get-text-property + (point) 'helm-grep-fname) + "\nmouse-1: set point\nmouse-2: jump to selection") + mouse-face highlight)) + (define-key map [mouse-1] 'mouse-set-point) + (define-key map [mouse-2] 'helm-grep-mode-mouse-jump) + (define-key map [mouse-3] 'ignore) + (forward-line 1)))) (helm-grep-mode)) (pop-to-buffer buf) (message "Helm %s Results saved in `%s' buffer" src-name buf))) +(defun helm-grep-mode-mouse-jump (event) + (interactive "e") + (let* ((window (posn-window (event-end event))) + (pos (posn-point (event-end event)))) + (with-selected-window window + (when (eq major-mode 'helm-grep-mode) + (goto-char pos) + (helm-grep-mode-jump))))) + (define-derived-mode helm-grep-mode special-mode "helm-grep" "Major mode to provide actions in helm grep saved buffer. |