diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2021-01-26 17:57:26 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2021-01-26 17:58:42 -0500 |
commit | a572b21928a33b7ede445769bde5a67356327fef (patch) | |
tree | 2c3b1b544f6f588abef39662f8b50815b2ee6dd6 /lisp/progmodes | |
parent | 046db04e3da4afa7c6eb05af8c7ceb048689521a (diff) | |
download | emacs-a572b21928a33b7ede445769bde5a67356327fef.tar.gz |
* 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.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/sh-script.el | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index cc045a1b2d1..fd689527676 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -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 ";;" ";&" ";;&")) |