summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el10
-rw-r--r--lisp/emacs-lisp/cconv.el6
-rw-r--r--lisp/emacs-lisp/lisp-mode.el18
3 files changed, 29 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 905d99a5971..118356ec26a 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3428,7 +3428,10 @@ for symbols generated by the byte compiler itself."
(boundp var)
(memq var byte-compile-bound-variables)
(memq var byte-compile-free-references))
- (byte-compile-warn "reference to free variable `%S'" var)
+ (let* ((varname (prin1-to-string var))
+ (suggestions (help-uni-confusable-suggestions varname)))
+ (byte-compile-warn "reference to free variable `%s'%s" varname
+ (if suggestions (concat "\n " suggestions) "")))
(push var byte-compile-free-references))
(byte-compile-dynamic-variable-op 'byte-varref var))))
@@ -3444,7 +3447,10 @@ for symbols generated by the byte compiler itself."
(boundp var)
(memq var byte-compile-bound-variables)
(memq var byte-compile-free-assignments))
- (byte-compile-warn "assignment to free variable `%s'" var)
+ (let* ((varname (prin1-to-string var))
+ (suggestions (help-uni-confusable-suggestions varname)))
+ (byte-compile-warn "assignment to free variable `%s'%s" varname
+ (if suggestions (concat "\n " suggestions) "")))
(push var byte-compile-free-assignments))
(byte-compile-dynamic-variable-op 'byte-varset var))))
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index 58ca9d5f57e..09af7cb9104 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -591,8 +591,10 @@ FORM is the parent form that binds this var."
(eq ?_ (aref (symbol-name var) 0))
;; As a special exception, ignore "ignore".
(eq var 'ignored))
- (byte-compile-warn "Unused lexical %s `%S'"
- varkind var)))
+ (let ((suggestions (help-uni-confusable-suggestions (symbol-name var))))
+ (byte-compile-warn "Unused lexical %s `%S'%s"
+ varkind var
+ (if suggestions (concat "\n " suggestions) "")))))
;; If it's unused, there's no point converting it into a cons-cell, even if
;; it's captured and mutated.
(`(,binder ,_ t t ,_)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 5df52ebc98f..56f8ef63682 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -280,6 +280,19 @@ This will generate compile-time constants from BINDINGS."
`(face ,font-lock-warning-face
help-echo "This \\ has no effect"))))
+(defun lisp--match-confusable-symbol-character (limit)
+ ;; Match a confusable character within a Lisp symbol.
+ (catch 'matched
+ (while t
+ (if (re-search-forward uni-confusables-regexp limit t)
+ ;; Skip confusables which are backslash escaped, or inside
+ ;; strings or comments.
+ (save-match-data
+ (unless (or (eq (char-before (match-beginning 0)) ?\\)
+ (nth 8 (syntax-ppss)))
+ (throw 'matched t)))
+ (throw 'matched nil)))))
+
(let-when-compile
((lisp-fdefs '("defmacro" "defun"))
(lisp-vdefs '("defvar"))
@@ -463,7 +476,10 @@ This will generate compile-time constants from BINDINGS."
(3 'font-lock-regexp-grouping-construct prepend))
(lisp--match-hidden-arg
(0 '(face font-lock-warning-face
- help-echo "Hidden behind deeper element; move to another line?")))
+ help-echo "Hidden behind deeper element; move to another line?")))
+ (lisp--match-confusable-symbol-character
+ 0 '(face font-lock-warning-face
+ help-echo "Confusable character"))
))
"Gaudy level highlighting for Emacs Lisp mode.")