[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27229: eldoc wrong highlighting for "when"
From: |
Andy Moreton |
Subject: |
bug#27229: eldoc wrong highlighting for "when" |
Date: |
Fri, 03 Sep 2021 15:20:07 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (windows-nt) |
On Fri 03 Sep 2021, Lars Ingebrigtsen wrote:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
>
>>> > From emacs -q, type "(when x y z": COND is highlighted
>>> > instead of BODY. This is a regression from the behavior
>>> > of 24.5 (with eldoc-mode on).
>>>
>>> I can reproduce this on current master.
>>
>> Seems this code is the culprit (`elisp--highlight-function-argument'):
>>
>> | ;; Back to index 0 in ARG1 ARG2 ARG2 ARG3 etc...
>> | ;; like in `setq'.
>> | ((or (and (string-match-p "\\.\\.\\.\\'" argument)
>> | (string= argument (car (last args-lst))))
>> | (and (string-match-p "\\.\\.\\.\\'"
>> | (substring args 1 (1- (length args))))
>> | (= (length (remove "..." args-lst)) 2)
>> | (> index 1) (eq (logand index 1) 1)))
>> | (setq index 0))
>>
>> In general, the problem is that "..." can have different meanings (it's
>> not clear which arguments have to be repeated), so this is not trivial
>> to fix I think.
>
> I wonder -- why is this defined like this, anyway?
>
> (defmacro when (cond &rest body)
> "If COND yields non-nil, do BODY, else return nil.
> When COND yields non-nil, eval BODY forms sequentially and return
> value of last one, or nil if there are none.
>
> \(fn COND BODY...)"
>
> (when COND &rest BODY)
>
> is the correct signature, isn't it? Removing the (fn ...) from the doc
> string makes eldoc do the correct thing.
>
> The commit message is helpful:
>
> commit 7f67eea000b0ba102dd86c2666041dc395137413
> Author: Kim F. Storm <storm@cua.dk>
> AuthorDate: Sun Mar 18 00:44:24 2007 +0000
>
> (when, unless): Doc fix.
>
> Anybody know what the point of the (fn...) here is?
Have a look at (info "(elisp) Function Documentation") which explains
this usage. Perhaps eldoc needs fixing to understand that idiom.
AndyM