Last active
August 29, 2015 14:21
-
-
Save xuchunyang/36372b4f834d9c3e4a50 to your computer and use it in GitHub Desktop.
用鼠标执行 Helm 选项
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foo (prefix event) | |
"Select helm candidate by mouse. With PREFIX, also execute its first action." | |
(interactive "P\ne") | |
(when (helm-alive-p) | |
(with-helm-buffer | |
(let* ((posn (elt event 1)) | |
(cursor (line-number-at-pos (point))) | |
(pointer (line-number-at-pos (posn-point posn)))) | |
(helm--next-or-previous-line (if (> pointer cursor) | |
'next | |
'previous) | |
(abs (- pointer cursor))))) | |
(when prefix (helm-maybe-exit-minibuffer)))) | |
(bind-key* "<down-mouse-1>" #'foo) | |
(bind-key* "<mouse-1>" #'ignore) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment