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

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

bug#57673: [PATCH] Parse --help messages for pcomplete


From: Stefan Monnier
Subject: bug#57673: [PATCH] Parse --help messages for pcomplete
Date: Wed, 14 Sep 2022 16:40:43 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>>     (pcomplete-from-help COMMAND &rest ARGS &key (MARGIN (rx bol (+ " ")))
>>     (ARGUMENT (rx "-" (+ (any "-" alnum)) (32 "="))) (METAVAR (rx (32 " ")
>>     (or (+ (any alnum "_-")) (seq "[" (+? nonl) "]") (seq "<" (+? nonl)
>>     ">") (seq "{" (+? nonl) "}")))) (SEPARATOR (rx ", " symbol-start))
>>     (DESCRIPTION (rx (* nonl) (* "\n" (>= 9 " ") (* nonl)))) NARROW-START
>>     NARROW-END)
>>
>> But the information is good to have, because you need to know what these
>> regexps are in order to use the function.
>
> Oh, yeah, that's pretty bad...  we should probably fix that in the
> cl-defun macro, I guess, so this doesn't have to be fixed in this patch.

Side note: as a programmer, I don't really want to see this whole mess
in `C-h o` either.

Instead, I'd want the docstring to tell me what is the intended default
value of those keywords (rather than what is the code used to build that
default value).

Tho to be perfectly honest, I think any keyword argument whose default
value is not the same as nil is a problem (I know, sometimes there can
be good reasons for that, but we should try to avoid them as much as
possible).

So rather than

    (cl-defun pcomplete-from-help (command
                                   &rest args
                                   &key
                                   (margin (rx bol (+ " ")))
                                   (argument (rx "-" (+ (any "-" alnum)) (? 
"=")))
                                   (metavar (rx (? " ")
                                                (or (+ (any alnum "_-"))
                                                    (seq "[" (+? nonl) "]")
                                                    (seq "<" (+? nonl) ">")
                                                    (seq "{" (+? nonl) "}"))))
                                   (separator (rx ", " symbol-start))
                                   (description (rx (* nonl)
                                                    (* "\n" (>= 9 " ") (* 
nonl))))
                                   narrow-start
                                   narrow-end)

I'd rather see something like:

    (cl-defun pcomplete-from-help (command &rest args
                                   &key margin argument metavar
                                   separator description
                                   narrow-start narrow-end)
      (unless margin (setq margin (rx bol (+ " "))))
      (unless argument (setq argument (rx "-" (+ (any "-" alnum)) (? "=")))
      (unless metavar (setq metavar (rx (? " ")
                                        (or (+ (any alnum "_-"))
                                            (seq "[" (+? nonl) "]")
                                            (seq "<" (+? nonl) ">")
                                            (seq "{" (+? nonl) "}"))))
      (unless separator (setq separator (rx ", " symbol-start))
      (unless description (setq description (rx (* nonl)
                                                (* "\n" (>= 9 " ") (* nonl))))

[ which will probably not fix the overlong line problem, of course.  ]


        Stefan






reply via email to

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