[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Debugging SMIE for sh-script.el

From: Kévin Le Gouguec
Subject: Debugging SMIE for sh-script.el
Date: Thu, 02 Sep 2021 12:49:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)


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 \

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))

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

What am I missing?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]