GNU bug report logs - #17955
24.3.92; octave.el: indentation following ... or \

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Sun, 6 Jul 2014 09:38:02 UTC

Severity: minor

Tags: fixed

Found in version 24.3.92

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 17955 in the body.
You can then email your comments to 17955 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 monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org:
bug#17955; Package emacs. (Sun, 06 Jul 2014 09:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org. (Sun, 06 Jul 2014 09:38:02 GMT) Full text and rfc822 format available.

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

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.92; octave.el: indentation following ... or \
Date: Sun, 06 Jul 2014 17:36:38 +0800
As reported on 2013-07-03 in
http://article.gmane.org/gmane.comp.gnu.octave.maintainers/33796

In octave mode:

a = \
b

b is aligned to a. Previously there was an offset per
octave-continuation-offset.

The octave smie lexer may or may not return the continuation token (...
or \), any idea why it is made to behave like this?
octave-continuation-offset is also unused. Comments?

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17955; Package emacs. (Mon, 07 Jul 2014 01:50:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 17955 <at> debbugs.gnu.org
Subject: Re: bug#17955: 24.3.92; octave.el: indentation following ... or \
Date: Sun, 06 Jul 2014 21:49:41 -0400
> As reported on 2013-07-03 in
> http://article.gmane.org/gmane.comp.gnu.octave.maintainers/33796

> In octave mode:

> a = \
> b

> b is aligned to a. Previously there was an offset per
> octave-continuation-offset.

> The octave smie lexer may or may not return the continuation token (...
> or \), any idea why it is made to behave like this?
> octave-continuation-offset is also unused. Comments?

Same as for sh-script's SMIE support, the new indentation code performs
indentation of continued lines as if the "backslash newline" was
a normal newline except it doesn't contain an implicit semi-colon.
So you should get indentation like:

   a = b + a * \
           c

So you should be able to control indentation of "b" above by tweaking
the (:after . "=") or (:before . "=") rule.

That indentation style is incompatible with octave-continuation-offset
(which basically assumes that continued lines are just a single line
wrapped).  But, just like we did in sh-script.el, we could/should
probably add an indentation rule to SMIE to make sure that continued
lines are indented at least as much as octave-continuation-offset.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17955; Package emacs. (Sat, 29 May 2021 05:07:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 17955 <at> debbugs.gnu.org, Leo Liu <sdl.web <at> gmail.com>
Subject: Re: bug#17955: 24.3.92; octave.el: indentation following ... or \
Date: Sat, 29 May 2021 07:06:41 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> So you should be able to control indentation of "b" above by tweaking
> the (:after . "=") or (:before . "=") rule.

I've never played around with the SMIE indentation before, but looking
at other examples, I came up with this:

diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index a1a5192ee1..5d877fc6ba 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -460,7 +460,8 @@ octave-smie-rules
          (smie-rule-parent octave-block-offset)
        ;; For (invalid) code between switch and case.
        ;; (if (smie-rule-parent-p "switch") 4)
-       nil))))
+       nil))
+    ('(:after . "=") octave-block-offset)))
 
 (defun octave-indent-comment ()
   "A function for `smie-indent-functions' (which see)."

And the results look OK to me:

a = \
    b
foo = \
      dasd

So I've pushed this to Emacs 28; feel free to tweak further.

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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 29 May 2021 05:08:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 17955 <at> debbugs.gnu.org and Leo Liu <sdl.web <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 29 May 2021 05:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17955; Package emacs. (Sat, 29 May 2021 14:45:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 17955 <at> debbugs.gnu.org, Leo Liu <sdl.web <at> gmail.com>
Subject: Re: bug#17955: 24.3.92; octave.el: indentation following ... or \
Date: Sat, 29 May 2021 10:44:10 -0400
Lars Ingebrigtsen [2021-05-29 07:06:41] wrote:
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> So you should be able to control indentation of "b" above by tweaking
>> the (:after . "=") or (:before . "=") rule.
>
> I've never played around with the SMIE indentation before, but looking
> at other examples, I came up with this:
>
> diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
> index a1a5192ee1..5d877fc6ba 100644
> --- a/lisp/progmodes/octave.el
> +++ b/lisp/progmodes/octave.el
> @@ -460,7 +460,8 @@ octave-smie-rules
>           (smie-rule-parent octave-block-offset)
>         ;; For (invalid) code between switch and case.
>         ;; (if (smie-rule-parent-p "switch") 4)
> -       nil))))
> +       nil))
> +    ('(:after . "=") octave-block-offset)))
>  
>  (defun octave-indent-comment ()
>    "A function for `smie-indent-functions' (which see)."
>
> And the results look OK to me:
>
> a = \
>     b
> foo = \
>       dasd
>
> So I've pushed this to Emacs 28; feel free to tweak further.

I suspect this behavior, is still not quite what users would want:
why break the line if the continuation starts where you broke?
Maybe

    ('(:after . "=") (smie-rule-parent octave-block-offset))))

would work better?

And we should add tests for these changes, since regressions are all too
easy to introduce when it comes to indentation rules.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17955; Package emacs. (Sun, 30 May 2021 04:27:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 17955 <at> debbugs.gnu.org, Leo Liu <sdl.web <at> gmail.com>
Subject: Re: bug#17955: 24.3.92; octave.el: indentation following ... or \
Date: Sun, 30 May 2021 06:26:14 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> I suspect this behavior, is still not quite what users would want:
> why break the line if the continuation starts where you broke?
> Maybe
>
>     ('(:after . "=") (smie-rule-parent octave-block-offset))))
>
> would work better?
>
> And we should add tests for these changes, since regressions are all too
> easy to introduce when it comes to indentation rules.

OK; now done.

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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 27 Jun 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 294 days ago.

Previous Next


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