4f4968067363ebcdb15178d1be0d2e79c8658342 — John Foerch 13 years ago 2fb1930
visible-mark-move-overlays: rewrite

still not perfect.  has problems with reverting buffer, and with faces
being shown in margin text.
1 files changed, 32 insertions(+), 9 deletions(-)

M visible-mark.el
M visible-mark.el => visible-mark.el +32 -9
@@ 71,11 71,24 @@
  (let (overlays)
    (dotimes (i visible-mark-max)
      (let ((overlay (make-overlay (point-min) (point-min))))
        (overlay-put overlay 'category 'visible-mark)
        (push overlay overlays)))
    (setq visible-mark-overlays (nreverse overlays))))

(defun visible-mark-find-overlay-at (pos)
  (let ((overlays (overlays-at pos))
    (while (and overlays (not found))
      (let ((overlay (car overlays)))
        (if (eq 'visible-mark (overlay-get overlay 'category))
            (setq found overlay)))
      (setq overlays (cdr overlays)))

(defun visible-mark-move-overlays ()
  "Move the overlay in `visible-mark-overlay' to a new position."
  (mapc (lambda (x) (move-overlay x 0 0))
  (let ((marks (cons (mark-marker) mark-ring))
        (overlays visible-mark-overlays))
    (dotimes (i visible-mark-max)

@@ 83,16 96,26 @@
             (overlay (car overlays))
             (pos (and mark (marker-position mark))))
        (when pos
          (overlay-put overlay 'face
                       (if (and visible-mark-inhibit-trailing-overlay
                                  (goto-char pos)
                           (nth i visible-mark-non-trailing-faces)
                         (or (nth i visible-mark-faces) 'visible-mark-face)))
          (move-overlay overlay pos (1+ pos)))
            ((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
                               " "
                               'face (or (nth i visible-mark-faces) 'visible-mark-face)
                               'cursor 0))
                 (move-overlay overlay pos (1+ pos))))
             (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)))))
      (setq overlays (cdr overlays)))))

(require 'easy-mmode)