diff options
| author | Stefan Monnier | 2014-09-02 20:38:49 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-09-02 20:38:49 -0400 |
| commit | e6769f18909edfd1bbf6473a1f754ab29e2fb114 (patch) | |
| tree | 4d706d90221fe672b6d0f4374cd4a71ca43c7b43 /lisp/progmodes | |
| parent | da25527e976176228c44f3c44499e0b402baad65 (diff) | |
| download | emacs-e6769f18909edfd1bbf6473a1f754ab29e2fb114.tar.gz emacs-e6769f18909edfd1bbf6473a1f754ab29e2fb114.zip | |
* lisp/progmodes/sh-script.el (sh-font-lock-quoted-subshell): Try to better
handle multiline elements.
Fixes: debbugs:18380
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/sh-script.el | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 3b0550dccca..5631358b472 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." | |||
| 1051 | "Search for a subshell embedded in a string. | 1051 | "Search for a subshell embedded in a string. |
| 1052 | Find all the unescaped \" characters within said subshell, remembering that | 1052 | Find all the unescaped \" characters within said subshell, remembering that |
| 1053 | subshells can nest." | 1053 | subshells can nest." |
| 1054 | ;; FIXME: This can (and often does) match multiple lines, yet it makes no | ||
| 1055 | ;; effort to handle multiline cases correctly, so it ends up being | ||
| 1056 | ;; rather flaky. | ||
| 1057 | (when (eq ?\" (nth 3 (syntax-ppss))) ; Check we matched an opening quote. | 1054 | (when (eq ?\" (nth 3 (syntax-ppss))) ; Check we matched an opening quote. |
| 1058 | ;; bingo we have a $( or a ` inside a "" | 1055 | ;; bingo we have a $( or a ` inside a "" |
| 1059 | (let (;; `state' can be: double-quote, backquote, code. | 1056 | (let (;; `state' can be: double-quote, backquote, code. |
| 1060 | (state (if (eq (char-before) ?`) 'backquote 'code)) | 1057 | (state (if (eq (char-before) ?`) 'backquote 'code)) |
| 1058 | (startpos (point)) | ||
| 1061 | ;; Stacked states in the context. | 1059 | ;; Stacked states in the context. |
| 1062 | (states '(double-quote))) | 1060 | (states '(double-quote))) |
| 1063 | (while (and state (progn (skip-chars-forward "^'\\\\\"`$()" limit) | 1061 | (while (and state (progn (skip-chars-forward "^'\\\\\"`$()" limit) |
| @@ -1088,7 +1086,12 @@ subshells can nest." | |||
| 1088 | (`double-quote nil) | 1086 | (`double-quote nil) |
| 1089 | (_ (setq state (pop states))))) | 1087 | (_ (setq state (pop states))))) |
| 1090 | (_ (error "Internal error in sh-font-lock-quoted-subshell"))) | 1088 | (_ (error "Internal error in sh-font-lock-quoted-subshell"))) |
| 1091 | (forward-char 1))))) | 1089 | (forward-char 1)) |
| 1090 | (when (< startpos (line-beginning-position)) | ||
| 1091 | (put-text-property startpos (point) 'syntax-multiline t) | ||
| 1092 | (add-hook 'syntax-propertize-extend-region-functions | ||
| 1093 | 'syntax-propertize-multiline nil t)) | ||
| 1094 | ))) | ||
| 1092 | 1095 | ||
| 1093 | 1096 | ||
| 1094 | (defun sh-is-quoted-p (pos) | 1097 | (defun sh-is-quoted-p (pos) |