emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 46fcaf3: Improve last change


From: Stefan Monnier
Subject: [Emacs-diffs] master 46fcaf3: Improve last change
Date: Sat, 11 Mar 2017 16:36:30 -0500 (EST)

branch: master
commit 46fcaf3361b56306c288f2ddf4dd8a7dfab7ce2f
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    Improve last change
    
    * lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2):
    Use ppss to check escaping and add help-echo.
---
 lisp/emacs-lisp/lisp-mode.el | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 3ed0d06..c2f5f42 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -412,13 +412,17 @@ This will generate compile-time constants from BINDINGS."
          (,(concat "\\\\\\\\\\[\\(" lisp-mode-symbol-regexp "\\)\\]")
           (1 font-lock-constant-face prepend))
          ;; Ineffective backslashes (typically in need of doubling).
-         ("\\(?:[^\\]\\|^\\)\\(?:\\\\\\\\\\)*\\(\\(\\\\\\)\\([^\"\\]\\)\\)"
-          (2 (and (nth 3 (syntax-ppss))
-                  (equal (ignore-errors
-                           (car (read-from-string
-                                 (format "\"%s\"" (match-string 1)))))
-                         (match-string 3))
-                  font-lock-warning-face)
+         ("\\(\\\\\\)\\([^\"\\]\\)"
+          (1 (let ((ppss (save-excursion (syntax-ppss (match-beginning 0)))))
+               (and (nth 3 ppss)        ;Inside a string.
+                    (not (nth 5 ppss))  ;The \ is not itself \-escaped.
+                    (equal (ignore-errors
+                             (car (read-from-string
+                                   (format "\"%s\""
+                                           (match-string-no-properties 0)))))
+                           (match-string-no-properties 2))
+                    `(face ,font-lock-warning-face
+                           help-echo "This \\ has no effect")))
              prepend))
          ;; Words inside ‘’ and `' tend to be symbol names.
          (,(concat "[`‘]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]