diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-25 11:07:56 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-25 11:13:27 +0200 |
commit | 4cf832492eac6924c739e929c59d27441e238180 (patch) | |
tree | aa25a4d4235de22de3100417213d794d3823885c /helm-regexp.el | |
parent | b43d99e3d4fb202cec904b0d030c1103b2041be2 (diff) |
Implement mouse usage in helm-moccur-mode (#1746).
* helm-regexp.el (helm-moccur-save-results): Do it.
(helm-moccur-mode-mouse-goto-line): Do it.
Diffstat (limited to 'helm-regexp.el')
-rw-r--r-- | helm-regexp.el | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/helm-regexp.el b/helm-regexp.el index 1cf91691..1456cbb2 100644 --- a/helm-regexp.el +++ b/helm-regexp.el @@ -487,18 +487,44 @@ Same as `helm-moccur-goto-line' but go in new frame." (setq buf new-buf)) (with-current-buffer (get-buffer-create buf) (setq buffer-read-only t) - (let ((inhibit-read-only t)) + (let ((inhibit-read-only t) + (map (make-sparse-keymap))) (erase-buffer) (insert "-*- mode: helm-moccur -*-\n\n" (format "Moccur Results for `%s':\n\n" helm-input)) (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 + (buffer-file-name + (get-buffer (get-text-property + (point) 'buffer-name))) + "\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-moccur-mode-mouse-goto-line) + (define-key map [mouse-3] 'ignore) + (forward-line 1)))) (helm-moccur-mode)) (pop-to-buffer buf) (message "Helm Moccur Results saved in `%s' buffer" buf))) +(defun helm-moccur-mode-mouse-goto-line (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-moccur-mode) + (goto-char pos) + (helm-moccur-mode-goto-line))))) +(put 'helm-moccur-mode-mouse-goto-line 'helm-only t) + ;;;###autoload (define-derived-mode helm-moccur-mode special-mode "helm-moccur" |