Last active
September 10, 2018 16:29
-
-
Save leisti/b46eca0606da1f36e50d28d77e0fc634 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;;;; Make the mark always visible ('mmv' means 'make mark visible'). | |
;;;; Based on code written by Patrick Gundlach. Fixed with help from Stefan. | |
(defface mmv-face | |
'((t :background "red")) | |
"Face used for showing the mark's position.") | |
(defvar-local mmv-mark-overlay nil "Overlay for showing the mark's position.") | |
(defun mmv-show-mark (&rest _) | |
"Make the mark's position stand out by means of a one-character-long overlay." | |
(unless mmv-mark-overlay | |
(setq mmv-mark-overlay (make-overlay 0 0 nil t)) | |
(overlay-put mmv-mark-overlay 'face 'mmv-face)) | |
(let ((mark-position (mark t))) | |
(cond | |
((null mark-position) (delete-overlay mmv-mark-overlay)) | |
((and (< mark-position (point-max)) | |
(not (eq ?\n (char-after mark-position)))) | |
(overlay-put mmv-mark-overlay 'after-string nil) | |
(move-overlay mmv-mark-overlay | |
mark-position (1+ mark-position))) | |
(t | |
(overlay-put mmv-mark-overlay 'after-string | |
(propertize " " 'face (overlay-get mmv-mark-overlay 'face))) | |
(move-overlay mmv-mark-overlay | |
mark-position mark-position))))) | |
(add-hook 'pre-redisplay-functions #'mmv-show-mark) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment