Add prefix to help.el uni-confusable* vars
* lisp/help.el (help-uni-confusables, help-uni-confusables-regexp): Rename from uni-confusable and uni-confusables-regexp, respectively. (help-uni-confusable-suggestions): Use ngettext. Use new variable name. * lisp/emacs-lisp/lisp-mode.el (lisp--match-confusable-symbol-character): Use new variable name.
This commit is contained in:
parent
dd3f2130cf
commit
966abdba09
2 changed files with 17 additions and 10 deletions
|
@ -284,7 +284,7 @@ This will generate compile-time constants from BINDINGS."
|
||||||
;; Match a confusable character within a Lisp symbol.
|
;; Match a confusable character within a Lisp symbol.
|
||||||
(catch 'matched
|
(catch 'matched
|
||||||
(while t
|
(while t
|
||||||
(if (re-search-forward uni-confusables-regexp limit t)
|
(if (re-search-forward help-uni-confusables-regexp limit t)
|
||||||
;; Skip confusables which are backslash escaped, or inside
|
;; Skip confusables which are backslash escaped, or inside
|
||||||
;; strings or comments.
|
;; strings or comments.
|
||||||
(save-match-data
|
(save-match-data
|
||||||
|
|
23
lisp/help.el
23
lisp/help.el
|
@ -1511,7 +1511,7 @@ the same names as used in the original source code, when possible."
|
||||||
|
|
||||||
;; Just some quote-like characters for now. TODO: generate this stuff
|
;; Just some quote-like characters for now. TODO: generate this stuff
|
||||||
;; from official Unicode data.
|
;; from official Unicode data.
|
||||||
(defconst uni-confusables
|
(defconst help-uni-confusables
|
||||||
'((#x2018 . "'") ;; LEFT SINGLE QUOTATION MARK
|
'((#x2018 . "'") ;; LEFT SINGLE QUOTATION MARK
|
||||||
(#x2019 . "'") ;; RIGHT SINGLE QUOTATION MARK
|
(#x2019 . "'") ;; RIGHT SINGLE QUOTATION MARK
|
||||||
(#x201B . "'") ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK
|
(#x201B . "'") ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK
|
||||||
|
@ -1521,25 +1521,32 @@ the same names as used in the original source code, when possible."
|
||||||
(#x301E . "\"") ;; DOUBLE PRIME QUOTATION MARK
|
(#x301E . "\"") ;; DOUBLE PRIME QUOTATION MARK
|
||||||
(#xFF02 . "'") ;; FULLWIDTH QUOTATION MARK
|
(#xFF02 . "'") ;; FULLWIDTH QUOTATION MARK
|
||||||
(#xFF07 . "'") ;; FULLWIDTH APOSTROPHE
|
(#xFF07 . "'") ;; FULLWIDTH APOSTROPHE
|
||||||
))
|
)
|
||||||
|
"An alist of confusable characters to give hints about.
|
||||||
|
Each alist element is of the form (CHAR . REPLACEMENT), where
|
||||||
|
CHAR is the potentially confusable character, and REPLACEMENT is
|
||||||
|
the suggested string to use instead. See
|
||||||
|
`help-uni-confusable-suggestions'.")
|
||||||
|
|
||||||
(defconst uni-confusables-regexp
|
(defconst help-uni-confusables-regexp
|
||||||
(concat "[" (mapcar #'car uni-confusables) "]"))
|
(concat "[" (mapcar #'car help-uni-confusables) "]")
|
||||||
|
"Regexp matching any character listed in `help-uni-confusables'.")
|
||||||
|
|
||||||
(defun help-uni-confusable-suggestions (string)
|
(defun help-uni-confusable-suggestions (string)
|
||||||
"Return a message describing confusables in STRING."
|
"Return a message describing confusables in STRING."
|
||||||
(let ((i 0)
|
(let ((i 0)
|
||||||
(confusables nil))
|
(confusables nil))
|
||||||
(while (setq i (string-match uni-confusables-regexp string i))
|
(while (setq i (string-match help-uni-confusables-regexp string i))
|
||||||
(let ((replacement (alist-get (aref string i) uni-confusables)))
|
(let ((replacement (alist-get (aref string i) help-uni-confusables)))
|
||||||
(push (aref string i) confusables)
|
(push (aref string i) confusables)
|
||||||
(setq string (replace-match replacement t t string))
|
(setq string (replace-match replacement t t string))
|
||||||
(setq i (+ i (length replacement)))))
|
(setq i (+ i (length replacement)))))
|
||||||
(when confusables
|
(when confusables
|
||||||
(format-message
|
(format-message
|
||||||
(if (> (length confusables) 1)
|
(ngettext
|
||||||
|
"Found confusable character: %s, perhaps you meant: `%s'?"
|
||||||
"Found confusable characters: %s; perhaps you meant: `%s'?"
|
"Found confusable characters: %s; perhaps you meant: `%s'?"
|
||||||
"Found confusable character: %s, perhaps you meant: `%s'?")
|
(length confusables))
|
||||||
(mapconcat (lambda (c) (format-message "`%c'" c))
|
(mapconcat (lambda (c) (format-message "`%c'" c))
|
||||||
confusables ", ")
|
confusables ", ")
|
||||||
string))))
|
string))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue