aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2015-06-09 22:10:38 -0400
committerStefan Monnier2015-06-09 22:10:38 -0400
commit06193432f2c38811a4be075274bb5be014f9b594 (patch)
treeed22a002bb71e1149df785f4cc3be114a37ef27d
parent26a17f5ac9b5b996cb1598607441b3e29be8e00b (diff)
downloademacs-06193432f2c38811a4be075274bb5be014f9b594.tar.gz
emacs-06193432f2c38811a4be075274bb5be014f9b594.zip
* lisp/progmodes/sh-script.el: Better handle nested quotes
(sh-here-doc-open-re): Don't mis-match the <<< operator (bug#20683). (sh-font-lock-quoted-subshell): Make sure double quotes within single quotes don't mistakenly end prematurely the surrounding string.
-rw-r--r--lisp/progmodes/sh-script.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 537b180eed6..6709e751ecd 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -987,7 +987,7 @@ See `sh-feature'.")
987 "\\(?:\\(?:.*[^\\\n]\\)?\\(?:\\\\\\\\\\)*\\\\\n\\)*.*") 987 "\\(?:\\(?:.*[^\\\n]\\)?\\(?:\\\\\\\\\\)*\\\\\n\\)*.*")
988 988
989 (defconst sh-here-doc-open-re 989 (defconst sh-here-doc-open-re
990 (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)" 990 (concat "[^<]<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)"
991 sh-escaped-line-re "\\(\n\\)"))) 991 sh-escaped-line-re "\\(\n\\)")))
992 992
993(defun sh--inside-noncommand-expression (pos) 993(defun sh--inside-noncommand-expression (pos)
@@ -1064,7 +1064,16 @@ subshells can nest."
1064 (pcase (char-after) 1064 (pcase (char-after)
1065 (?\' (pcase state 1065 (?\' (pcase state
1066 (`double-quote nil) 1066 (`double-quote nil)
1067 (_ (forward-char 1) (skip-chars-forward "^'" limit)))) 1067 (_ (forward-char 1)
1068 ;; FIXME: mark skipped double quotes as punctuation syntax.
1069 (let ((spos (point)))
1070 (skip-chars-forward "^'" limit)
1071 (save-excursion
1072 (let ((epos (point)))
1073 (goto-char spos)
1074 (while (search-forward "\"" epos t)
1075 (put-text-property (point) (1- (point))
1076 'syntax-table '(1)))))))))
1068 (?\\ (forward-char 1)) 1077 (?\\ (forward-char 1))
1069 (?\" (pcase state 1078 (?\" (pcase state
1070 (`double-quote (setq state (pop states))) 1079 (`double-quote (setq state (pop states)))