GNU bug report logs - #64795
30.0.50; manual-entry [(1) fails

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Sun, 23 Jul 2023 01:00:01 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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 64795 in the body.
You can then email your comments to 64795 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64795; Package emacs. (Sun, 23 Jul 2023 01:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 23 Jul 2023 01:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; manual-entry [(1) fails
Date: Sun, 23 Jul 2023 02:58:59 +0200
Hello,

In Gnu/Linux there is a binary named "[" in /usr/bin/, and it has a man
page I can read in a terminal using "man '[(1)'".

Requesting the man page in Emacs using `man' is broken, however:

  M-x manual-entry RET [ TAB

echoes "[No match]" - this is the first problem (the failing
completion).

C-g, let's try differently:

  M-x manual-entry RET TAB [ TAB

(that's the same as before but additionally requesting all candidates
before writing in the minibuffer) suddenly completes to "[(1)" as
expected.  But when confirming with RET the man buffer only has these
contents:

| /bin/sh: 1: Syntax error: "(" unexpected
|
| process exited abnormally with code 2

That's the second problem.

Oh, and M-x woman [ RET works as expected.


TIA,

Michael.


In GNU Emacs 30.0.50 (build 33, x86_64-pc-linux-gnu, cairo version
 1.16.0) of 2023-07-22 built on drachen
Repository revision: 4b3ab8fae12dcb403e653edeafa1d4ce1dab0187
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64795; Package emacs. (Sun, 23 Jul 2023 19:24:02 GMT) Full text and rfc822 format available.

Message #8 received at 64795 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 64795 <at> debbugs.gnu.org
Subject: Re: bug#64795: 30.0.50; manual-entry [(1) fails
Date: Sun, 23 Jul 2023 22:23:48 +0300
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Date: Sun, 23 Jul 2023 02:58:59 +0200
> 
> In Gnu/Linux there is a binary named "[" in /usr/bin/, and it has a man
> page I can read in a terminal using "man '[(1)'".
> 
> Requesting the man page in Emacs using `man' is broken, however:
> 
>   M-x manual-entry RET [ TAB
> 
> echoes "[No match]" - this is the first problem (the failing
> completion).
> 
> C-g, let's try differently:
> 
>   M-x manual-entry RET TAB [ TAB
> 
> (that's the same as before but additionally requesting all candidates
> before writing in the minibuffer) suddenly completes to "[(1)" as
> expected.  But when confirming with RET the man buffer only has these
> contents:
> 
> | /bin/sh: 1: Syntax error: "(" unexpected
> |
> | process exited abnormally with code 2
> 
> That's the second problem.

Does the patch below give good results?

diff --git a/lisp/man.el b/lisp/man.el
index 479bf9f9a3c..bbcbe5d1525 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -315,7 +315,7 @@ Man-cooked-hook
   :type 'hook
   :group 'man)
 
-(defvar Man-name-regexp "[-[:alnum:]_­+][-[:alnum:]_.:­+]*"
+(defvar Man-name-regexp "[-[:alnum:]_­+[][-[:alnum:]_.:­+]*"
   "Regular expression describing the name of a manpage (without section).")
 
 (defvar Man-section-regexp "[0-9][a-zA-Z0-9+]*\\|[LNln]"
@@ -937,7 +937,7 @@ Man-completion-table
                          "-k" (concat (when (or Man-man-k-use-anchor
                                                 (string-equal prefix ""))
                                         "^")
-                                      prefix))))
+                                      (shell-quote-argument prefix)))))
               (setq table (Man-parse-man-k)))))
 	;; Cache the table for later reuse.
         (when table




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64795; Package emacs. (Mon, 24 Jul 2023 00:16:02 GMT) Full text and rfc822 format available.

Message #11 received at 64795 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64795 <at> debbugs.gnu.org
Subject: Re: bug#64795: 30.0.50; manual-entry [(1) fails
Date: Mon, 24 Jul 2023 02:15:28 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Does the patch below give good results?

Thanks.  Yes, it fixes the man [(1) not completing and not displaying
problem.

However, man RET TAB displays [No match] now instead of showing all
completion candidates.


I searched for more problematic characters.  I found also "@" not
working, like in "journald@.conf (5)" or
"systemd-backlight@.service (8)".

I guess we need to add that character as well.  That's the only
one I found when looking through the output of "apropos '.'".


Thx,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64795; Package emacs. (Mon, 24 Jul 2023 14:25:02 GMT) Full text and rfc822 format available.

Message #14 received at 64795 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 64795 <at> debbugs.gnu.org
Subject: Re: bug#64795: 30.0.50; manual-entry [(1) fails
Date: Mon, 24 Jul 2023 17:25:09 +0300
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Cc: 64795 <at> debbugs.gnu.org
> Date: Mon, 24 Jul 2023 02:15:28 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Does the patch below give good results?
> 
> Thanks.  Yes, it fixes the man [(1) not completing and not displaying
> problem.
> 
> However, man RET TAB displays [No match] now instead of showing all
> completion candidates.

How about the patch below?

> I searched for more problematic characters.  I found also "@" not
> working, like in "journald@.conf (5)" or
> "systemd-backlight@.service (8)".
> 
> I guess we need to add that character as well.  That's the only
> one I found when looking through the output of "apropos '.'".

Thanks, I added that one as well.

diff --git a/lisp/man.el b/lisp/man.el
index 479bf9f..10ea1c8 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -315,7 +315,7 @@ Man-cooked-hook
   :type 'hook
   :group 'man)
 
-(defvar Man-name-regexp "[-[:alnum:]_­+][-[:alnum:]_.:­+]*"
+(defvar Man-name-regexp "[-[:alnum:]_­+[@][-[:alnum:]_.:­+]*"
   "Regular expression describing the name of a manpage (without section).")
 
 (defvar Man-section-regexp "[0-9][a-zA-Z0-9+]*\\|[LNln]"
@@ -937,7 +937,9 @@ Man-completion-table
                          "-k" (concat (when (or Man-man-k-use-anchor
                                                 (string-equal prefix ""))
                                         "^")
-                                      prefix))))
+                                      (if (string-equal prefix "")
+                                          prefix
+                                        (shell-quote-argument prefix))))))
               (setq table (Man-parse-man-k)))))
 	;; Cache the table for later reuse.
         (when table




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64795; Package emacs. (Tue, 25 Jul 2023 01:06:01 GMT) Full text and rfc822 format available.

Message #17 received at 64795 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64795 <at> debbugs.gnu.org
Subject: Re: bug#64795: 30.0.50; manual-entry [(1) fails
Date: Tue, 25 Jul 2023 03:05:34 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> How about the patch below?

I think it works well now.

> -(defvar Man-name-regexp "[-[:alnum:]_­+][-[:alnum:]_.:­+]*"
> +(defvar Man-name-regexp "[-[:alnum:]_­+[@][-[:alnum:]_.:­+]*"
>    "Regular expression describing the name of a manpage (without section).")

And this also works well now.
  
>  (defvar Man-section-regexp "[0-9][a-zA-Z0-9+]*\\|[LNln]"
> @@ -937,7 +937,9 @@ Man-completion-table
>                           "-k" (concat (when (or Man-man-k-use-anchor
>                                                  (string-equal prefix ""))
>                                          "^")
> -                                      prefix))))
> +                                      (if (string-equal prefix "")
> +                                          prefix
> +                                        (shell-quote-argument prefix))))))

I wonder however: why did you add that `shell-quote-argument' wrapper?
I think there is no shell involved.  It doesn't seem to have an effect
here, but I'm not sure if there are not more problems possible like the
one involving the empty string.

Or do you expect that some people might set `manual-program' to
something involving a shell?


Thx,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64795; Package emacs. (Tue, 25 Jul 2023 11:45:01 GMT) Full text and rfc822 format available.

Message #20 received at 64795 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 64795 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64795: 30.0.50; manual-entry [(1) fails
Date: Tue, 25 Jul 2023 14:45:09 +0300
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Cc: 64795 <at> debbugs.gnu.org
> Date: Tue, 25 Jul 2023 03:05:34 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > @@ -937,7 +937,9 @@ Man-completion-table
> >                           "-k" (concat (when (or Man-man-k-use-anchor
> >                                                  (string-equal prefix ""))
> >                                          "^")
> > -                                      prefix))))
> > +                                      (if (string-equal prefix "")
> > +                                          prefix
> > +                                        (shell-quote-argument prefix))))))
> 
> I wonder however: why did you add that `shell-quote-argument' wrapper?
> I think there is no shell involved.  It doesn't seem to have an effect
> here, but I'm not sure if there are not more problems possible like the
> one involving the empty string.
> 
> Or do you expect that some people might set `manual-program' to
> something involving a shell?

I used shell-quote-argument because it did the job, and was simple.

What would be the alternative?  We could perhaps use regexp-quote, if
we believe the argument to "man -k" is interpreted as an Emacs regexp,
but the only reference I have just says "regular expression", and
"M-x man" says in the doc string it's an ERE, and I don't believe
regexp-quote can handle those reliably.  Developing a new function
that would quote an ERE was not my intent, but if you or someone else
wants to do that, please do.  (Btw, is there only one "man -k" variant
out there? if not, perhaps others don't accept regexps at all...)

Stefan, any suggestions?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64795; Package emacs. (Wed, 26 Jul 2023 03:21:02 GMT) Full text and rfc822 format available.

Message #23 received at 64795 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 64795 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64795: 30.0.50; manual-entry [(1) fails
Date: Wed, 26 Jul 2023 05:20:30 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> > I wonder however: why did you add that `shell-quote-argument' wrapper?
> > I think there is no shell involved. [...]
>
> I used shell-quote-argument because it did the job, and was simple.
> What would be the alternative? [...]

Let's go with your patch.  I'm sorry - I was just confused and didn't
understand why the quoting was necessary.  I was missing that the string
will me interpreted as a regexp (although it's obvious...).


Michael.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 26 Jul 2023 14:32:01 GMT) Full text and rfc822 format available.

Notification sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
bug acknowledged by developer. (Wed, 26 Jul 2023 14:32:02 GMT) Full text and rfc822 format available.

Message #28 received at 64795-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 64795-done <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#64795: 30.0.50; manual-entry [(1) fails
Date: Wed, 26 Jul 2023 17:31:59 +0300
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Cc: 64795 <at> debbugs.gnu.org,  Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Wed, 26 Jul 2023 05:20:30 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > > I wonder however: why did you add that `shell-quote-argument' wrapper?
> > > I think there is no shell involved. [...]
> >
> > I used shell-quote-argument because it did the job, and was simple.
> > What would be the alternative? [...]
> 
> Let's go with your patch.  I'm sorry - I was just confused and didn't
> understand why the quoting was necessary.  I was missing that the string
> will me interpreted as a regexp (although it's obvious...).

Thanks, installed on master, and closing the bug.  I added a comment
there regarding the use of shell-quote-argument, for posterity.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 24 Aug 2023 11:24:13 GMT) Full text and rfc822 format available.

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

Previous Next


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