aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-06-11 22:16:43 +0000
committerStefan Monnier2007-06-11 22:16:43 +0000
commit935e6b79826c7b581aa131bb0ff81afc591ab746 (patch)
tree292303f1640c0e46156b41ce1e7637524a58e411
parentb4879b4331e5b51d40e0d144fbe3f7570047f838 (diff)
downloademacs-935e6b79826c7b581aa131bb0ff81afc591ab746.tar.gz
emacs-935e6b79826c7b581aa131bb0ff81afc591ab746.zip
(sh-font-lock-backslash-quote, sh-font-lock-flush-syntax-ppss-cache): New funs.
(sh-font-lock-syntactic-keywords): Use them to distinguish the different possible cases for \'.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/sh-script.el21
2 files changed, 24 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c9b2e0adecf..b1c70ed39de 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12007-06-11 Stefan Monnier <monnier@iro.umontreal.ca> 12007-06-11 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/sh-script.el (sh-font-lock-backslash-quote)
4 (sh-font-lock-flush-syntax-ppss-cache): New functions.
5 (sh-font-lock-syntactic-keywords): Use them to distinguish the
6 different possible cases for \'.
7
3 * complete.el (PC-bindings): Don't bind things already bound in the 8 * complete.el (PC-bindings): Don't bind things already bound in the
4 parent keymap. 9 parent keymap.
5 10
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 60fc4c43e7b..56b16eb3638 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -884,7 +884,7 @@ See `sh-feature'.")
884(defconst sh-here-doc-syntax (string-to-syntax "|")) ;; generic string 884(defconst sh-here-doc-syntax (string-to-syntax "|")) ;; generic string
885 885
886(defconst sh-escaped-line-re 886(defconst sh-escaped-line-re
887 ;; Should match until the real end-of-continued line, but if that is not 887 ;; Should match until the real end-of-continued-line, but if that is not
888 ;; possible (because we bump into EOB or the search bound), then we should 888 ;; possible (because we bump into EOB or the search bound), then we should
889 ;; match until the search bound. 889 ;; match until the search bound.
890 "\\(?:\\(?:.*[^\\\n]\\)?\\(?:\\\\\\\\\\)*\\\\\n\\)*.*") 890 "\\(?:\\(?:.*[^\\\n]\\)?\\(?:\\\\\\\\\\)*\\\\\n\\)*.*")
@@ -1062,6 +1062,19 @@ subshells can nest."
1062 (when (save-excursion (backward-char 2) (looking-at ";;\\|in")) 1062 (when (save-excursion (backward-char 2) (looking-at ";;\\|in"))
1063 sh-st-punc))) 1063 sh-st-punc)))
1064 1064
1065(defun sh-font-lock-backslash-quote ()
1066 (if (eq (save-excursion (nth 3 (syntax-ppss (match-beginning 0)))) ?\')
1067 ;; In a '...' the backslash is not escaping.
1068 sh-st-punc
1069 nil))
1070
1071(defun sh-font-lock-flush-syntax-ppss-cache (limit)
1072 ;; This should probably be a standard function provided by font-lock.el
1073 ;; (or syntax.el).
1074 (syntax-ppss-flush-cache (point))
1075 (goto-char limit)
1076 nil)
1077
1065(defun sh-apply-quoted-subshell () 1078(defun sh-apply-quoted-subshell ()
1066 "Apply the `sh-st-punc' syntax to all the matches in `match-data'. 1079 "Apply the `sh-st-punc' syntax to all the matches in `match-data'.
1067This is used to flag quote characters in subshell constructs inside strings 1080This is used to flag quote characters in subshell constructs inside strings
@@ -1080,7 +1093,11 @@ This is used to flag quote characters in subshell constructs inside strings
1080 ;; of the shell command language (under `quoting') but with `$' removed. 1093 ;; of the shell command language (under `quoting') but with `$' removed.
1081 `(("[^|&;<>()`\\\"' \t\n]\\(#+\\)" 1 ,sh-st-symbol) 1094 `(("[^|&;<>()`\\\"' \t\n]\\(#+\\)" 1 ,sh-st-symbol)
1082 ;; In a '...' the backslash is not escaping. 1095 ;; In a '...' the backslash is not escaping.
1083 ("\\(\\\\\\)'" 1 ,sh-st-punc) 1096 ("\\(\\\\\\)'" (1 (sh-font-lock-backslash-quote)))
1097 ;; The previous rule uses syntax-ppss, but the subsequent rules may
1098 ;; change the syntax, so we have to tell syntax-ppss that the states it
1099 ;; has just computed will need to be recomputed.
1100 (sh-font-lock-flush-syntax-ppss-cache)
1084 ;; Make sure $@ and @? are correctly recognized as sexps. 1101 ;; Make sure $@ and @? are correctly recognized as sexps.
1085 ("\\$\\([?@]\\)" 1 ,sh-st-symbol) 1102 ("\\$\\([?@]\\)" 1 ,sh-st-symbol)
1086 ;; Find HEREDOC starters and add a corresponding rule for the ender. 1103 ;; Find HEREDOC starters and add a corresponding rule for the ender.