emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 4086d85: Highlight useless backslashes in Elisp str


From: Stefan Monnier
Subject: [Emacs-diffs] master 4086d85: Highlight useless backslashes in Elisp strings
Date: Sat, 11 Mar 2017 11:35:21 -0500 (EST)

branch: master
commit 4086d850dc02c95615095adddd1e798377f03cec
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    Highlight useless backslashes in Elisp strings
    
    * lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2):
    Put warning face on backslashes that have no effect.
---
 lisp/emacs-lisp/lisp-mode.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index d720e0b..3ed0d06 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -411,6 +411,15 @@ This will generate compile-time constants from BINDINGS."
          ;; Words inside \\[] tend to be for `substitute-command-keys'.
          (,(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)
+             prepend))
          ;; Words inside ‘’ and `' tend to be symbol names.
          (,(concat "[`‘]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)"
                    lisp-mode-symbol-regexp "\\)['’]")



reply via email to

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