bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19422: 25.0.50; `remove-overlays` needs one additional `point` at en


From: Keith David Bershatsky
Subject: bug#19422: 25.0.50; `remove-overlays` needs one additional `point` at end of narrowed region.
Date: Sun, 21 Dec 2014 09:42:36 -0800

In my particular use case, I am narrowing to a region and then inserting an 
`after-string` overlay at `point-max`:

(overlay-put (make-overlay (point-max) (point-max)) 'after-string "|")

I have a minor mode that draws a vertical line that tracks the cursor position 
and I extend that to window-end or point-max.  The end of the buffer has a 
different color and a different character overlay depending upon where `point` 
is --- a leading cushion is used if the vertical column extends beyond the 
point at the end of the line.

And here is the slightly revised function that I am using to remove it.  It 
differs a little bit from the version in my initial bug report number 19422:

    (defun lawlist-remove-overlays (beg end name val)
      "Remove the overlays."
      ;; DEBUGGING
      ;; (unless (and beg end name val)
      ;;   (message "ERROR -- beg:  %s | end:  %s | name:  %s | val:  %s" beg 
end name val))
      (let* (
          (point-max (point-max))
          (point-min (point-min))
          (narrowed-p (not (equal (- point-max point-min) (buffer-size))))
          (beg (if beg beg point-min))
          (end
            (cond
              ((and
                  (not narrowed-p)
                  end)
                end)
              ((and
                  (not narrowed-p)
                  (null end))
                point-max)
              ((and
                  narrowed-p
                  end
                  (< end point-max))
                end)
              ((and
                  narrowed-p
                  end
                  (= end point-max))
                (1+ end))
              ((and
                  narrowed-p
                  (null end))
                (1+ point-max)) )))
        (when (and beg end name val)
          (overlay-recenter end)
          (dolist (o (overlays-in beg end))
            (when (eq (overlay-get o name) val)
              (delete-overlay o))))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

At Sun, 21 Dec 2014 18:45:06 +0200,
Eli Zaretskii wrote:
> 
> > Date: Sun, 21 Dec 2014 00:39:44 -0800
> > From: Keith David Bershatsky <esq@lawlist.com>
> > 
> > The function `remove-overlays`, when used without any arguments, needs one 
> > additional `point` at the end of a narrowed region to effectively remove an 
> > overlay at the very end of said region.
> 
> Maybe I'm confused, but what do you mean by "overlay at the very end
> of region"?  Overlay that starts at END is not part of the region,
> AFAIU.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]