* bug#17955: 24.3.92; octave.el: indentation following ... or \
@ 2014-07-06 9:36 Leo Liu
2014-07-07 1:49 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Leo Liu @ 2014-07-06 9:36 UTC (permalink / raw)
To: 17955
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17955: 24.3.92; octave.el: indentation following ... or \
2014-07-06 9:36 bug#17955: 24.3.92; octave.el: indentation following ... or \ Leo Liu
@ 2014-07-07 1:49 ` Stefan Monnier
2021-05-29 5:06 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2014-07-07 1:49 UTC (permalink / raw)
To: Leo Liu; +Cc: 17955
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17955: 24.3.92; octave.el: indentation following ... or \
2014-07-07 1:49 ` Stefan Monnier
@ 2021-05-29 5:06 ` Lars Ingebrigtsen
2021-05-29 14:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-29 5:06 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 17955, Leo Liu
Stefan Monnier <monnier@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#17955: 24.3.92; octave.el: indentation following ... or \
2021-05-29 5:06 ` Lars Ingebrigtsen
@ 2021-05-29 14:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-30 4:26 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-05-29 14:44 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 17955, Leo Liu
Lars Ingebrigtsen [2021-05-29 07:06:41] wrote:
> Stefan Monnier <monnier@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17955: 24.3.92; octave.el: indentation following ... or \
2021-05-29 14:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-05-30 4:26 ` Lars Ingebrigtsen
0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-30 4:26 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 17955, Leo Liu
Stefan Monnier <monnier@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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-30 4:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-06 9:36 bug#17955: 24.3.92; octave.el: indentation following ... or \ Leo Liu
2014-07-07 1:49 ` Stefan Monnier
2021-05-29 5:06 ` Lars Ingebrigtsen
2021-05-29 14:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-30 4:26 ` Lars Ingebrigtsen
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).