diff options
| author | Noam Postavsky | 2019-12-13 06:36:02 -0500 |
|---|---|---|
| committer | Noam Postavsky | 2019-12-13 06:41:05 -0500 |
| commit | 966abdba09214813a86979f22bfb08475a73f10c (patch) | |
| tree | f48c52b9796f38fa374a392d6f2021e9bcb23442 | |
| parent | dd3f2130cf2977cff79101e72cff0b433df1c1c6 (diff) | |
| download | emacs-966abdba09214813a86979f22bfb08475a73f10c.tar.gz emacs-966abdba09214813a86979f22bfb08475a73f10c.zip | |
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.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 2 | ||||
| -rw-r--r-- | lisp/help.el | 25 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 56f8ef63682..1da2b794317 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -284,7 +284,7 @@ This will generate compile-time constants from BINDINGS." | |||
| 284 | ;; Match a confusable character within a Lisp symbol. | 284 | ;; Match a confusable character within a Lisp symbol. |
| 285 | (catch 'matched | 285 | (catch 'matched |
| 286 | (while t | 286 | (while t |
| 287 | (if (re-search-forward uni-confusables-regexp limit t) | 287 | (if (re-search-forward help-uni-confusables-regexp limit t) |
| 288 | ;; Skip confusables which are backslash escaped, or inside | 288 | ;; Skip confusables which are backslash escaped, or inside |
| 289 | ;; strings or comments. | 289 | ;; strings or comments. |
| 290 | (save-match-data | 290 | (save-match-data |
diff --git a/lisp/help.el b/lisp/help.el index 8bb942abf4f..857064cdda2 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -1511,7 +1511,7 @@ the same names as used in the original source code, when possible." | |||
| 1511 | 1511 | ||
| 1512 | ;; Just some quote-like characters for now. TODO: generate this stuff | 1512 | ;; Just some quote-like characters for now. TODO: generate this stuff |
| 1513 | ;; from official Unicode data. | 1513 | ;; from official Unicode data. |
| 1514 | (defconst uni-confusables | 1514 | (defconst help-uni-confusables |
| 1515 | '((#x2018 . "'") ;; LEFT SINGLE QUOTATION MARK | 1515 | '((#x2018 . "'") ;; LEFT SINGLE QUOTATION MARK |
| 1516 | (#x2019 . "'") ;; RIGHT SINGLE QUOTATION MARK | 1516 | (#x2019 . "'") ;; RIGHT SINGLE QUOTATION MARK |
| 1517 | (#x201B . "'") ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK | 1517 | (#x201B . "'") ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK |
| @@ -1521,25 +1521,32 @@ the same names as used in the original source code, when possible." | |||
| 1521 | (#x301E . "\"") ;; DOUBLE PRIME QUOTATION MARK | 1521 | (#x301E . "\"") ;; DOUBLE PRIME QUOTATION MARK |
| 1522 | (#xFF02 . "'") ;; FULLWIDTH QUOTATION MARK | 1522 | (#xFF02 . "'") ;; FULLWIDTH QUOTATION MARK |
| 1523 | (#xFF07 . "'") ;; FULLWIDTH APOSTROPHE | 1523 | (#xFF07 . "'") ;; FULLWIDTH APOSTROPHE |
| 1524 | )) | 1524 | ) |
| 1525 | "An alist of confusable characters to give hints about. | ||
| 1526 | Each alist element is of the form (CHAR . REPLACEMENT), where | ||
| 1527 | CHAR is the potentially confusable character, and REPLACEMENT is | ||
| 1528 | the suggested string to use instead. See | ||
| 1529 | `help-uni-confusable-suggestions'.") | ||
| 1525 | 1530 | ||
| 1526 | (defconst uni-confusables-regexp | 1531 | (defconst help-uni-confusables-regexp |
| 1527 | (concat "[" (mapcar #'car uni-confusables) "]")) | 1532 | (concat "[" (mapcar #'car help-uni-confusables) "]") |
| 1533 | "Regexp matching any character listed in `help-uni-confusables'.") | ||
| 1528 | 1534 | ||
| 1529 | (defun help-uni-confusable-suggestions (string) | 1535 | (defun help-uni-confusable-suggestions (string) |
| 1530 | "Return a message describing confusables in STRING." | 1536 | "Return a message describing confusables in STRING." |
| 1531 | (let ((i 0) | 1537 | (let ((i 0) |
| 1532 | (confusables nil)) | 1538 | (confusables nil)) |
| 1533 | (while (setq i (string-match uni-confusables-regexp string i)) | 1539 | (while (setq i (string-match help-uni-confusables-regexp string i)) |
| 1534 | (let ((replacement (alist-get (aref string i) uni-confusables))) | 1540 | (let ((replacement (alist-get (aref string i) help-uni-confusables))) |
| 1535 | (push (aref string i) confusables) | 1541 | (push (aref string i) confusables) |
| 1536 | (setq string (replace-match replacement t t string)) | 1542 | (setq string (replace-match replacement t t string)) |
| 1537 | (setq i (+ i (length replacement))))) | 1543 | (setq i (+ i (length replacement))))) |
| 1538 | (when confusables | 1544 | (when confusables |
| 1539 | (format-message | 1545 | (format-message |
| 1540 | (if (> (length confusables) 1) | 1546 | (ngettext |
| 1541 | "Found confusable characters: %s; perhaps you meant: `%s'?" | 1547 | "Found confusable character: %s, perhaps you meant: `%s'?" |
| 1542 | "Found confusable character: %s, perhaps you meant: `%s'?") | 1548 | "Found confusable characters: %s; perhaps you meant: `%s'?" |
| 1549 | (length confusables)) | ||
| 1543 | (mapconcat (lambda (c) (format-message "`%c'" c)) | 1550 | (mapconcat (lambda (c) (format-message "`%c'" c)) |
| 1544 | confusables ", ") | 1551 | confusables ", ") |
| 1545 | string)))) | 1552 | string)))) |