@@ -602,14 +602,18 @@ behaviors."
602
602
(macrostep-collapse-overlays-in (point ) end)
603
603
(delete-region (point ) end)
604
604
; ; 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))))
610
612
(unless macrostep-expansion-buffer
611
613
; ; 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))
613
617
(overlay-put overlay 'priority priority)
614
618
(overlay-put overlay 'macrostep-original-text text)
615
619
(overlay-put overlay 'macrostep-gensym-depth macrostep-gensym-depth)
@@ -708,17 +712,20 @@ Also removes the overlay from `macrostep-overlays'."
708
712
; ; Remove overlay from the list and delete it
709
713
(setq macrostep-overlays
710
714
(delq overlay macrostep-overlays))
715
+ (let ((highlight-overlay (overlay-get overlay 'macrostep-highlight-overlay )))
716
+ (when highlight-overlay (delete-overlay highlight-overlay)))
711
717
(delete-overlay overlay)))
712
718
713
719
(defun macrostep-collapse-overlays-in (start end )
714
720
" Collapse all macrostepper overlays that are strictly between START and END.
715
721
716
722
Will not collapse overlays that begin at START and end at END."
717
723
(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 ))))
722
729
723
730
724
731
; ;; Emacs Lisp implementation
0 commit comments