GNU bug report logs - #9622
23.3; flet indentation

Previous Next

Package: emacs;

Reported by: diogofsr <at> gmail.com (Diogo F. S. Ramos)

Date: Wed, 28 Sep 2011 01:59:02 UTC

Severity: minor

Tags: confirmed

Found in versions 23.3, 26.2

Done: Stefan Kangas <stefankangas <at> gmail.com>

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 9622 in the body.
You can then email your comments to 9622 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#9622; Package emacs. (Wed, 28 Sep 2011 01:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to diogofsr <at> gmail.com (Diogo F. S. Ramos):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 28 Sep 2011 01:59:02 GMT) Full text and rfc822 format available.

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

From: diogofsr <at> gmail.com (Diogo F. S. Ramos)
To: bug-gnu-emacs <at> gnu.org
Subject: 23.3; flet indentation
Date: Tue, 27 Sep 2011 22:56:45 -0300
Currently, when using `flet', the functions are indented with respect of
the arglist.

It would be nice if flet functions were indented like a `defun', for
example.

Current behavior:

(defun foo ()
  (flet ((long-function-name ()
                             (misses-flet)))
    (long-function-name)))

Wanted behavior:

(defun foo ()
  (flet ((long-function-name ()
           (hi-flet)))
    (long-function-name)))

-- 
Diogo F. S. Ramos




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Sat, 10 Aug 2019 20:11:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: diogofsr <at> gmail.com
Cc: 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: 23.3; flet indentation
Date: Sat, 10 Aug 2019 22:10:00 +0200
diogofsr <at> gmail.com (Diogo F. S. Ramos) writes:

> Currently, when using `flet', the functions are indented with respect of
> the arglist.
>
> It would be nice if flet functions were indented like a `defun', for
> example.
>
> Current behavior:
>
> (defun foo ()
>   (flet ((long-function-name ()
>                              (misses-flet)))
>     (long-function-name)))
>
> Wanted behavior:
>
> (defun foo ()
>   (flet ((long-function-name ()
>            (hi-flet)))
>     (long-function-name)))

I can confirm that this is still an issue on Emacs 26.2 and current
master.

Thanks,
Stefan Kangas




bug Marked as found in versions 26.2. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 10 Aug 2019 20:11:02 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Fri, 23 Aug 2019 06:40:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Sat, 25 Sep 2021 01:30:03 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: diogofsr <at> gmail.com (Diogo F. S. Ramos)
Cc: 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: 23.3; flet indentation
Date: Sat, 25 Sep 2021 03:29:33 +0200
diogofsr <at> gmail.com (Diogo F. S. Ramos) writes:

> Currently, when using `flet', the functions are indented with respect of
> the arglist.
>
> It would be nice if flet functions were indented like a `defun', for
> example.

This is now fixed in Emacs 28:

commit 57dcc26e4af4e4f7812f2e287f18d36c662bf6b1 (HEAD -> master)
Author:     akater <nuclearspace <at> gmail.com>
AuthorDate: Sat Sep 25 03:27:29 2021 +0200


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




bug marked as fixed in version 28.1, send any further explanations to 9622 <at> debbugs.gnu.org and diogofsr <at> gmail.com (Diogo F. S. Ramos) Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 25 Sep 2021 01:30:03 GMT) Full text and rfc822 format available.

bug No longer marked as fixed in versions 28.1 and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 27 Sep 2021 15:18:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Tue, 28 Sep 2021 03:00:02 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: 23.3; flet indentation
Date: Tue, 28 Sep 2021 03:01:13 +0000
[Message part 1 (text/plain, inline)]
I'm not around Emacs 28 atm; could you check if it's still wrong when cl-flet's definition — square (x) — is not on a single line?
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Tue, 28 Sep 2021 05:25:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: 23.3; flet indentation
Date: Tue, 28 Sep 2021 07:23:47 +0200
akater <nuclearspace <at> gmail.com> writes:

> I'm not around Emacs 28 atm; could you check if it's still wrong when
> cl-flet's definition — square (x) — is not on a single line?

Yes, it's still wrongly indented:

(cl-flet ((square (x)
            (* x x)))
  (let* ((a 3)
          (b (square a)))               ; <-- malindented
    b))

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Tue, 28 Sep 2021 10:13:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9622 <at> debbugs.gnu.org, akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: 23.3; flet indentation
Date: Tue, 28 Sep 2021 12:11:55 +0200
It affects other constructs too:

  (cl-flet ((f () alpha))
    (cond
     (beta
       gamma)))  ; <- wrong






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Tue, 28 Sep 2021 10:37:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9622 <at> debbugs.gnu.org, akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: 23.3; flet indentation
Date: Tue, 28 Sep 2021 12:35:54 +0200
More examples:

  (cl-flet ((f () alpha))
    (let ((x y))
      (if beta
        gamma     ; <- wrong
        delta)))

  (cl-flet ((f () alpha))
    (gamma
     (delta
       epsilon)))   ; <- wrong






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Tue, 28 Sep 2021 16:52:02 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: 23.3; flet indentation
Date: Tue, 28 Sep 2021 16:39:53 +0000
[Message part 1 (text/plain, inline)]
OK I found the culprit; figuring out the least expensive way to
resolve.  One way or another, I'll fix it in the coming days.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Wed, 29 Sep 2021 18:24:01 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org,
 "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Wed, 29 Sep 2021 18:12:10 +0000
[Message part 1 (text/plain, inline)]
Several fixes:

- We now check whether we're in the relevant subexpression of flet and
  friends.

- Added -p to the predicate's name.

- Added cl-macrolet cl-flet* cl-symbol-macrolet to the list of local
  definers.  I added cl-symbol-macrolet too because this is how SLIME
  indents symbol-macrolet.

Technical notes:

- I attached flet-tests.sexp which only contains cl-flet forms written
  the way they are meant to be indented.  I think writing them in
  strings in deftest forms would be quite ugly and unreliable.  If
  appropriate, I could add test(s) that would try to indent individual
  forms in the file; no change indicates test(s) passed.  Only I'm not
  sure what would be the best way to define an individual ert test per
  form but I guess I'll figure it out.  OK?

- parse-partial-sexp does not keep any record of relative position of
  subexpressions in superexpressions which I found surprising.  Things
  would be easier if it did.  Other things might become easier too.
  But I did not dare to patch it.

I also have stylistic notes.  First, the less important ones.

- You changed “iff” to “if”; I meant “iff”, i.e. “if and only if”; I
  now changed it to “when” simply because the semantics corresponds
  directly to that of lisp's own lingo and is thus in my opinion
  easier to read.

- Lines
  > In Wishful Lisp, the following form would be
  > ...
  are supposed to convey the intent of what the form in quistion does,
  in a concise way.  Feel free to remove this if you feel it doesn't
  help.

The more involved stylistic note is

- a line split issue that I wanted to discuss for some time.  See the
  diff when it comes to second-order-parent and (pop parents).  TL;DR:
  it's entirely up to you but I wanted to point out that this was done
  deliberately.  Note that if pop (or a hypothetical cdrf) accepted
  multiple arguments, most people would agree it's fine to keep these
  two on a single line; if you have time, see the discussion I started
  in emacs-devel:
  https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg02189.html

[signature.asc (application/pgp-signature, inline)]
[0001-Fixup-cl-flet-indentation.patch (text/x-diff, attachment)]
[flet-tests.sexp (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 06:38:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org,
 "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 08:37:36 +0200
akater <nuclearspace <at> gmail.com> writes:

> - We now check whether we're in the relevant subexpression of flet and
>   friends.
>
> - Added -p to the predicate's name.
>
> - Added cl-macrolet cl-flet* cl-symbol-macrolet to the list of local
>   definers.  I added cl-symbol-macrolet too because this is how SLIME
>   indents symbol-macrolet.

Thanks; applied to Emacs 28.

> - I attached flet-tests.sexp which only contains cl-flet forms written
>   the way they are meant to be indented.  I think writing them in
>   strings in deftest forms would be quite ugly and unreliable.

Indeed.  I have a new machinery for doing tests like this waiting for
Emacs 29 development to commence to fix this awkwardness.

> - You changed “iff” to “if”; I meant “iff”, i.e. “if and only if”; I
>   now changed it to “when” simply because the semantics corresponds
>   directly to that of lisp's own lingo and is thus in my opinion
>   easier to read.

Oops, sorry.

> The more involved stylistic note is
>
> - a line split issue that I wanted to discuss for some time.  See the
>   diff when it comes to second-order-parent and (pop parents).  TL;DR:
>   it's entirely up to you but I wanted to point out that this was done
>   deliberately.  Note that if pop (or a hypothetical cdrf) accepted
>   multiple arguments, most people would agree it's fine to keep these
>   two on a single line; if you have time, see the discussion I started
>   in emacs-devel:
>   https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg02189.html

We never put two statements on the same line like that, so I added a
newline there (and some other stylistic fixes, like changing the `and' to
a when (the `and' is logical here (since we're doing a predicate), but
we prefer `when' when it's a long and involved body).

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 08:06:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9622 <at> debbugs.gnu.org, akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 10:05:33 +0200
30 sep. 2021 kl. 08.37 skrev Lars Ingebrigtsen <larsi <at> gnus.org>:

>> - I attached flet-tests.sexp which only contains cl-flet forms written
>>  the way they are meant to be indented.  I think writing them in
>>  strings in deftest forms would be quite ugly and unreliable.

What would be unreliable?

> Indeed.  I have a new machinery for doing tests like this waiting for
> Emacs 29 development to commence to fix this awkwardness.

We should insist on tests accompanying any bug fix from the start. Awkward is better than nothing. If the author finds it too difficult to write the test then we should help.

Akater, we have plenty of indentation tests for other programming modes already and they employ a variety of methods; there are many examples to look at. For instance, look at ruby-mode-tests.el; it contains a converted legacy test (ruby--indent/converted-from-manual-test) that reindents a separate source file, much like your example.

If you need further directions, we will assist.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 13:07:01 GMT) Full text and rfc822 format available.

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

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org,
 akater <nuclearspace <at> gmail.com>, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 14:06:42 +0100
Lars Ingebrigtsen [2021-09-30 08:37 +0200] wrote:

> akater <nuclearspace <at> gmail.com> writes:
>
>> - We now check whether we're in the relevant subexpression of flet and
>>   friends.
>>
>> - Added -p to the predicate's name.
>>
>> - Added cl-macrolet cl-flet* cl-symbol-macrolet to the list of local
>>   definers.  I added cl-symbol-macrolet too because this is how SLIME
>>   indents symbol-macrolet.
>
> Thanks; applied to Emacs 28.

Thanks, but I found another indentation regression introduced in
38037e04cb that does not involve flet and is not fixed by c42af5aee7:

0. emacs -Q
1. (let ((x (and y RET

Point is now at BOL instead of under y.

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 13:42:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org,
 akater <nuclearspace <at> gmail.com>, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 15:41:41 +0200
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> Thanks, but I found another indentation regression introduced in
> 38037e04cb that does not involve flet and is not fixed by c42af5aee7:
>
> 0. emacs -Q
> 1. (let ((x (and y RET
>
> Point is now at BOL instead of under y.

Perhaps we should consider backing out these changed in Emacs 28 and
continuing to work on them on the trunk?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 14:10:02 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, "Basil L. Contovounesios"
 <contovob <at> tcd.ie>
Cc: Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org,
 "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 13:57:04 +0000
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Perhaps we should consider backing out these changed in Emacs 28 and
> continuing to work on them on the trunk?

I don't think so.  The first attempt was written in a hurry, and merged
without extensive testing; in the second I did exhaustive tests, it just
never crossed my mind to test on unbalanced expressions.  This very much
looks like the last ignore-errors of them:

[signature.asc (application/pgp-signature, inline)]
[0001-Fix-other-regressions-in-cl-flet-indentation.patch (text/x-diff, inline)]
From 2e5f87b345d349dc6657f8034102a842d0685232 Mon Sep 17 00:00:00 2001
From: akater <nuclearspace <at> gmail.com>
Date: Thu, 30 Sep 2021 13:37:59 +0000
Subject: [PATCH] Fix other regressions in cl-flet indentation

* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p):
Fix indentation regression
introduced by 38037e04cb05cb1f2b604f0b1602d36b0bcf6985
(bug#9622), namely don't fail in unreadable (incl. unbalanced) sexps.
---
 lisp/emacs-lisp/lisp-mode.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index cd054801bc..57196dfec4 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1124,9 +1124,13 @@ defun lisp--local-defform-body-p (state)
       (when second-order-parent
         (save-excursion
           (goto-char (1+ second-order-parent))
-          (and (memq (read (current-buffer))
-                     '( cl-flet cl-labels cl-macrolet cl-flet*
-                        cl-symbol-macrolet))
+          (and (when-let ((head (ignore-errors
+                                  ;; FIXME: This does not distinguish
+                                  ;; between reading nil and a read error.
+                                  ;; We don't care but still, better fix this.
+                                  (read (current-buffer)))))
+                 (memq head '( cl-flet cl-labels cl-macrolet cl-flet*
+                               cl-symbol-macrolet)))
                ;; Now we must check that we are
                ;; in the second element of the flet-like form.
                ;; It would be easier if `parse-partial-sexp' also recorded
-- 
2.32.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 14:53:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org,
 akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 16:52:30 +0200
30 sep. 2021 kl. 15.06 skrev Basil L. Contovounesios <contovob <at> tcd.ie>:

> Thanks, but I found another indentation regression introduced in
> 38037e04cb that does not involve flet and is not fixed by c42af5aee7:
> 
> 0. emacs -Q
> 1. (let ((x (and y RET
> 
> Point is now at BOL instead of under y.

Thanks for reporting this; I've noticed the same. It's sufficient annoying that I'm reverting both changes; at least that gets us back where we started.

Akater, please don't see this as a hostile move -- we all want the bug resolved. Let's make sure that the next patch comes with ERT tests for all the mentioned issues and more.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 15:12:01 GMT) Full text and rfc822 format available.

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

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org,
 akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 16:11:13 +0100
Mattias Engdegård [2021-09-30 16:52 +0200] wrote:

> 30 sep. 2021 kl. 15.06 skrev Basil L. Contovounesios <contovob <at> tcd.ie>:
>
>> Thanks, but I found another indentation regression introduced in
>> 38037e04cb that does not involve flet and is not fixed by c42af5aee7:
>> 
>> 0. emacs -Q
>> 1. (let ((x (and y RET
>> 
>> Point is now at BOL instead of under y.
>
> Thanks for reporting this; I've noticed the same. It's sufficient annoying that
> I'm reverting both changes; at least that gets us back where we started.

Modulo a failing test ;).

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 15:24:02 GMT) Full text and rfc822 format available.

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

From: Thierry Volpiatto <thievol <at> posteo.net>
To: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army
 knife of text editors" <bug-gnu-emacs <at> gnu.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Mattias Engdegård <mattiase <at> acm.org>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org,
 akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 15:23:44 +0000
"Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army
knife of text editors" <bug-gnu-emacs <at> gnu.org> writes:

> Mattias Engdegård [2021-09-30 16:52 +0200] wrote:
>
>> 30 sep. 2021 kl. 15.06 skrev Basil L. Contovounesios <contovob <at> tcd.ie>:
>>
>>> Thanks, but I found another indentation regression introduced in
>>> 38037e04cb that does not involve flet and is not fixed by c42af5aee7:
>>> 
>>> 0. emacs -Q
>>> 1. (let ((x (and y RET
>>> 
>>> Point is now at BOL instead of under y.
>>
>> Thanks for reporting this; I've noticed the same. It's sufficient annoying that
>> I'm reverting both changes; at least that gets us back where we started.
>
> Modulo a failing test ;).

Note that using `common-lisp-indent-function` as `lisp-indent-function` in
emacs-27.2 make `cl-flet` and friends indent properly, with a few more
settings for `cl-loop` indentation it is perfect, did I miss something?

-- 
Thierry




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 15:25:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 15:26:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org,
 akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 17:25:05 +0200
30 sep. 2021 kl. 17.11 skrev Basil L. Contovounesios <contovob <at> tcd.ie>:

> Modulo a failing test ;).

Now marked as an expected failure. Thank you!





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 15:46:01 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Thierry Volpiatto <thievol <at> posteo.net>, "Basil L. Contovounesios via Bug
 reports for GNU Emacs, the Swiss army
 knife of text editors" <bug-gnu-emacs <at> gnu.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Mattias Engdegård <mattiase <at> acm.org>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 15:33:53 +0000
[Message part 1 (text/plain, inline)]
Thierry Volpiatto <thievol <at> posteo.net> writes:

> Note that using `common-lisp-indent-function` as `lisp-indent-function` in
> emacs-27.2 make `cl-flet` and friends indent properly, with a few more
> settings for `cl-loop` indentation it is perfect, did I miss something?

In general, the languages are different and rules should be expected to
be different.  cl- indenter takes care of #(..) and so on which is
meaningless in Elisp.

I also think common-lisp-indent-function should not attempt to indent
cl- stuff and likewise lisp-indent-function should not indent plain flet
and so on because plain ones are “officially deprecated”.

It would make more sense to have a generic sexp indenter and
dialect-specific indenters that inherit from it.  But inheritance
practices in Emacs is in terrible shape: inheritance mechanisms have
been reinvented in incompatible ways since forever.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 15:46:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 16:05:01 GMT) Full text and rfc822 format available.

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

From: Thierry Volpiatto <thievol <at> posteo.net>
To: akater <nuclearspace <at> gmail.com>
Cc: contovob <at> tcd.ie, mattiase <at> acm.org, larsi <at> gnus.org, 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 16:04:11 +0000
akater <nuclearspace <at> gmail.com> writes:

> Thierry Volpiatto <thievol <at> posteo.net> writes:
>
>> Note that using `common-lisp-indent-function` as `lisp-indent-function` in
>> emacs-27.2 make `cl-flet` and friends indent properly, with a few more
>> settings for `cl-loop` indentation it is perfect, did I miss something?
>
> In general, the languages are different and rules should be expected to
> be different.  cl- indenter takes care of #(..) and so on which is
> meaningless in Elisp.
>
> I also think common-lisp-indent-function should not attempt to indent
> cl- stuff and likewise lisp-indent-function should not indent plain flet
> and so on because plain ones are “officially deprecated”.
>
> It would make more sense to have a generic sexp indenter and
> dialect-specific indenters that inherit from it.  But inheritance
> practices in Emacs is in terrible shape: inheritance mechanisms have
> been reinvented in incompatible ways since forever.

Thanks for explanations, make sense.

-- 
Thierry




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 16:08:02 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 15:56:16 +0000
[Message part 1 (text/plain, inline)]
I don't see this as hostile.  I didn't expect my original one-off
suggestion to be merged this soon anyway.  But I still think we were
going the most efficient way of producing the aforementioned “and more”
tests.

Lars, when the method is established to use external file like
flet-tests.sexp (with the last unbalanced example and its variations to
be added) rather than strings, let me know, I'll write the tests.  As
much as I want local definers indented correctly, getting these strings
into tests verbatim is too much.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 19:26:01 GMT) Full text and rfc822 format available.

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

From: miha <at> kamnitnik.top
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>, Lars Ingebrigtsen
 <larsi <at> gnus.org>
Cc: Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org,
 akater <nuclearspace <at> gmail.com>, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 21:28:42 +0200
[Message part 1 (text/plain, inline)]
> Thanks, but I found another indentation regression introduced in
> 38037e04cb that does not involve flet and is not fixed by c42af5aee7:
>
> 0. emacs -Q
> 1. (let ((x (and y RET
>
I also found a regression that you might want to add as a test case: on
Emacs commit c006286780, Evaluating the following form would signal an
"Invalid read syntax" error:

   (pp `[((1 (okno . ,(current-buffer))))])

Best regards.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 30 Sep 2021 23:36:02 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: 9622 <at> debbugs.gnu.org
Cc: miha <at> kamnitnik.top
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 30 Sep 2021 23:23:39 +0000
Thank you.  This is already covered by the last patch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Fri, 01 Oct 2021 11:28:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Mattias Engdegård <mattiase <at> acm.org>,
 9622 <at> debbugs.gnu.org, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Fri, 01 Oct 2021 13:27:32 +0200
akater <nuclearspace <at> gmail.com> writes:

> I don't think so.  The first attempt was written in a hurry, and merged
> without extensive testing; in the second I did exhaustive tests, it just
> never crossed my mind to test on unbalanced expressions.  This very much
> looks like the last ignore-errors of them:

Thanks, but I think we're just too late to get this into Emacs 28, so I
resurrected your patch series and pushed it as one patch to the trunk.
(I also added all the test cases from your second patch to ert.)

Please have a look and see if I missed something when I did the merge.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Sat, 09 Oct 2021 07:38:01 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Mattias Engdegård <mattiase <at> acm.org>,
 9622 <at> debbugs.gnu.org, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Sat, 09 Oct 2021 07:26:04 +0000
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> akater <nuclearspace <at> gmail.com> writes:
>
>> I don't think so.  The first attempt was written in a hurry, and merged
>> without extensive testing; in the second I did exhaustive tests, it just
>> never crossed my mind to test on unbalanced expressions.  This very much
>> looks like the last ignore-errors of them:
>
> Thanks, but I think we're just too late to get this into Emacs 28, so I
> resurrected your patch series and pushed it as one patch to the trunk.
> (I also added all the test cases from your second patch to ert.)
>
> Please have a look and see if I missed something when I did the merge.

Everything from my last patch is in its place (my branch is even with
master, and 15 tests are there) but:

We need to also include partial sexps, and a test should ensure RET brings
point to the proper position.  I have not familiarized myself with this test
routine yet so I'm not sure how to do this right.  The important aspect I want
to point out now is, especially since previous partial sexps affect the
indentation of all consequent sexps, we must ensure this will not affect both
the “RET tests” and tests where the region is indented.  This presumes all our
test cases will reside in a single file but they should be because otherwise it
will be terrible.  This is important enough so I write this message in advance
even though the indentation is sometimes wrong and I've not yet figured it out.

Here go “RET test cases”; looks like they are exhaustive, modulo variations
with longer excessive whitespace.  Not everything of what follows is indented
correctly with my patch.  I'm investigating; some issues might be present even
without my patch.

In what follows, ^ points to the appropriate position after RET is pressed.

The last case that broke my patch:
(let ((x (and y

              ^
A variation of it, just in case:
(let ((x

       ^
; N.B.: This is the way it is in elisp-mode right now but in lisp-mode, the point is one step further.

5 cases with some whitespace missing:

flet-missing-whitespace-1
(cl-flet((f (x)

           ^
flet-missing-whitespace-2
(cl-flet((f(x)

           ^
flet-missing-whitespace-3
(cl-flet ((f(x)

            ^
flet-missing-whitespace-4
(cl-flet( (f (x)

            ^
flet-missing-whitespace-5
(cl-flet( (f(x)

            ^

Combinations of missing and excessive whitespace

flet-missing-and-excessive-whitespace-1
(cl-flet((f  (x)

           ^
flet-missing-and-excessive-whitespace-2
(cl-flet  ((f(x)

             ^
flet-missing-and-excessive-whitespace-3
(cl-flet( (f  (x)

            ^
flet-missing-and-excessive-whitespace-4
(cl-flet(  (f (x)

             ^
flet-missing-and-excessive-whitespace-5
(cl-flet(  (f  (x)

             ^
flet-missing-and-excessive-whitespace-6
(cl-flet(  (f(x)

             ^

There's another problem: in some of these cases, even though initial
indentation is incorrect, once the sexp is completed, it is indented correctly.
But in some other cases, it's not!  I'm looking into this.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Sat, 09 Oct 2021 11:25:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Mattias Engdegård <mattiase <at> acm.org>,
 9622 <at> debbugs.gnu.org, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Sat, 09 Oct 2021 13:23:56 +0200
akater <nuclearspace <at> gmail.com> writes:

> In what follows, ^ points to the appropriate position after RET is pressed.
>
> The last case that broke my patch:
> (let ((x (and y
>
>               ^

I think these tests should be fine for erts-mode.  Just put Point-Char:
^ into the header and make the test be (newline).

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 28 Oct 2021 19:36:01 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Mattias Engdegård <mattiase <at> acm.org>,
 9622 <at> debbugs.gnu.org, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 28 Oct 2021 19:23:45 +0000
[Message part 1 (text/plain, inline)]
New patch supports incomplete sexps and adds tests for them.

“test-identation” ert test in elisp-mode-tests.el does pass.

[signature.asc (application/pgp-signature, inline)]
[0001-Indent-cl-flet-like-forms-correctly-in-incomplete-ex.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Thu, 28 Oct 2021 21:54:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Mattias Engdegård <mattiase <at> acm.org>,
 9622 <at> debbugs.gnu.org, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Thu, 28 Oct 2021 23:53:33 +0200
akater <nuclearspace <at> gmail.com> writes:

> New patch supports incomplete sexps and adds tests for them.
>
> “test-identation” ert test in elisp-mode-tests.el does pass.

Thanks; seems to work well, so this is now pushed to the trunk.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Mon, 08 Nov 2021 01:14:02 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 9622 <at> debbugs.gnu.org
Cc: Mattias Engdegård <mattiase <at> acm.org>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, akater <nuclearspace <at> gmail.com>,
 "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: bug#9622: 23.3; flet indentation
Date: Mon, 08 Nov 2021 02:13:16 +0100
akater <nuclearspace <at> gmail.com> writes:

> Several fixes:
> [...]

Am I allowed to report a regression that might be caused by these
changes here?

I have code like this:

#+begin_src emacs-lisp
(cl-flet* ((cont-w/expr (f) (g-w/extended-expr cont f))
           (cont-prepend (&rest exps)
             (cont-w/expr (lambda (p) (apply #'g--and (append exps (list p)))))))
  (pcase expr
    ((and (let transformed (g--trivial-transformation-p expr)) (guard transformed))
    (cont-prepend transformed))))
#+end_src

and the last line gets indented wrongly (one space too less).  When I
remove the wrapping `cl-flet*' indentation behavior gets back to the
expected.


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Mon, 08 Nov 2021 06:30:02 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>, 9622 <at> debbugs.gnu.org
Cc: Mattias Engdegård <mattiase <at> acm.org>,
 Lars Ingebrigtsen <larsi <at> gnus.org>, "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Mon, 08 Nov 2021 06:18:11 +0000
[Message part 1 (text/plain, inline)]
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> #+begin_src emacs-lisp
> (cl-flet* ((cont-w/expr (f) (g-w/extended-expr cont f))
>            (cont-prepend (&rest exps)
>              (cont-w/expr (lambda (p) (apply #'g--and (append exps (list p)))))))
>   (pcase expr
>     ((and (let transformed (g--trivial-transformation-p expr)) (guard transformed))
>     (cont-prepend transformed))))
> #+end_src
>
> and the last line gets indented wrongly (one space too less).  When I
> remove the wrapping `cl-flet*' indentation behavior gets back to the
> expected.

Indeed, I forgot one save-excursion.

To Lars: tests involving complete sexps do pass, the rest I couldn't
run, as described in bug#51680

[signature.asc (application/pgp-signature, inline)]
[0001-lisp-emacs-lisp-lisp-mode.el-Fix-parser-state-corrup.patch (text/x-diff, inline)]
From 367ec048e7fbf6d7f3453a64e953079575444f4d Mon Sep 17 00:00:00 2001
From: akater <nuclearspace <at> gmail.com>
Date: Mon, 8 Nov 2021 04:48:13 +0000
Subject: [PATCH] ; * lisp/emacs-lisp/lisp-mode.el: Fix parser state
 corruption.

* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p): Preserve
the point
* test/lisp/progmodes/elisp-mode-resources/flet.erts: Add corresponding
test example
---
 lisp/emacs-lisp/lisp-mode.el                       | 13 +++++++------
 test/lisp/progmodes/elisp-mode-resources/flet.erts | 10 ++++++++++
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 15afdef0252..a5613e70e0a 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1148,12 +1148,13 @@ defun lisp--local-defform-body-p (state)
                               ;; that starts a sexp.
                               t)
                              (point))))))
-               (ignore-errors
-                 ;; We rely on `backward-up-list' working
-                 ;; even when sexp is incomplete “to the right”.
-                 (backward-up-list 2)
-                 t)
-               (= local-definitions-starting-point (point))))))))
+               (save-excursion
+                 (ignore-errors
+                   ;; We rely on `backward-up-list' working
+                   ;; even when sexp is incomplete “to the right”.
+                   (backward-up-list 2)
+                   t)
+                 (= local-definitions-starting-point (point)))))))))
 
 (defun lisp-indent-function (indent-point state)
   "This function is the normal value of the variable `lisp-indent-function'.
diff --git a/test/lisp/progmodes/elisp-mode-resources/flet.erts b/test/lisp/progmodes/elisp-mode-resources/flet.erts
index 7c4a0f304e9..da3dcb6ec3e 100644
--- a/test/lisp/progmodes/elisp-mode-resources/flet.erts
+++ b/test/lisp/progmodes/elisp-mode-resources/flet.erts
@@ -221,6 +221,16 @@ Name: flet15
             i)))
 =-=-=
 
+Name: flet16
+
+=-=
+(cl-flet ((f (x)
+            (g x)))
+  (pcase e
+    ((dangerous-expression)
+     (form))))
+=-=-=
+
 Name: flet-indentation-incomplete-sexp-no-side-effects-1
 Code: (lambda () (emacs-lisp-mode) (setq indent-tabs-mode nil) (newline nil t))
 Point-Char: |
-- 
2.32.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Mon, 08 Nov 2021 06:39:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>,
 Mattias Engdegård <mattiase <at> acm.org>, 9622 <at> debbugs.gnu.org,
 "Diogo F. S. Ramos" <diogofsr <at> gmail.com>
Subject: Re: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Mon, 08 Nov 2021 07:38:29 +0100
akater <nuclearspace <at> gmail.com> writes:

> Indeed, I forgot one save-excursion.

Thanks; this fixes Michael's test case here, too, so I've now pushed it
to the trunk.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Mon, 08 Nov 2021 06:50:02 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9622 <at> debbugs.gnu.org
Subject: Re: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Mon, 08 Nov 2021 06:38:03 +0000
[Message part 1 (text/plain, inline)]
Sorry: even though half of the tests pass, I did not preserve one check
with the last patch and it better be preserved just to be safe:

[0001-lisp-emacs-lisp-lisp-mode.el-Fix-parser-state-corrup.patch (text/x-diff, inline)]
From 2f35789d67115ccd7288ce0b759d6b52c08dde4c Mon Sep 17 00:00:00 2001
From: akater <nuclearspace <at> gmail.com>
Date: Mon, 8 Nov 2021 04:48:13 +0000
Subject: [PATCH] ; * lisp/emacs-lisp/lisp-mode.el: Fix parser state
 corruption.

* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p): Preserve
the point
* test/lisp/progmodes/elisp-mode-resources/flet.erts: Add corresponding
test example
---
 lisp/emacs-lisp/lisp-mode.el                       | 13 +++++++------
 test/lisp/progmodes/elisp-mode-resources/flet.erts | 10 ++++++++++
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 15afdef0252..d90d0f5f6ac 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1148,12 +1148,13 @@ defun lisp--local-defform-body-p (state)
                               ;; that starts a sexp.
                               t)
                              (point))))))
-               (ignore-errors
-                 ;; We rely on `backward-up-list' working
-                 ;; even when sexp is incomplete “to the right”.
-                 (backward-up-list 2)
-                 t)
-               (= local-definitions-starting-point (point))))))))
+               (save-excursion
+                 (when (ignore-errors
+                         ;; We rely on `backward-up-list' working
+                         ;; even when sexp is incomplete “to the right”.
+                         (backward-up-list 2)
+                         t)
+                   (= local-definitions-starting-point (point))))))))))
 
 (defun lisp-indent-function (indent-point state)
   "This function is the normal value of the variable `lisp-indent-function'.
diff --git a/test/lisp/progmodes/elisp-mode-resources/flet.erts b/test/lisp/progmodes/elisp-mode-resources/flet.erts
index 7c4a0f304e9..da3dcb6ec3e 100644
--- a/test/lisp/progmodes/elisp-mode-resources/flet.erts
+++ b/test/lisp/progmodes/elisp-mode-resources/flet.erts
@@ -221,6 +221,16 @@ Name: flet15
             i)))
 =-=-=
 
+Name: flet16
+
+=-=
+(cl-flet ((f (x)
+            (g x)))
+  (pcase e
+    ((dangerous-expression)
+     (form))))
+=-=-=
+
 Name: flet-indentation-incomplete-sexp-no-side-effects-1
 Code: (lambda () (emacs-lisp-mode) (setq indent-tabs-mode nil) (newline nil t))
 Point-Char: |
-- 
2.32.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Mon, 08 Nov 2021 06:54:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Mon, 08 Nov 2021 07:53:14 +0100
akater <nuclearspace <at> gmail.com> writes:

> Sorry: even though half of the tests pass, I did not preserve one check
> with the last patch and it better be preserved just to be safe:

Can you send a new patch against the current trunk?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Mon, 08 Nov 2021 09:49:01 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Mon, 08 Nov 2021 09:36:39 +0000
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> akater <nuclearspace <at> gmail.com> writes:
>
>> Sorry: even though half of the tests pass, I did not preserve one check
>> with the last patch and it better be preserved just to be safe:
>
> Can you send a new patch against the current trunk?

Here it goes.

[0001-lisp-emacs-lisp-lisp-mode.el-Restore-one-check.patch (text/x-diff, inline)]
From 2a988ef49e1ea954a99e4c123301165764feebac Mon Sep 17 00:00:00 2001
From: akater <nuclearspace <at> gmail.com>
Date: Mon, 8 Nov 2021 04:48:13 +0000
Subject: [PATCH] ; * lisp/emacs-lisp/lisp-mode.el: Restore one check.

* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p):
Do check backward-up-list executing without errors
---
 lisp/emacs-lisp/lisp-mode.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index a5613e70e0a..d90d0f5f6ac 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1149,12 +1149,12 @@ defun lisp--local-defform-body-p (state)
                               t)
                              (point))))))
                (save-excursion
-                 (ignore-errors
-                   ;; We rely on `backward-up-list' working
-                   ;; even when sexp is incomplete “to the right”.
-                   (backward-up-list 2)
-                   t)
-                 (= local-definitions-starting-point (point)))))))))
+                 (when (ignore-errors
+                         ;; We rely on `backward-up-list' working
+                         ;; even when sexp is incomplete “to the right”.
+                         (backward-up-list 2)
+                         t)
+                   (= local-definitions-starting-point (point))))))))))
 
 (defun lisp-indent-function (indent-point state)
   "This function is the normal value of the variable `lisp-indent-function'.
-- 
2.32.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Mon, 08 Nov 2021 16:31:01 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9622 <at> debbugs.gnu.org, akater <nuclearspace <at> gmail.com>
Subject: Re: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Mon, 08 Nov 2021 17:30:03 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Thanks; this fixes Michael's test case here, too, so I've now pushed
> it to the trunk.

Thanks, too -- works now.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9622; Package emacs. (Tue, 09 Nov 2021 03:27:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: akater <nuclearspace <at> gmail.com>
Cc: 9622 <at> debbugs.gnu.org
Subject: Re: bug#9622: [PATCH] Re: bug#9622: 23.3; flet indentation
Date: Tue, 09 Nov 2021 04:25:53 +0100
akater <nuclearspace <at> gmail.com> writes:

>> Can you send a new patch against the current trunk?
>
> Here it goes.

Thanks; applied to Emacs 29.

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




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sat, 15 Feb 2025 02:21:03 GMT) Full text and rfc822 format available.

Notification sent to diogofsr <at> gmail.com (Diogo F. S. Ramos):
bug acknowledged by developer. (Sat, 15 Feb 2025 02:21:03 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 9622-done <at> debbugs.gnu.org, akater <nuclearspace <at> gmail.com>
Subject: Re: bug#9622: 23.3; flet indentation
Date: Sat, 15 Feb 2025 02:20:26 +0000
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> akater <nuclearspace <at> gmail.com> writes:
>
>>> Can you send a new patch against the current trunk?
>>
>> Here it goes.
>
> Thanks; applied to Emacs 29.

All the test cases in this thread indent correctly, and there are
several tests.  So I assume that fixed it, and I'm closing this bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 15 Mar 2025 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 55 days ago.

Previous Next


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