- (let* ((mark (car-safe marks))
- (overlay (car overlays))
- (pos (and mark (marker-position mark))))
- (when pos
- (cond
- ((and visible-mark-inhibit-trailing-overlay
- (save-excursion (goto-char pos) (eolp)))
- (overlay-put overlay 'face nil)
- (if (visible-mark-find-overlay-at pos)
- (progn (overlay-put overlay 'before-string nil)
- (move-overlay overlay 0 0))
- (overlay-put overlay 'before-string
- (propertize
- " "
- 'face (or (nth i visible-mark-faces) 'visible-mark-face)
- 'cursor 0))
- (move-overlay overlay pos (1+ pos))))
- (t
- (overlay-put overlay 'before-string nil)
- (overlay-put overlay 'face
- (or (nth i visible-mark-faces) 'visible-mark-face))
- (move-overlay overlay pos (1+ pos)))))
- (setq marks (cdr marks)))
- (setq overlays (cdr overlays)))))
+ (visible-mark-move-overlay (pop overlays) (pop marks) (car faces))
+ (if (cdr faces) (pop faces)))
+ (dotimes (i visible-mark-forward-max)
+ (visible-mark-move-overlay (pop overlays) (car (last marks (1+ i))) (car faces-forward))
+ (if (cdr faces-forward) (pop faces-forward)))))
+
+(defun visible-mark-move-overlay (overlay mark face)
+ "Set OVERLAY to position of MARK and display of FACE."
+ (let ((pos (and mark (marker-position mark))))
+ (when (and pos (not (equal (point) pos)))
+ (cond
+ ((and
+ visible-mark-inhibit-trailing-overlay
+ (save-excursion (goto-char pos) (eolp)))
+ (overlay-put overlay 'face nil)
+ (if (visible-mark-find-overlay-at pos)
+ (progn (overlay-put overlay 'before-string nil))
+ (overlay-put overlay 'before-string
+ (propertize
+ " "
+ 'face face))
+ (move-overlay overlay pos (1+ pos))))
+ (t
+ (overlay-put overlay 'before-string nil)
+ (overlay-put overlay 'face face)
+ (move-overlay overlay pos (1+ pos)))))))