unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47146: 27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode
@ 2021-03-14 21:08 Markus Triska
  2021-03-18  5:46 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Triska @ 2021-03-14 21:08 UTC (permalink / raw)
  To: 47146


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






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#47146: 27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode
  2021-03-14 21:08 bug#47146: 27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode Markus Triska
@ 2021-03-18  5:46 ` Lars Ingebrigtsen
  2021-03-18 13:51   ` Stefan Monnier
  2021-03-18 14:03   ` Andreas Schwab
  0 siblings, 2 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-18  5:46 UTC (permalink / raw)
  To: Markus Triska; +Cc: 47146, Stefan Monnier

Markus Triska <triska@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#47146: 27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode
  2021-03-18  5:46 ` Lars Ingebrigtsen
@ 2021-03-18 13:51   ` Stefan Monnier
  2021-03-18 14:03   ` Andreas Schwab
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2021-03-18 13:51 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Markus Triska, 47146

>> 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






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#47146: 27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode
  2021-03-18  5:46 ` Lars Ingebrigtsen
  2021-03-18 13:51   ` Stefan Monnier
@ 2021-03-18 14:03   ` Andreas Schwab
  1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2021-03-18 14:03 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 47146, Markus Triska, Stefan Monnier

On Mär 18 2021, Lars Ingebrigtsen wrote:

> Markus Triska <triska@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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-18 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-14 21:08 bug#47146: 27.0.50; Unexpected indentation for pcase forms in emacs-lisp-mode Markus Triska
2021-03-18  5:46 ` Lars Ingebrigtsen
2021-03-18 13:51   ` Stefan Monnier
2021-03-18 14:03   ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).