Created
March 15, 2020 20:14
-
-
Save codecoll/c861390a518556211388f87914db5023 to your computer and use it in GitHub Desktop.
Emacs - Always highlight matching parent (use echo area if out of screen)
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 my-show-paren-for-line-start () | |
(interactive) | |
(add-hook 'post-command-hook 'my-show-paren-for-line-setup-overlay t t)) | |
(defun my-show-paren-for-line-stop () | |
(interactive) | |
(remove-hook 'post-command-hook 'my-show-paren-for-line-setup-overlay t)) | |
(setq my-show-paren-for-line-overlay (make-overlay (point) (point))) | |
(overlay-put my-show-paren-for-line-overlay | |
'face '(background-color . "cyan")) | |
(delete-overlay my-show-paren-for-line-overlay) ;; hide it | |
(defun my-show-paren-for-line-setup-overlay () | |
(if (and (looking-at ".*))\\s-*$") | |
(not (eq (char-before) ?\)))) | |
(save-excursion | |
(ignore-errors | |
(end-of-line) | |
(backward-sexp) | |
(if (< (point) (window-start)) | |
(message "Matches %s" (buffer-substring (line-beginning-position) (line-end-position))) | |
(move-overlay my-show-paren-for-line-overlay (point) (1+ (point))) | |
(add-hook 'pre-command-hook 'my-show-paren-for-line-hide-overlay t t)))))) | |
(defun my-show-paren-for-line-hide-overlay () | |
(delete-overlay my-show-paren-for-line-overlay) | |
(remove-hook 'pre-command-hook 'my-show-paren-for-line-hide-overlay t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment