]> git.eshelyaron.com Git - emacs.git/commitdiff
(sh-font-lock-backslash-quote, sh-font-lock-flush-syntax-ppss-cache): New funs.
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 11 Jun 2007 22:16:43 +0000 (22:16 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 11 Jun 2007 22:16:43 +0000 (22:16 +0000)
(sh-font-lock-syntactic-keywords): Use them to distinguish the
different possible cases for \'.

lisp/ChangeLog
lisp/progmodes/sh-script.el

index c9b2e0adecf8317387c131eee3422e08813a2bbc..b1c70ed39de118900dc7f21ef2106a10dd80ec0f 100644 (file)
@@ -1,5 +1,10 @@
 2007-06-11  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * progmodes/sh-script.el (sh-font-lock-backslash-quote)
+       (sh-font-lock-flush-syntax-ppss-cache): New functions.
+       (sh-font-lock-syntactic-keywords): Use them to distinguish the
+       different possible cases for \'.
+
        * complete.el (PC-bindings): Don't bind things already bound in the
        parent keymap.
 
index 60fc4c43e7bd81d62def70f0dd64d4a0a109cc52..56b16eb3638a6011cb460ccb67ce03b239071f7f 100644 (file)
@@ -884,7 +884,7 @@ See `sh-feature'.")
 (defconst sh-here-doc-syntax (string-to-syntax "|")) ;; generic string
 
 (defconst sh-escaped-line-re
-  ;; Should match until the real end-of-continued line, but if that is not
+  ;; Should match until the real end-of-continued-line, but if that is not
   ;; possible (because we bump into EOB or the search bound), then we should
   ;; match until the search bound.
   "\\(?:\\(?:.*[^\\\n]\\)?\\(?:\\\\\\\\\\)*\\\\\n\\)*.*")
@@ -1062,6 +1062,19 @@ subshells can nest."
     (when (save-excursion (backward-char 2) (looking-at ";;\\|in"))
       sh-st-punc)))
 
+(defun sh-font-lock-backslash-quote ()
+  (if (eq (save-excursion (nth 3 (syntax-ppss (match-beginning 0)))) ?\')
+      ;; In a '...' the backslash is not escaping.
+      sh-st-punc
+    nil))
+
+(defun sh-font-lock-flush-syntax-ppss-cache (limit)
+  ;; This should probably be a standard function provided by font-lock.el
+  ;; (or syntax.el).
+  (syntax-ppss-flush-cache (point))
+  (goto-char limit)
+  nil)
+
 (defun sh-apply-quoted-subshell ()
   "Apply the `sh-st-punc' syntax to all the matches in `match-data'.
 This 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
   ;; of the shell command language (under `quoting') but with `$' removed.
   `(("[^|&;<>()`\\\"' \t\n]\\(#+\\)" 1 ,sh-st-symbol)
     ;; In a '...' the backslash is not escaping.
-    ("\\(\\\\\\)'" 1 ,sh-st-punc)
+    ("\\(\\\\\\)'" (1 (sh-font-lock-backslash-quote)))
+    ;; The previous rule uses syntax-ppss, but the subsequent rules may
+    ;; change the syntax, so we have to tell syntax-ppss that the states it
+    ;; has just computed will need to be recomputed.
+    (sh-font-lock-flush-syntax-ppss-cache)
     ;; Make sure $@ and @? are correctly recognized as sexps.
     ("\\$\\([?@]\\)" 1 ,sh-st-symbol)
     ;; Find HEREDOC starters and add a corresponding rule for the ender.