Subject: bug#77747: closed (Re: bug#77747: 'cursor-face-highlight-mode' signals 'args-out-of-range' in narrowed buffer)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 26 Apr 2025 14:22:03 +0000

Your bug report

#77747: 'cursor-face-highlight-mode' signals 'args-out-of-range' in narrowed buffer

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
77747: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77747
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#77747: 'cursor-face-highlight-mode' signals 'args-out-of-range' in narrowed buffer
From: Eli Zaretskii <[email-masked]>
To: Ship Mints <[email-masked]>
Cc: [email-masked]
Date: Sat, 26 Apr 2025 17:21:26 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Ship Mints <[email-masked]>
> Date: Fri, 25 Apr 2025 15:24:02 -0400
> Cc: [email-masked]
> 
> On Fri, Apr 25, 2025 at 2:37 PM Eli Zaretskii <[email-masked]> wrote:
> 
>  > From: Ship Mints <[email-masked]>
>  > Date: Fri, 25 Apr 2025 12:21:40 -0400
>  > Cc: [email-masked]
>  > 
>  > On Fri, Apr 25, 2025 at 10:58 AM Ship Mints <[email-masked]> wrote:
>  > 
>  >  On Fri, Apr 25, 2025 at 9:51 AM Ship Mints <[email-masked]> wrote:
>  > 
>  >  On Sun, Apr 13, 2025 at 5:52 AM Eli Zaretskii <[email-masked]> wrote:
>  > 
>  >  > From: Ship Mints <[email-masked]>
>  >  > Date: Fri, 11 Apr 2025 11:32:18 -0400
>  >  > 
>  >  > -Q reproducer
>  >  > 
>  >  > ;; The culprit appears to be `redisplay--update-cursor-face-highlight'
>  >  > (setq debug-on-error t)
>  >  > (cursor-face-highlight-mode)
>  >  > (save-excursion (insert (propertize "cursor face text\n"
>  >  >                                     'cursor-face 'region)))
>  >  > (narrow-to-region (pos-bol) (pos-eol))
>  >  > (setq unread-command-events (mapcar #'identity
>  >  >                                     (kbd "C-n")))
>  > 
>  >  Thanks, does the below fix it?
>  > 
>  >  diff --git a/lisp/simple.el b/lisp/simple.el
>  >  index ee09a6f..9e9dd15 100644
>  >  --- a/lisp/simple.el
>  >  +++ b/lisp/simple.el
>  >  @@ -7265,7 +7265,7 @@ redisplay--update-cursor-face-highlight
>  >                 (pt (window-point window))
>  >                 (cursor-face (get-text-property pt 'cursor-face)))
>  >           (let* ((start (previous-single-property-change
>  >  -                       (1+ pt) 'cursor-face nil (point-min)))
>  >  +                       (min (1+ pt) (point-min)) 'cursor-face nil (point-min)))
>  >                  (end (next-single-property-change
>  >                        pt 'cursor-face nil (point-max)))
>  >                  (new (redisplay--highlight-overlay-function
>  > 
>  >  Eli, possible to apply the above soon?
>  > 
>  >  Actually, I'm back to thinking this is better or the effect is that the whole buffer can wind up being
>  >  unexpectedly highlighted:
>  > 
>  >                         (min (1+ pt) (pos-bol)) 'cursor-face nil (point-min)))
>  > 
>  > To be clearer:
>  > 
>  > The original condition (1+ pt) 'cursor-face nil (point-min))) works fine in a wide buffer.
>  > 
>  > The condition (min (1+ pt) (point-min)) 'cursor-face nil (point-min))) in a wide buffer winds up
>  highlighting all
>  > the way to point-min in a buffer where every line has 'cursor-face which is undesirable.
> 
>  It should obviously be point-max, not point-min.
> 
> Yeah.  Of course.  Feel free to apply AFAIC.

Done.

Subject: 'cursor-face-highlight-mode' signals 'args-out-of-range' in narrowed buffer
From: Ship Mints <[email-masked]>
To: [email-masked]
Date: Fri, 11 Apr 2025 11:32:18 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

-Q reproducer

;; The culprit appears to be `redisplay--update-cursor-face-highlight'
(setq debug-on-error t)
(cursor-face-highlight-mode)
(save-excursion (insert (propertize "cursor face text\n"
                                    'cursor-face 'region)))
(narrow-to-region (pos-bol) (pos-eol))
(setq unread-command-events (mapcar #'identity
                                    (kbd "C-n")))

-Stephane