Skip to content

Instantly share code, notes, and snippets.

@xuchunyang
Last active August 29, 2015 14:21
Show Gist options
  • Save xuchunyang/36372b4f834d9c3e4a50 to your computer and use it in GitHub Desktop.
Save xuchunyang/36372b4f834d9c3e4a50 to your computer and use it in GitHub Desktop.
用鼠标执行 Helm 选项
(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