unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Doug Maxey <emacs-bugs@maxeygroup.tech>, 53817@debbugs.gnu.org
Subject: bug#53817: 28.0.91; sh-mode indent misses on 'if test; then' when 'then' is on 'if' line
Date: Sun, 06 Feb 2022 19:11:23 -0500	[thread overview]
Message-ID: <jwvmtj3y204.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87y22n367a.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 07 Feb 2022 00:50:49 +0100")

> (defun sh-smie--default-backward-token ()
> [...]
>             (progn (skip-syntax-backward ".w_'")
>                    (or (not (zerop (skip-syntax-backward "\\")))
>                        (when (eq ?\\ (char-before (1- (point))))
>
> Semi-colons have punctuation syntax, so we're skipping back over the
> entirety of "test;then" instead of stopping after "then".

We should indeed only skip over "then", and then only over ";" and then
only over "test".

> This looks easy enough to fix, but the overall logic of that function is
> somewhat obscure to me, so I've added Stefan to the comments; perhaps he
> has some comments.

The sh syntax is fairly nasty to parse, especially backwards, so I can't
give you any general comment here.  I'd try something and then see if it
breaks any tests (including looking at test/manual/indent/shell.sh).

For sure, I'd recommend adding a regression test.


        Stefan






  reply	other threads:[~2022-02-07  0:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-06  4:37 bug#53817: 28.0.91; sh-mode indent misses on 'if test; then' when 'then' is on 'if' line Doug Maxey
2022-02-06 23:50 ` Lars Ingebrigtsen
2022-02-07  0:11   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-02-07  0:14     ` Doug Maxey
2022-02-07  8:16     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmtj3y204.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=53817@debbugs.gnu.org \
    --cc=emacs-bugs@maxeygroup.tech \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).