Created
November 26, 2016 22:04
-
-
Save olejorgenb/ae562bb0aee796a9c41eae3587f181ac to your computer and use it in GitHub Desktop.
Highlight symbol at point on mouse click (emacs)
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
;; Only tested with spacemacs | |
(defvar my-current-focus-symbol nil) | |
(make-variable-buffer-local 'my-current-focus-symbol) | |
(defvar my-focus-symbol-face 'hi-yellow) | |
(defun mouse-set-point-and-hl-symbol (event) | |
(interactive "e") | |
(mouse-set-point event) | |
;; Evil workaround crap (without this every other click visual state is activated...) | |
;; (not 100% sure why this works, but see the binding of [down-mouse-1] and | |
;; the white-listing of mouse-set-point in that code) | |
(deactivate-mark) | |
(let ((symbol (thing-at-point 'symbol))) | |
(when my-current-focus-symbol | |
(hlt-unhighlight-symbol my-current-focus-symbol nil)) | |
(when symbol | |
(hlt-highlight-symbol symbol nil my-focus-symbol-face)) | |
(setq my-current-focus-symbol symbol) | |
) | |
) | |
(global-set-key [mouse-1] 'mouse-set-point-and-hl-symbol) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment