* lisp/progmodes/sh-script.el (sh-smie-sh-rules): Tweak indent of new for
The new `for (TEST) { BODY }` syntax introduces various challenges. This patch just fixes a trivial subcase.
This commit is contained in:
parent
046db04e3d
commit
a572b21928
2 changed files with 17 additions and 4 deletions
|
@ -1957,12 +1957,18 @@ May return nil if the line should not be treated as continued."
|
|||
('(:after . "case-)") (- (sh-var-value 'sh-indent-for-case-alt)
|
||||
(sh-var-value 'sh-indent-for-case-label)))
|
||||
(`(:before . ,(or "(" "{" "[" "while" "if" "for" "case"))
|
||||
(if (not (smie-rule-prev-p "&&" "||" "|"))
|
||||
(when (smie-rule-hanging-p)
|
||||
(smie-rule-parent))
|
||||
(cond
|
||||
((and (equal token "{") (smie-rule-parent-p "for"))
|
||||
(let ((data (smie-backward-sexp "in")))
|
||||
(when (equal (nth 2 data) "for")
|
||||
`(column . ,(smie-indent-virtual)))))
|
||||
((not (smie-rule-prev-p "&&" "||" "|"))
|
||||
(when (smie-rule-hanging-p)
|
||||
(smie-rule-parent)))
|
||||
(t
|
||||
(unless (smie-rule-bolp)
|
||||
(while (equal "|" (nth 2 (smie-backward-sexp 'halfexp))))
|
||||
`(column . ,(smie-indent-virtual)))))
|
||||
`(column . ,(smie-indent-virtual))))))
|
||||
;; FIXME: Maybe this handling of ;; should be made into
|
||||
;; a smie-rule-terminator function that takes the substitute ";" as arg.
|
||||
(`(:before . ,(or ";;" ";&" ";;&"))
|
||||
|
|
|
@ -6,6 +6,13 @@ setlock -n /tmp/getmail.lock && echo getmail isn\'t running
|
|||
toto=$(grep hello foo |
|
||||
wc)
|
||||
|
||||
myfun () {
|
||||
for ((it=0; it<${limit}; ++it))
|
||||
{
|
||||
echo "whatever $it"
|
||||
}
|
||||
}
|
||||
|
||||
# adsgsdg
|
||||
|
||||
if foo; then
|
||||
|
|
Loading…
Add table
Reference in a new issue