Skip to content

Commit 424e373

Browse files
authored
Merge pull request #16 from fice-t/master
Move overlay face to a different overlay
2 parents 2d216ba + 29fd924 commit 424e373

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

macrostep.el

+17-10
Original file line numberDiff line numberDiff line change
@@ -602,14 +602,18 @@ behaviors."
602602
(macrostep-collapse-overlays-in (point) end)
603603
(delete-region (point) end)
604604
;; Create a new overlay
605-
(let ((overlay
606-
(make-overlay start
607-
(if (looking-at "\n")
608-
(1+ (point))
609-
(point)))))
605+
(let* ((overlay
606+
(make-overlay start
607+
(if (looking-at "\n")
608+
(1+ (point))
609+
(point))))
610+
(highlight-overlay (unless macrostep-expansion-buffer
611+
(copy-overlay overlay))))
610612
(unless macrostep-expansion-buffer
611613
;; Highlight the overlay in original source buffers only
612-
(overlay-put overlay 'face 'macrostep-expansion-highlight-face))
614+
(overlay-put highlight-overlay 'face 'macrostep-expansion-highlight-face)
615+
(overlay-put highlight-overlay 'priority -1)
616+
(overlay-put overlay 'macrostep-highlight-overlay highlight-overlay))
613617
(overlay-put overlay 'priority priority)
614618
(overlay-put overlay 'macrostep-original-text text)
615619
(overlay-put overlay 'macrostep-gensym-depth macrostep-gensym-depth)
@@ -708,17 +712,20 @@ Also removes the overlay from `macrostep-overlays'."
708712
;; Remove overlay from the list and delete it
709713
(setq macrostep-overlays
710714
(delq overlay macrostep-overlays))
715+
(let ((highlight-overlay (overlay-get overlay 'macrostep-highlight-overlay)))
716+
(when highlight-overlay (delete-overlay highlight-overlay)))
711717
(delete-overlay overlay)))
712718

713719
(defun macrostep-collapse-overlays-in (start end)
714720
"Collapse all macrostepper overlays that are strictly between START and END.
715721
716722
Will not collapse overlays that begin at START and end at END."
717723
(dolist (ol (overlays-in start end))
718-
(if (and (> (overlay-start ol) start)
719-
(< (overlay-end ol) end)
720-
(overlay-get ol 'macrostep-original-text))
721-
(macrostep-collapse-overlay ol t))))
724+
(when (and (overlay-buffer ol) ; collapsing may delete other overlays
725+
(> (overlay-start ol) start)
726+
(< (overlay-end ol) end)
727+
(overlay-get ol 'macrostep-original-text))
728+
(macrostep-collapse-overlay ol t))))
722729

723730

724731
;;; Emacs Lisp implementation

0 commit comments

Comments
 (0)