GNU bug report logs -
#77118
31.0.50; help-key-binding face in help buffer
Previous Next
Reported by: Arash Esbati <arash <at> gnu.org>
Date: Wed, 19 Mar 2025 13:06:02 UTC
Severity: normal
Found in version 31.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 77118 in the body.
You can then email your comments to 77118 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Wed, 19 Mar 2025 13:06:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Arash Esbati <arash <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 19 Mar 2025 13:06:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi all,
when I eval the following code:
--8<---------------cut here---------------start------------->8---
(let ((help-form (substitute-command-keys "\
Select with a key:
\\`h' do this,
\\`k' do that,
\\`RET' do nothing.")))
(read-char-choice (substitute-command-keys
(format "\
This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
(key-description (vector help-char))))
'(?h ?k ?\r)))
--8<---------------cut here---------------end--------------->8---
and do 'C-h', h, k and RET don't receive the help-key-binding face in
the help buffer which pops up. What I see with 'emacs -Q' is attached.
Note the difference in the minibuffer.
The reason seems to be in the implementation of `help-form-show' using
`princ' which strips properties. If this is intentional, it doesn't
match definitions of `help-form' in Emacs tree. Take for example
dired-aux.el which pushes the string for `help-form' also through
`substitute-command-keys'[1,2,3].
In case this report is confirmed, a possible solution is provided
here[4].
Best, Arash
Footnotes:
[1] https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/dired-aux.el#n2489
[2] https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/dired-aux.el#n3091
[3] https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/dired-aux.el#n3227
[4] https://lists.gnu.org/archive/html/help-gnu-emacs/2025-03/msg00192.html
In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.3.0, NS
appkit-2575.40 Version 15.3.2 (Build 24D81)) of 2025-03-17 built on
MacMutant.local
Repository revision: acb96a5ca8ac3bef80ca2ff1496cacb3ab57c87a
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description: macOS 15.3.2
Configured using:
'configure --with-ns --with-threads --with-modules
--with-native-compilation --without-compress-install --without-harfbuzz
--without-mailutils --without-pop 'CFLAGS=-O2 -g0 -pipe '
'CPPFLAGS=-I/opt/homebrew/Cellar/gcc/14.2.0_1/include
-I/opt/homebrew/Cellar/libgccjit/14.2.0_1/include
-I/opt/homebrew/Cellar/gmp/6.3.0/include
-I/opt/homebrew/Cellar/libxml2/2.13.6_1/include '
'LDFLAGS=-L/opt/homebrew/Cellar/gcc/14.2.0_1/lib/gcc/current
-L/opt/homebrew/Cellar/gmp/6.3.0/lib
-L/opt/homebrew/Cellar/libxml2/2.13.6_1/lib ''
[help-buffer.png (image/png, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Wed, 19 Mar 2025 14:41:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 77118 <at> debbugs.gnu.org (full text, mbox):
> From: Arash Esbati <arash <at> gnu.org>
> Date: Wed, 19 Mar 2025 14:05:21 +0100
>
> when I eval the following code:
>
> --8<---------------cut here---------------start------------->8---
> (let ((help-form (substitute-command-keys "\
> Select with a key:
> \\`h' do this,
> \\`k' do that,
> \\`RET' do nothing.")))
> (read-char-choice (substitute-command-keys
> (format "\
> This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
> (key-description (vector help-char))))
> '(?h ?k ?\r)))
> --8<---------------cut here---------------end--------------->8---
>
> and do 'C-h', h, k and RET don't receive the help-key-binding face in
> the help buffer which pops up. What I see with 'emacs -Q' is attached.
> Note the difference in the minibuffer.
>
> The reason seems to be in the implementation of `help-form-show' using
> `princ' which strips properties. If this is intentional, it doesn't
> match definitions of `help-form' in Emacs tree. Take for example
> dired-aux.el which pushes the string for `help-form' also through
> `substitute-command-keys'[1,2,3].
>
> In case this report is confirmed, a possible solution is provided
> here[4].
Stefan, any comments or reasons why we use princ there?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Wed, 19 Mar 2025 19:16:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 77118 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Arash Esbati <arash <at> gnu.org>
>> Date: Wed, 19 Mar 2025 14:05:21 +0100
>>
>> when I eval the following code:
>>
>> --8<---------------cut here---------------start------------->8---
>> (let ((help-form (substitute-command-keys "\
>> Select with a key:
>> \\`h' do this,
>> \\`k' do that,
>> \\`RET' do nothing.")))
>> (read-char-choice (substitute-command-keys
>> (format "\
>> This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
>> (key-description (vector help-char))))
>> '(?h ?k ?\r)))
>> --8<---------------cut here---------------end--------------->8---
>>
>> and do 'C-h', h, k and RET don't receive the help-key-binding face in
>> the help buffer which pops up. What I see with 'emacs -Q' is attached.
>> Note the difference in the minibuffer.
>>
>> The reason seems to be in the implementation of `help-form-show' using
>> `princ' which strips properties. If this is intentional, it doesn't
>> match definitions of `help-form' in Emacs tree. Take for example
>> dired-aux.el which pushes the string for `help-form' also through
>> `substitute-command-keys'[1,2,3].
>>
>> In case this report is confirmed, a possible solution is provided
>> here[4].
>
> Stefan, any comments or reasons why we use princ there?
There is no deep reason. We want to stay in the buffer that we invoked
help from, to get the keybindings from the right keymaps, but we also
want to insert the documentation in the *Help* buffer. Setting
`standard-output` to the *Help* buffer and using `princ` is just a
convenient way to do that.
The fix is to switch things around so we can use `insert` instead.
We have done that elsewhere in help, and should do the same in
`read-char-choice` also.
Another option is to introduce a version of `princ` that preserves
string properties.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Wed, 19 Mar 2025 21:13:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 77118 <at> debbugs.gnu.org (full text, mbox):
>> The reason seems to be in the implementation of `help-form-show' using
>> `princ' which strips properties. If this is intentional, it doesn't
>> match definitions of `help-form' in Emacs tree. Take for example
>> dired-aux.el which pushes the string for `help-form' also through
>> `substitute-command-keys'[1,2,3].
> Stefan, any comments or reasons why we use princ there?
Not sure which Stefan you were thinking of, but the other Stefan's
answer sounds right to me.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Wed, 19 Mar 2025 21:49:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 77118 <at> debbugs.gnu.org (full text, mbox):
Stefan Kangas <stefankangas <at> gmail.com> writes:
> There is no deep reason. We want to stay in the buffer that we invoked
> help from, to get the keybindings from the right keymaps, but we also
> want to insert the documentation in the *Help* buffer. Setting
> `standard-output` to the *Help* buffer and using `princ` is just a
> convenient way to do that.
>
> The fix is to switch things around so we can use `insert` instead.
> We have done that elsewhere in help, and should do the same in
> `read-char-choice` also.
>
> Another option is to introduce a version of `princ` that preserves
> string properties.
^^^^^^ text properties, of course
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Thu, 20 Mar 2025 07:59:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 77118 <at> debbugs.gnu.org (full text, mbox):
On Wed, 19 Mar 2025 12:15:40 -0700 Stefan Kangas <stefankangas <at> gmail.com> wrote:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Arash Esbati <arash <at> gnu.org>
>>> Date: Wed, 19 Mar 2025 14:05:21 +0100
>>>
>>> when I eval the following code:
>>>
>>> --8<---------------cut here---------------start------------->8---
>>> (let ((help-form (substitute-command-keys "\
>>> Select with a key:
>>> \\`h' do this,
>>> \\`k' do that,
>>> \\`RET' do nothing.")))
>>> (read-char-choice (substitute-command-keys
>>> (format "\
>>> This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
>>> (key-description (vector help-char))))
>>> '(?h ?k ?\r)))
>>> --8<---------------cut here---------------end--------------->8---
>>>
>>> and do 'C-h', h, k and RET don't receive the help-key-binding face in
>>> the help buffer which pops up. What I see with 'emacs -Q' is attached.
>>> Note the difference in the minibuffer.
>>>
>>> The reason seems to be in the implementation of `help-form-show' using
>>> `princ' which strips properties. If this is intentional, it doesn't
>>> match definitions of `help-form' in Emacs tree. Take for example
>>> dired-aux.el which pushes the string for `help-form' also through
>>> `substitute-command-keys'[1,2,3].
>>>
>>> In case this report is confirmed, a possible solution is provided
>>> here[4].
>>
>> Stefan, any comments or reasons why we use princ there?
>
> There is no deep reason. We want to stay in the buffer that we invoked
> help from, to get the keybindings from the right keymaps, but we also
> want to insert the documentation in the *Help* buffer. Setting
> `standard-output` to the *Help* buffer and using `princ` is just a
> convenient way to do that.
>
> The fix is to switch things around so we can use `insert` instead.
> We have done that elsewhere in help, and should do the same in
> `read-char-choice` also.
Is the patch I posted to help-gnu-emacs -- linked in the OP of this bug
thread and repeated below for convenience -- adequate?
Steve Berman
diff --git a/lisp/help.el b/lisp/help.el
index 835e47fec43..d77894b3372 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -2190,8 +2190,8 @@ help-form-show
"Display the output of a non-nil `help-form'."
(let ((msg (eval help-form t)))
(if (stringp msg)
- (with-output-to-temp-buffer " *Char Help*"
- (princ msg)))))
+ (with-help-window " *Char Help*"
+ (insert msg)))))
(defun help--append-keystrokes-help (str)
(let* ((keys (this-single-command-keys))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Fri, 11 Apr 2025 08:20:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 77118 <at> debbugs.gnu.org (full text, mbox):
On Thu, 20 Mar 2025 08:57:52 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:
> On Wed, 19 Mar 2025 12:15:40 -0700 Stefan Kangas <stefankangas <at> gmail.com> wrote:
>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>>> From: Arash Esbati <arash <at> gnu.org>
>>>> Date: Wed, 19 Mar 2025 14:05:21 +0100
>>>>
>>>> when I eval the following code:
>>>>
>>>> --8<---------------cut here---------------start------------->8---
>>>> (let ((help-form (substitute-command-keys "\
>>>> Select with a key:
>>>> \\`h' do this,
>>>> \\`k' do that,
>>>> \\`RET' do nothing.")))
>>>> (read-char-choice (substitute-command-keys
>>>> (format "\
>>>> This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
>>>> (key-description (vector help-char))))
>>>> '(?h ?k ?\r)))
>>>> --8<---------------cut here---------------end--------------->8---
>>>>
>>>> and do 'C-h', h, k and RET don't receive the help-key-binding face in
>>>> the help buffer which pops up. What I see with 'emacs -Q' is attached.
>>>> Note the difference in the minibuffer.
>>>>
>>>> The reason seems to be in the implementation of `help-form-show' using
>>>> `princ' which strips properties. If this is intentional, it doesn't
>>>> match definitions of `help-form' in Emacs tree. Take for example
>>>> dired-aux.el which pushes the string for `help-form' also through
>>>> `substitute-command-keys'[1,2,3].
>>>>
>>>> In case this report is confirmed, a possible solution is provided
>>>> here[4].
>>>
>>> Stefan, any comments or reasons why we use princ there?
>>
>> There is no deep reason. We want to stay in the buffer that we invoked
>> help from, to get the keybindings from the right keymaps, but we also
>> want to insert the documentation in the *Help* buffer. Setting
>> `standard-output` to the *Help* buffer and using `princ` is just a
>> convenient way to do that.
>>
>> The fix is to switch things around so we can use `insert` instead.
>> We have done that elsewhere in help, and should do the same in
>> `read-char-choice` also.
>
> Is the patch I posted to help-gnu-emacs -- linked in the OP of this bug
> thread and repeated below for convenience -- adequate?
>
> Steve Berman
>
> diff --git a/lisp/help.el b/lisp/help.el
> index 835e47fec43..d77894b3372 100644
> --- a/lisp/help.el
> +++ b/lisp/help.el
> @@ -2190,8 +2190,8 @@ help-form-show
> "Display the output of a non-nil `help-form'."
> (let ((msg (eval help-form t)))
> (if (stringp msg)
> - (with-output-to-temp-buffer " *Char Help*"
> - (princ msg)))))
> + (with-help-window " *Char Help*"
> + (insert msg)))))
>
> (defun help--append-keystrokes-help (str)
> (let* ((keys (this-single-command-keys))
This bug thread seems to have stalled; is my patch acceptable or is
someone working on the alternative suggested upthread by Stefan Kangas
(a version of princ that preserves string properties)? If my patch is
acceptable, should it be installed in emacs-30 or master?
Steve Berman
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Fri, 11 Apr 2025 08:58:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 77118 <at> debbugs.gnu.org (full text, mbox):
> From: Stephen Berman <stephen.berman <at> gmx.net>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Arash Esbati <arash <at> gnu.org>, Stefan
> Monnier <monnier <at> iro.umontreal.ca>, 77118 <at> debbugs.gnu.org
> Date: Fri, 11 Apr 2025 10:19:35 +0200
>
> On Thu, 20 Mar 2025 08:57:52 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:
>
> > On Wed, 19 Mar 2025 12:15:40 -0700 Stefan Kangas <stefankangas <at> gmail.com> wrote:
> >
> >> Eli Zaretskii <eliz <at> gnu.org> writes:
> >>
> >>>> From: Arash Esbati <arash <at> gnu.org>
> >>>> Date: Wed, 19 Mar 2025 14:05:21 +0100
> >>>>
> >>>> when I eval the following code:
> >>>>
> >>>> --8<---------------cut here---------------start------------->8---
> >>>> (let ((help-form (substitute-command-keys "\
> >>>> Select with a key:
> >>>> \\`h' do this,
> >>>> \\`k' do that,
> >>>> \\`RET' do nothing.")))
> >>>> (read-char-choice (substitute-command-keys
> >>>> (format "\
> >>>> This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
> >>>> (key-description (vector help-char))))
> >>>> '(?h ?k ?\r)))
> >>>> --8<---------------cut here---------------end--------------->8---
> >>>>
> >>>> and do 'C-h', h, k and RET don't receive the help-key-binding face in
> >>>> the help buffer which pops up. What I see with 'emacs -Q' is attached.
> >>>> Note the difference in the minibuffer.
> >>>>
> >>>> The reason seems to be in the implementation of `help-form-show' using
> >>>> `princ' which strips properties. If this is intentional, it doesn't
> >>>> match definitions of `help-form' in Emacs tree. Take for example
> >>>> dired-aux.el which pushes the string for `help-form' also through
> >>>> `substitute-command-keys'[1,2,3].
> >>>>
> >>>> In case this report is confirmed, a possible solution is provided
> >>>> here[4].
> >>>
> >>> Stefan, any comments or reasons why we use princ there?
> >>
> >> There is no deep reason. We want to stay in the buffer that we invoked
> >> help from, to get the keybindings from the right keymaps, but we also
> >> want to insert the documentation in the *Help* buffer. Setting
> >> `standard-output` to the *Help* buffer and using `princ` is just a
> >> convenient way to do that.
> >>
> >> The fix is to switch things around so we can use `insert` instead.
> >> We have done that elsewhere in help, and should do the same in
> >> `read-char-choice` also.
> >
> > Is the patch I posted to help-gnu-emacs -- linked in the OP of this bug
> > thread and repeated below for convenience -- adequate?
> >
> > Steve Berman
> >
> > diff --git a/lisp/help.el b/lisp/help.el
> > index 835e47fec43..d77894b3372 100644
> > --- a/lisp/help.el
> > +++ b/lisp/help.el
> > @@ -2190,8 +2190,8 @@ help-form-show
> > "Display the output of a non-nil `help-form'."
> > (let ((msg (eval help-form t)))
> > (if (stringp msg)
> > - (with-output-to-temp-buffer " *Char Help*"
> > - (princ msg)))))
> > + (with-help-window " *Char Help*"
> > + (insert msg)))))
> >
> > (defun help--append-keystrokes-help (str)
> > (let* ((keys (this-single-command-keys))
>
> This bug thread seems to have stalled; is my patch acceptable or is
> someone working on the alternative suggested upthread by Stefan Kangas
> (a version of princ that preserves string properties)? If my patch is
> acceptable, should it be installed in emacs-30 or master?
TBH, this patch scares me, even if we only install it on master, let
alone on the release branch. with-help-window's implementation has
nothing in common with that of with-output-to-temp-buffer, so who
knows what unintended changes in behavior this deceptively-simple
change will cause? E.g., with-help-window obeys the value of
help-window-select wrt selecting the window: do we want that here?
And that's just the tip of what I fear is a very large iceberg. All
that just to support some obscure use case?
Can't we come up with some change that has more predictable
consequences? Like some creative use of with-current-buffer around
the call to 'insert'? That'd have only local effect, which is well
understood, and thus make this change easier to agree to and install
on the release branch.
But maybe I'm exaggerating; adding Martin in the hope that he could
have comments or suggestions.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Fri, 11 Apr 2025 10:08:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 77118 <at> debbugs.gnu.org (full text, mbox):
> But maybe I'm exaggerating; adding Martin in the hope that he could
> have comments or suggestions.
Sorry. Saving and restoring the window configuration in order to show a
help form is already so scary that I would never touch that construction
with a ten-foot pole. Chong would be the right person to ask ... lisp.h
still externs internal_with_output_to_temp_buffer.
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Fri, 11 Apr 2025 10:25:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 77118 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Fri, 11 Apr 2025 11:57:39 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>, Arash Esbati <arash <at> gnu.org>, Stefan
>> Monnier <monnier <at> iro.umontreal.ca>, 77118 <at> debbugs.gnu.org
>> Date: Fri, 11 Apr 2025 10:19:35 +0200
>>
>> On Thu, 20 Mar 2025 08:57:52 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:
>>
>> > On Wed, 19 Mar 2025 12:15:40 -0700 Stefan Kangas <stefankangas <at> gmail.com> wrote:
>> >
>> >> Eli Zaretskii <eliz <at> gnu.org> writes:
>> >>
>> >>>> From: Arash Esbati <arash <at> gnu.org>
>> >>>> Date: Wed, 19 Mar 2025 14:05:21 +0100
>> >>>>
>> >>>> when I eval the following code:
>> >>>>
>> >>>> --8<---------------cut here---------------start------------->8---
>> >>>> (let ((help-form (substitute-command-keys "\
>> >>>> Select with a key:
>> >>>> \\`h' do this,
>> >>>> \\`k' do that,
>> >>>> \\`RET' do nothing.")))
>> >>>> (read-char-choice (substitute-command-keys
>> >>>> (format "\
>> >>>> This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
>> >>>> (key-description (vector help-char))))
>> >>>> '(?h ?k ?\r)))
>> >>>> --8<---------------cut here---------------end--------------->8---
>> >>>>
>> >>>> and do 'C-h', h, k and RET don't receive the help-key-binding face in
>> >>>> the help buffer which pops up. What I see with 'emacs -Q' is attached.
>> >>>> Note the difference in the minibuffer.
>> >>>>
>> >>>> The reason seems to be in the implementation of `help-form-show' using
>> >>>> `princ' which strips properties. If this is intentional, it doesn't
>> >>>> match definitions of `help-form' in Emacs tree. Take for example
>> >>>> dired-aux.el which pushes the string for `help-form' also through
>> >>>> `substitute-command-keys'[1,2,3].
>> >>>>
>> >>>> In case this report is confirmed, a possible solution is provided
>> >>>> here[4].
>> >>>
>> >>> Stefan, any comments or reasons why we use princ there?
>> >>
>> >> There is no deep reason. We want to stay in the buffer that we invoked
>> >> help from, to get the keybindings from the right keymaps, but we also
>> >> want to insert the documentation in the *Help* buffer. Setting
>> >> `standard-output` to the *Help* buffer and using `princ` is just a
>> >> convenient way to do that.
>> >>
>> >> The fix is to switch things around so we can use `insert` instead.
>> >> We have done that elsewhere in help, and should do the same in
>> >> `read-char-choice` also.
>> >
>> > Is the patch I posted to help-gnu-emacs -- linked in the OP of this bug
>> > thread and repeated below for convenience -- adequate?
>> >
>> > Steve Berman
>> >
>> > diff --git a/lisp/help.el b/lisp/help.el
>> > index 835e47fec43..d77894b3372 100644
>> > --- a/lisp/help.el
>> > +++ b/lisp/help.el
>> > @@ -2190,8 +2190,8 @@ help-form-show
>> > "Display the output of a non-nil `help-form'."
>> > (let ((msg (eval help-form t)))
>> > (if (stringp msg)
>> > - (with-output-to-temp-buffer " *Char Help*"
>> > - (princ msg)))))
>> > + (with-help-window " *Char Help*"
>> > + (insert msg)))))
>> >
>> > (defun help--append-keystrokes-help (str)
>> > (let* ((keys (this-single-command-keys))
>>
>> This bug thread seems to have stalled; is my patch acceptable or is
>> someone working on the alternative suggested upthread by Stefan Kangas
>> (a version of princ that preserves string properties)? If my patch is
>> acceptable, should it be installed in emacs-30 or master?
>
> TBH, this patch scares me, even if we only install it on master, let
> alone on the release branch. with-help-window's implementation has
> nothing in common with that of with-output-to-temp-buffer, so who
> knows what unintended changes in behavior this deceptively-simple
> change will cause? E.g., with-help-window obeys the value of
> help-window-select wrt selecting the window: do we want that here?
> And that's just the tip of what I fear is a very large iceberg. All
> that just to support some obscure use case?
>
> Can't we come up with some change that has more predictable
> consequences? Like some creative use of with-current-buffer around
> the call to 'insert'? That'd have only local effect, which is well
> understood, and thus make this change easier to agree to and install
> on the release branch.
Is the patch below creative enough?
Steve Berman
[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/help.el b/lisp/help.el
index b0c003ed16a..c7419b0d0ad 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -2190,8 +2190,11 @@ help-form-show
"Display the output of a non-nil `help-form'."
(let ((msg (eval help-form t)))
(if (stringp msg)
- (with-output-to-temp-buffer " *Char Help*"
- (princ msg)))))
+ (let ((bufname " *Char Help*"))
+ (with-output-to-temp-buffer bufname)
+ (with-current-buffer bufname
+ (let (buffer-read-only)
+ (insert msg)))))))
(defun help--append-keystrokes-help (str)
(let* ((keys (this-single-command-keys))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Fri, 11 Apr 2025 11:47:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 77118 <at> debbugs.gnu.org (full text, mbox):
> From: Stephen Berman <stephen.berman <at> gmx.net>
> Cc: martin rudalics <rudalics <at> gmx.at>, stefankangas <at> gmail.com,
> arash <at> gnu.org, monnier <at> iro.umontreal.ca, 77118 <at> debbugs.gnu.org
> Date: Fri, 11 Apr 2025 12:23:55 +0200
>
> Is the patch below creative enough?
>
> Steve Berman
>
> diff --git a/lisp/help.el b/lisp/help.el
> index b0c003ed16a..c7419b0d0ad 100644
> --- a/lisp/help.el
> +++ b/lisp/help.el
> @@ -2190,8 +2190,11 @@ help-form-show
> "Display the output of a non-nil `help-form'."
> (let ((msg (eval help-form t)))
> (if (stringp msg)
> - (with-output-to-temp-buffer " *Char Help*"
> - (princ msg)))))
> + (let ((bufname " *Char Help*"))
> + (with-output-to-temp-buffer bufname)
> + (with-current-buffer bufname
> + (let (buffer-read-only)
> + (insert msg)))))))
>
> (defun help--append-keystrokes-help (str)
> (let* ((keys (this-single-command-keys))
Yes, if this does the job, it's much simpler and safer, IMO.
But let's see if anyone else has comments.
P.S. Why do we still need with-output-to-temp-buffer, if we just doing
the 'insert' part inside the body?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Fri, 11 Apr 2025 12:52:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 77118 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Fri, 11 Apr 2025 14:46:10 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> Cc: martin rudalics <rudalics <at> gmx.at>, stefankangas <at> gmail.com,
>> arash <at> gnu.org, monnier <at> iro.umontreal.ca, 77118 <at> debbugs.gnu.org
>> Date: Fri, 11 Apr 2025 12:23:55 +0200
>>
>> Is the patch below creative enough?
>>
>> Steve Berman
>>
>> diff --git a/lisp/help.el b/lisp/help.el
>> index b0c003ed16a..c7419b0d0ad 100644
>> --- a/lisp/help.el
>> +++ b/lisp/help.el
>> @@ -2190,8 +2190,11 @@ help-form-show
>> "Display the output of a non-nil `help-form'."
>> (let ((msg (eval help-form t)))
>> (if (stringp msg)
>> - (with-output-to-temp-buffer " *Char Help*"
>> - (princ msg)))))
>> + (let ((bufname " *Char Help*"))
>> + (with-output-to-temp-buffer bufname)
>> + (with-current-buffer bufname
>> + (let (buffer-read-only)
>> + (insert msg)))))))
>>
>> (defun help--append-keystrokes-help (str)
>> (let* ((keys (this-single-command-keys))
>
> Yes, if this does the job, it's much simpler and safer, IMO.
Ok.
> But let's see if anyone else has comments.
Sure.
> P.S. Why do we still need with-output-to-temp-buffer, if we just doing
> the 'insert' part inside the body?
It's with-output-to-temp-buffer that displays the buffer and insures
that it's content is up-to-date and also that the buffer is in Help mode
(the latter is done, IIUC, in the C code via
read_char_help_form_unwind). We can avoid with-output-to-temp-buffer
here with the following patch:
[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/help.el b/lisp/help.el
index b0c003ed16a..6b591761177 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -2190,8 +2190,13 @@ help-form-show
"Display the output of a non-nil `help-form'."
(let ((msg (eval help-form t)))
(if (stringp msg)
- (with-output-to-temp-buffer " *Char Help*"
- (princ msg)))))
+ (let ((bufname " *Char Help*"))
+ (with-current-buffer (get-buffer-create bufname)
+ (let (buffer-read-only)
+ (erase-buffer)
+ (insert msg)
+ (help-mode)))
+ (display-buffer bufname)))))
(defun help--append-keystrokes-help (str)
(let* ((keys (this-single-command-keys))
[Message part 3 (text/plain, inline)]
I think this would also make some of the code in read_char that
processes the help character superfluous. Is it preferable to avoid
calling help-form-show from C?
Steve Berman
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Fri, 11 Apr 2025 14:01:03 GMT)
Full text and
rfc822 format available.
Message #41 received at 77118 <at> debbugs.gnu.org (full text, mbox):
> I think this would also make some of the code in read_char that
> processes the help character superfluous. Is it preferable to avoid
> calling help-form-show from C?
I would change as little as possible. The cascaded use of saved window
configurations is extremely fragile and will certainly fail to DTRT when
displaying " *Char Help*" in a separate frame.
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Sat, 12 Apr 2025 07:50:01 GMT)
Full text and
rfc822 format available.
Message #44 received at 77118 <at> debbugs.gnu.org (full text, mbox):
> From: Stephen Berman <stephen.berman <at> gmx.net>
> Cc: rudalics <at> gmx.at, stefankangas <at> gmail.com, arash <at> gnu.org,
> monnier <at> iro.umontreal.ca, 77118 <at> debbugs.gnu.org
> Date: Fri, 11 Apr 2025 14:50:57 +0200
>
> >> diff --git a/lisp/help.el b/lisp/help.el
> >> index b0c003ed16a..c7419b0d0ad 100644
> >> --- a/lisp/help.el
> >> +++ b/lisp/help.el
> >> @@ -2190,8 +2190,11 @@ help-form-show
> >> "Display the output of a non-nil `help-form'."
> >> (let ((msg (eval help-form t)))
> >> (if (stringp msg)
> >> - (with-output-to-temp-buffer " *Char Help*"
> >> - (princ msg)))))
> >> + (let ((bufname " *Char Help*"))
> >> + (with-output-to-temp-buffer bufname)
> >> + (with-current-buffer bufname
> >> + (let (buffer-read-only)
> >> + (insert msg)))))))
> >>
> >> (defun help--append-keystrokes-help (str)
> >> (let* ((keys (this-single-command-keys))
> >
> > Yes, if this does the job, it's much simpler and safer, IMO.
>
> Ok.
>
> > But let's see if anyone else has comments.
>
> Sure.
>
> > P.S. Why do we still need with-output-to-temp-buffer, if we just doing
> > the 'insert' part inside the body?
>
> It's with-output-to-temp-buffer that displays the buffer and insures
> that it's content is up-to-date and also that the buffer is in Help mode
> (the latter is done, IIUC, in the C code via
> read_char_help_form_unwind). We can avoid with-output-to-temp-buffer
> here with the following patch:
No, let's go with the safe patch above. I agree with Martin that this
stuff is extremely fragile and should be taken with extra care.
So I think in the above form, this is good for the emacs-30 branch.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Sat, 12 Apr 2025 10:10:01 GMT)
Full text and
rfc822 format available.
Message #47 received at 77118 <at> debbugs.gnu.org (full text, mbox):
On Sat, 12 Apr 2025 10:49:01 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> Cc: rudalics <at> gmx.at, stefankangas <at> gmail.com, arash <at> gnu.org,
>> monnier <at> iro.umontreal.ca, 77118 <at> debbugs.gnu.org
>> Date: Fri, 11 Apr 2025 14:50:57 +0200
>>
>> >> diff --git a/lisp/help.el b/lisp/help.el
>> >> index b0c003ed16a..c7419b0d0ad 100644
>> >> --- a/lisp/help.el
>> >> +++ b/lisp/help.el
>> >> @@ -2190,8 +2190,11 @@ help-form-show
>> >> "Display the output of a non-nil `help-form'."
>> >> (let ((msg (eval help-form t)))
>> >> (if (stringp msg)
>> >> - (with-output-to-temp-buffer " *Char Help*"
>> >> - (princ msg)))))
>> >> + (let ((bufname " *Char Help*"))
>> >> + (with-output-to-temp-buffer bufname)
>> >> + (with-current-buffer bufname
>> >> + (let (buffer-read-only)
>> >> + (insert msg)))))))
>> >>
>> >> (defun help--append-keystrokes-help (str)
>> >> (let* ((keys (this-single-command-keys))
>> >
>> > Yes, if this does the job, it's much simpler and safer, IMO.
>>
>> Ok.
>>
>> > But let's see if anyone else has comments.
>>
>> Sure.
>>
>> > P.S. Why do we still need with-output-to-temp-buffer, if we just doing
>> > the 'insert' part inside the body?
>>
>> It's with-output-to-temp-buffer that displays the buffer and insures
>> that it's content is up-to-date and also that the buffer is in Help mode
>> (the latter is done, IIUC, in the C code via
>> read_char_help_form_unwind). We can avoid with-output-to-temp-buffer
>> here with the following patch:
>
> No, let's go with the safe patch above. I agree with Martin that this
> stuff is extremely fragile and should be taken with extra care.
I agree too.
> So I think in the above form, this is good for the emacs-30 branch.
Thanks, done in commit d3c39fb522d. I'll let Arash Esbati confirm the
fix before closing the bug.
Steve Berman
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77118
; Package
emacs
.
(Mon, 14 Apr 2025 10:14:02 GMT)
Full text and
rfc822 format available.
Message #50 received at 77118 <at> debbugs.gnu.org (full text, mbox):
Stephen Berman <stephen.berman <at> gmx.net> writes:
> Thanks, done in commit d3c39fb522d. I'll let Arash Esbati confirm the
> fix before closing the bug.
Many thanks for installing this. I confirm it works as expected in my
test. Please feel free to close this report.
Best, Arash
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Mon, 14 Apr 2025 10:37:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Arash Esbati <arash <at> gnu.org>
:
bug acknowledged by developer.
(Mon, 14 Apr 2025 10:37:02 GMT)
Full text and
rfc822 format available.
Message #55 received at 77118-done <at> debbugs.gnu.org (full text, mbox):
> From: Arash Esbati <arash <at> gnu.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, rudalics <at> gmx.at, stefankangas <at> gmail.com,
> monnier <at> iro.umontreal.ca, 77118 <at> debbugs.gnu.org
> Date: Mon, 14 Apr 2025 12:13:03 +0200
>
> Stephen Berman <stephen.berman <at> gmx.net> writes:
>
> > Thanks, done in commit d3c39fb522d. I'll let Arash Esbati confirm the
> > fix before closing the bug.
>
> Many thanks for installing this. I confirm it works as expected in my
> test. Please feel free to close this report.
Closing.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 12 May 2025 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 65 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.