Created
November 17, 2014 10:03
-
-
Save Mzyxptlk/66cf8b39b6bc1bcd7476 to your computer and use it in GitHub Desktop.
Fix for active region's interaction with overlays
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
; Fix bug that causes the active region overlay to get the lowest | |
; possible priority. | |
(eval-after-load 'simple | |
'(setq redisplay-highlight-region-function | |
(lambda (start end window rol) | |
(if (not (overlayp rol)) | |
(let ((nrol (make-overlay start end))) | |
(funcall redisplay-unhighlight-region-function rol) | |
(overlay-put nrol 'window window) | |
(overlay-put nrol 'face 'region) | |
;; Normal priority so that a large region doesn't hide all the | |
;; overlays within it, but high secondary priority so that if it | |
;; ends/starts in the middle of a small overlay, that small | |
;; overlay won't hide the region's boundaries. | |
(overlay-put nrol 'priority 100) | |
nrol) | |
(unless (and (eq (overlay-buffer rol) (current-buffer)) | |
(eq (overlay-start rol) start) | |
(eq (overlay-end rol) end)) | |
(move-overlay rol start end (current-buffer))) | |
;; mz: Possibly dirty hack to ensure highlight on active region takes its | |
;; rightful place in the overlay priority hierarchy. | |
(overlay-put rol 'priority 100) | |
rol)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment