GNU bug report logs - #47146
27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode

Previous Next

Package: emacs;

Reported by: Markus Triska <triska <at> metalevel.at>

Date: Sun, 14 Mar 2021 21:46:04 UTC

Severity: normal

Found in version 27.0.50

To reply to this bug, email your comments to 47146 AT debbugs.gnu.org.

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#47146; Package emacs. (Sun, 14 Mar 2021 21:46:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <triska <at> metalevel.at>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 14 Mar 2021 21:46:05 GMT) Full text and rfc822 format available.

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

From: Markus Triska <triska <at> metalevel.at>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode
Date: Sun, 14 Mar 2021 22:08:29 +0100
Starting Emacs with:

    $ emacs -Q

I get the following indentation:

    (defun word (arg)
      (pcase arg
        ('love
         'amour)
        ('always
         'toujours)
        ('if
            'si)
        ('emacs
         'emacs)))

However, the indentation I expected is:

    (defun word (arg)
      (pcase arg
        ('love
         'amour)
        ('always
         'toujours)
        ('if
         'si)
        ('emacs
         'emacs)))

Thank you and all the best,
Markus

In GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin18.0.0, X toolkit, Xaw scroll bars)
 of 2018-11-15 built on mac
Repository revision: b4eb908f858284a7962851fd99c94598f76afa6f
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:  Mac OS X 10.14.2





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47146; Package emacs. (Thu, 18 Mar 2021 05:47:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Markus Triska <triska <at> metalevel.at>
Cc: 47146 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#47146: 27.0.50; Unexpected indentation for pcase forms in
 emacs-lisp-mode
Date: Thu, 18 Mar 2021 06:46:01 +0100
Markus Triska <triska <at> metalevel.at> writes:

> Starting Emacs with:
>
>     $ emacs -Q
>
> I get the following indentation:
>
>     (defun word (arg)
>       (pcase arg
>         ('love
>          'amour)
>         ('always
>          'toujours)
>         ('if
>             'si)
>         ('emacs
>          'emacs)))

I guess `lisp-indent-calc-next' is interpreting the "('if" as if it were
"(if"?

I must admit I have some difficulties in following the logic in that
function, perhaps Stefan has some insights here (added to CCs).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47146; Package emacs. (Thu, 18 Mar 2021 13:52:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Markus Triska <triska <at> metalevel.at>, 47146 <at> debbugs.gnu.org
Subject: Re: bug#47146: 27.0.50; Unexpected indentation for pcase forms in
 emacs-lisp-mode
Date: Thu, 18 Mar 2021 09:51:30 -0400
>> Starting Emacs with:
>>
>>     $ emacs -Q
>>
>> I get the following indentation:
>>
>>     (defun word (arg)
>>       (pcase arg
>>         ('love
>>          'amour)
>>         ('always
>>          'toujours)
>>         ('if
>>             'si)
>>         ('emacs
>>          'emacs)))
>
> I guess `lisp-indent-calc-next' is interpreting the "('if" as if it were
> "(if"?

Looks like it, indeed.

> I must admit I have some difficulties in following the logic in that
> function, perhaps Stefan has some insights here (added to CCs).

I'm not very familiar with our Lisp indentation code, I'm afraid (so
much so that I often feel like replacing it with one based on SMIE, tho
I luckily recognize it as NIH-syndrome so I managed to resist the
temptation so far).


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47146; Package emacs. (Thu, 18 Mar 2021 14:04:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Markus Triska <triska <at> metalevel.at>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 47146 <at> debbugs.gnu.org
Subject: Re: bug#47146: 27.0.50; Unexpected indentation for pcase forms in
 emacs-lisp-mode
Date: Thu, 18 Mar 2021 15:03:29 +0100
On Mär 18 2021, Lars Ingebrigtsen wrote:

> Markus Triska <triska <at> metalevel.at> writes:
>
>> Starting Emacs with:
>>
>>     $ emacs -Q
>>
>> I get the following indentation:
>>
>>     (defun word (arg)
>>       (pcase arg
>>         ('love
>>          'amour)
>>         ('always
>>          'toujours)
>>         ('if
>>             'si)
>>         ('emacs
>>          'emacs)))
>
> I guess `lisp-indent-calc-next' is interpreting the "('if" as if it were
> "(if"?

It's lisp-indent-function that calculates the indentation.  It is called
with a pps state where start of last complete sexp terminated points to
`if' and start of innermost containing list points to the preceding
paren.  It then determines that `if' has a lisp-indent-function property
of 2.

So if there is any bug, it is probably in parse-partial-sexp.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




This bug report was last modified 4 years and 89 days ago.

Previous Next


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