diff options
Diffstat (limited to 'lisp/progmodes/sh-script.el')
-rw-r--r-- | lisp/progmodes/sh-script.el | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 54da1e0468e..0cde1f387e0 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1042,7 +1042,9 @@ subshells can nest." ;; Maybe we've bumped into an escaped newline. (sh-is-quoted-p (point))) (backward-char 1)) - (when (eq (char-before) ?|) + (when (and + (eq (char-before) ?|) + (not (eq (char-before (1- (point))) ?\;))) (backward-char 1) t))) (and (> (point) (1+ (point-min))) (progn (backward-char 2) @@ -1053,7 +1055,7 @@ subshells can nest." ;; a normal command rather than the real `in' keyword. ;; I.e. we should look back to try and find the ;; corresponding `case'. - (and (looking-at ";[;&]\\|\\_<in") + (and (looking-at ";\\(?:;&?\\|[&|]\\)\\|\\_<in") ;; ";; esac )" is a case that looks ;; like a case-pattern but it's really just a close ;; paren after a case statement. I.e. if we skipped @@ -1628,6 +1630,10 @@ not written in Bash or sh." ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (setq-local treesit-defun-type-regexp "function_definition") (treesit-major-mode-setup))) @@ -1785,8 +1791,9 @@ before the newline and in that case point should be just before the token." (pattern (rpattern) ("case-(" rpattern)) (branches (branches ";;" branches) (branches ";&" branches) (branches ";;&" branches) ;bash. + (branches ";|" branches) ;zsh. (pattern "case-)" cmd))) - '((assoc ";;" ";&" ";;&")) + '((assoc ";;" ";&" ";;&" ";|")) '((assoc ";" "&") (assoc "&&" "||") (assoc "|" "|&"))))) (defconst sh-smie--sh-operators @@ -2011,7 +2018,7 @@ May return nil if the line should not be treated as continued." (forward-line -1) (if (sh-smie--looking-back-at-continuation-p) (current-indentation) - (+ (current-indentation) sh-basic-offset)))) + (+ (current-indentation) (sh-var-value 'sh-indent-for-continuation))))) (t ;; Just make sure a line-continuation is indented deeper. (save-excursion @@ -2032,7 +2039,10 @@ May return nil if the line should not be treated as continued." ;; check the line before that one. (> ci indent)) (t ;Previous line is the beginning of the continued line. - (setq indent (min (+ ci sh-basic-offset) max)) + (setq + indent + (min + (+ ci (sh-var-value 'sh-indent-for-continuation)) max)) nil))))) indent)))))) @@ -2056,11 +2066,11 @@ May return nil if the line should not be treated as continued." `(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 ";;" ";&" ";;&")) - (if (and (smie-rule-bolp) (looking-at ";;?&?[ \t]*\\(#\\|$\\)")) + (`(:before . ,(or ";;" ";&" ";;&" ";|")) + (if (and (smie-rule-bolp) (looking-at ";\\(?:;&?\\|[&|]\\)?[ \t]*\\(#\\|$\\)")) (cons 'column (smie-indent-keyword ";")) (smie-rule-separator kind))) - (`(:after . ,(or ";;" ";&" ";;&")) + (`(:after . ,(or ";;" ";&" ";;&" ";|")) (with-demoted-errors "SMIE rule error: %S" (smie-backward-sexp token) (cons 'column @@ -2149,8 +2159,9 @@ May return nil if the line should not be treated as continued." (pattern (pattern "|" pattern)) (branches (branches ";;" branches) (branches ";&" branches) (branches ";;&" branches) ;bash. + (branches ";|" branches) ;zsh. (pattern "case-)" cmd))) - '((assoc ";;" ";&" ";;&")) + '((assoc ";;" ";&" ";;&" ";|")) '((assoc "case") (assoc ";" "&") (assoc "&&" "||") (assoc "|" "|&"))))) (defun sh-smie--rc-after-special-arg-p () |