unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Debugging SMIE for sh-script.el
Date: Sun, 05 Sep 2021 12:27:09 -0400	[thread overview]
Message-ID: <jwvsfyjatla.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 3b4cea5f-c08f-3307-655f-a43185ada5ee@gmail.com

> The proper solution IMHO should be changing sh-smie--indent-continuation to
> not rely on other functions to calculate indent. Something along the lines
> of going (smie-backward-sexp) until you get (smie-rule-bolp), this would get
> you to the start of the parent line and then you can base your indentation
> decisions on it.

I'm not sure which "other functions" you're thinking of (obviously
`smie-backward-sexp` and `smie-rule-bolp` aren't included in those
"other functions" that shouldn't be used ;-).

Note that if you start with the loop you describe (which corresponds to
the algorithm used by `smie-indent-exps`) you'll sooner or later
hit cases where the code needs to be refined a bit, as at some point
I think you'll realize that you're reimplementing the whole indentation
code and that you're probably better off calling `smie-indent-calculate`
recursively and call it a day ;-)

> Also note, that sh-mode separates default-backward\forward-token functions
> from the actual backward\forward-token functions, with the latter handling
> whatever special cases there are and the default functions just doing
> straight buffer reading.

The default-backward\forward-token functions are only meant as examples
to help get started (they're often good enough during the first
half-hour of fiddling with a new grammar to get a feel for what might
work).  The actual backward\forward-token functions don't need to
use them or to look like them.


        Stefan




  reply	other threads:[~2021-09-05 16:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02 10:49 Debugging SMIE for sh-script.el Kévin Le Gouguec
2021-09-02 12:07 ` Nikolay Kudryavtsev
2021-09-02 17:19   ` Kévin Le Gouguec
2021-09-02 18:09     ` Nikolay Kudryavtsev
2021-09-02 20:29       ` Kévin Le Gouguec
2021-09-02 19:50   ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-09-02 21:37     ` Kévin Le Gouguec
2021-09-02 23:54       ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-09-03  7:09         ` Kévin Le Gouguec
2021-09-03 12:12           ` Stefan Monnier
2021-09-05 15:48       ` Nikolay Kudryavtsev
2021-09-05 16:27         ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
2021-09-05 16:41           ` Nikolay Kudryavtsev
2021-09-05 17:23             ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-09-05 18:01               ` Nikolay Kudryavtsev
2021-09-05 23:02                 ` Stefan Monnier
2021-09-06 12:47                   ` Nikolay Kudryavtsev
2021-09-06 14:01                     ` Stefan Monnier
2021-09-06 17:24                       ` Nikolay Kudryavtsev
2021-09-06 20:23                         ` Stefan Monnier
2021-09-12 17:40                         ` Kévin Le Gouguec
2021-09-02 19:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-09-02 20:39   ` Kévin Le Gouguec

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=jwvsfyjatla.fsf-monnier+emacs@gnu.org \
    --to=help-gnu-emacs@gnu.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.
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).