all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Debugging SMIE for sh-script.el
@ 2021-09-02 10:49 Kévin Le Gouguec
  2021-09-02 12:07 ` Nikolay Kudryavtsev
  2021-09-02 19:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 23+ messages in thread
From: Kévin Le Gouguec @ 2021-09-02 10:49 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I am having a hard time understanding the mechanics of SMIE in the
context of sh-script.el; for starters, I am stumped trying to debug a
call to smie-indent-calculate.

Take this two-line shell snippet:

#+begin_src sh
${foo}/bar --baz \
      --quux
#+end_src

With point on "--quux", evaluate (smie-indent-calculate): this yields 6.
Looking at this function, I see that it simply funcalls everything in
smie-indent-functions, which in a shell buffer is
(sh-smie--indent-continuation t).

Instrumenting sh-smie--indent-continuation with C-M-x, I see that we
first go into the catch-all branch of the cond (";; Just make sure a
line-continuation is indented deeper."), which let-binds "indent" to:

#+begin_src elisp
(let ((sh-indent-after-continuation nil))
  (smie-indent-calculate))
#+end_src

Stepping through this recursive call with Edebug, I see that we go into
the first branch of sh-smie--indent-continuation's opening cond, which
returns nil.  Continuing into the parent call of
sh-smie--indent-continuation… "indent" is set to 6 for some reason??

I struggle to understand whether I am missing something, or whether this
binding is bogus.  On the one hand, run-hook-wrapped makes no promises
as to its return value when all functions return nil; on the other hand,
"indent" gets consistently assigned to whatever column "/bar" begins at
(e.g. 6 here, or 9 with "${foobar}/bar"), so there is a method to the
madness…

What am I missing?



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-09-12 17:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.