aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky2018-03-10 18:12:55 -0500
committerNoam Postavsky2019-11-28 18:10:07 -0500
commitb2790db049da98b541d07bac21ca7d7c220d3be0 (patch)
tree61aba17be4946bf84dc0dd57b1d7157b88725c83 /test
parent85f586f3ce5c6d9598d345440fd57e0fc9b8d98b (diff)
downloademacs-b2790db049da98b541d07bac21ca7d7c220d3be0.tar.gz
emacs-b2790db049da98b541d07bac21ca7d7c220d3be0.zip
Improve errors & warnings due to fancy quoted vars (Bug#32939)
Add some hints to the message for byte compiler free & unused variable warnings, and 'void-variable' errors where the variable has confusable quote characters in it. * lisp/help.el (uni-confusables), uni-confusables-regexp): New constants. (help-command-error-confusable-suggestions): New function, added to `command-error-function'. (help-uni-confusable-suggestions): New function. * lisp/emacs-lisp/bytecomp.el (byte-compile-variable-ref): * lisp/emacs-lisp/cconv.el (cconv--analyze-use): Use it. * lisp/emacs-lisp/lisp-mode.el (lisp--match-confusable-symbol-character): New function. (lisp-fdefs): Use it to fontify confusable characters with font-lock-warning-face when they occur in symbol names. * doc/lispref/modes.texi (Faces for Font Lock): * doc/lispref/objects.texi (Basic Char Syntax): Recommend backslash escaping of confusable characters, and mention new fontification. * etc/NEWS: Announce the new fontification behavior. * test/lisp/emacs-lisp/lisp-mode-tests.el (lisp-fontify-confusables): New test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/lisp-mode-tests.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el
index e4ba929ecbd..c0dd68c0a0b 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -20,6 +20,10 @@
20(require 'ert) 20(require 'ert)
21(require 'cl-lib) 21(require 'cl-lib)
22(require 'lisp-mode) 22(require 'lisp-mode)
23(require 'faceup)
24
25
26;;; Indentation
23 27
24(defconst lisp-mode-tests--correctly-indented-sexp "\ 28(defconst lisp-mode-tests--correctly-indented-sexp "\
25\(a 29\(a
@@ -290,5 +294,27 @@ Expected initialization file: `%s'\"
290 (insert "\"\n") 294 (insert "\"\n")
291 (lisp-indent-region (point-min) (point-max)))) 295 (lisp-indent-region (point-min) (point-max))))
292 296
297
298;;; Fontification
299
300(ert-deftest lisp-fontify-confusables ()
301 "Unescaped 'smart quotes' should be fontified in `font-lock-warning-face'."
302 (with-temp-buffer
303 (dolist (ch
304 '(#x2018 ;; LEFT SINGLE QUOTATION MARK
305 #x2019 ;; RIGHT SINGLE QUOTATION MARK
306 #x201B ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK
307 #x201C ;; LEFT DOUBLE QUOTATION MARK
308 #x201D ;; RIGHT DOUBLE QUOTATION MARK
309 #x201F ;; DOUBLE HIGH-REVERSED-9 QUOTATION MARK
310 #x301E ;; DOUBLE PRIME QUOTATION MARK
311 #xFF02 ;; FULLWIDTH QUOTATION MARK
312 #xFF07 ;; FULLWIDTH APOSTROPHE
313 ))
314 (insert (format "«w:%c»foo \\%cfoo\n" ch ch)))
315 (let ((faceup (buffer-string)))
316 (faceup-clean-buffer)
317 (should (faceup-test-font-lock-buffer 'emacs-lisp-mode faceup)))))
318
293(provide 'lisp-mode-tests) 319(provide 'lisp-mode-tests)
294;;; lisp-mode-tests.el ends here 320;;; lisp-mode-tests.el ends here