GNU bug report logs - #69259
30.0.50; (get-pos-property 9483 'cursor-intangible) gives args-out-of-range error in folded magit buffer

Previous Next

Package: emacs;

Reported by: StrawberryTea <look <at> strawberrytea.xyz>

Date: Sun, 18 Feb 2024 21:19:02 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: StrawberryTea <look <at> strawberrytea.xyz>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Jonas Bernoulli <jonas <at> bernoul.li>, 69259 <at> debbugs.gnu.org
Subject: bug#69259: 30.0.50; (get-pos-property 9483 'cursor-intangible) gives args-out-of-range error in folded magit buffer
Date: Wed, 21 Feb 2024 17:29:54 -0600
[Message part 1 (text/plain, inline)]
Thanks for the explanation Stefan and Eli. I ended up making a PR to magit. And
I think Tarsius is going to merge it. He just asked me to test it after he made
a small change.

Sincerely,
StrawberryTea

modified   lisp/magit-section.el
@@ -1635,10 +1635,14 @@ evaluated its BODY.  Admittedly that’s a bit of a hack.“
   (setq magit-section-pre-command-section (magit-current-section)))

(defun magit-section-post-command-hook ()
• (cursor-sensor-move-to-tangible (selected-window))
• (when (or magit–context-menu-buffer
• magit–context-menu-section)
• (magit-menu-highlight-point-section))
⁃ (let ((window (selected-window)))
⁃ ;; The command may have used `set-window-buffer’ to change
⁃ ;; the window’s buffer without changing the current buffer.
⁃ (when (eq (current-buffer) (window-buffer window))
⁃ (cursor-sensor-move-to-tangible window)
⁃ (when (or magit–context-menu-buffer
⁃ magit–context-menu-section)
⁃ (magit-menu-highlight-point-section))))
  (unless (memq this-command ’(magit-refresh magit-refresh-all))
    (magit-section-update-highlight)))
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> Eli wrote:
>> I think cursor-sensor is written under the assumption that the
>> selected window’s buffer is also the current buffer, and if so,
>> magit-post-command-hook should abide by that protocol.  Stefan, am I
>> right?
>
> Not `cursor-sensor.el` in its entirety, but
> `cursor-sensor-move-to-tangible` presumes that it is called with the
> current-buffer already set to (window-buffer window).
>
> StrawberryTea wrote:
>> Why exactly are the window-buffer and the current-buffer different?
>
> Good question.  AFAIK the code that runs `post-command-hook` normally
> tries to avoid such situations.
>
>> I think this has to do with persp-mode.  My guess is that when it sets
>> the new window configuration, the current-buffer is not updated to the
>> new window’s buffer immediately.
>
> Could be a “bad citizen” on `post-command-hook`, indeed, which messes up
> subsequent functions on the hook.  Maybe the code that runs
> `post-command-hook` should be more careful to (re)set current-buffer
> after each function, but it seems easier to fix the rare functions which
> mess it up.
>
>         Stefan

This bug report was last modified 1 year and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.