X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/bb16bffbd20705fcfbbb17189f20b838eaf7d31e..411c1c65313aa4e22730ba9762e073881f4e299a:/lisp/progmodes/sh-script.el diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 3b0550dccc..904e9dfc28 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1051,13 +1051,11 @@ Point is at the beginning of the next line." "Search for a subshell embedded in a string. Find all the unescaped \" characters within said subshell, remembering that subshells can nest." - ;; FIXME: This can (and often does) match multiple lines, yet it makes no - ;; effort to handle multiline cases correctly, so it ends up being - ;; rather flaky. (when (eq ?\" (nth 3 (syntax-ppss))) ; Check we matched an opening quote. ;; bingo we have a $( or a ` inside a "" (let (;; `state' can be: double-quote, backquote, code. (state (if (eq (char-before) ?`) 'backquote 'code)) + (startpos (point)) ;; Stacked states in the context. (states '(double-quote))) (while (and state (progn (skip-chars-forward "^'\\\\\"`$()" limit) @@ -1088,7 +1086,12 @@ subshells can nest." (`double-quote nil) (_ (setq state (pop states))))) (_ (error "Internal error in sh-font-lock-quoted-subshell"))) - (forward-char 1))))) + (forward-char 1)) + (when (< startpos (line-beginning-position)) + (put-text-property startpos (point) 'syntax-multiline t) + (add-hook 'syntax-propertize-extend-region-functions + 'syntax-propertize-multiline nil t)) + ))) (defun sh-is-quoted-p (pos) @@ -2011,12 +2014,12 @@ May return nil if the line should not be treated as continued." (and (numberp indent) (numberp initial) (<= indent initial))))) `(column . ,(+ initial sh-indentation))) - (`(:before . ,(or `"(" `"{" `"[")) + (`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case")) (if (not (smie-rule-prev-p "&&" "||" "|")) (when (smie-rule-hanging-p) (smie-rule-parent)) (unless (smie-rule-bolp) - (smie-backward-sexp 'halfexp) + (while (equal "|" (nth 2 (smie-backward-sexp 'halfexp)))) `(column . ,(smie-indent-virtual))))) ;; FIXME: Maybe this handling of ;; should be made into ;; a smie-rule-terminator function that takes the substitute ";" as arg. @@ -2371,7 +2374,7 @@ Calls the value of `sh-set-shell-hook' if set." (sh-make-vars-local)) (message "Indentation setup for shell type %s" sh-shell)) (message "No indentation for this shell type.") - (setq indent-line-function 'sh-basic-indent-line)) + (setq-local indent-line-function 'sh-basic-indent-line)) (when font-lock-mode (setq font-lock-set-defaults nil) (font-lock-set-defaults)