diff options
| author | Basil L. Contovounesios | 2020-12-27 14:21:50 +0000 |
|---|---|---|
| committer | Basil L. Contovounesios | 2021-01-10 13:37:38 +0000 |
| commit | 25dadca0d175aa7f9f1654314f90af64cdcb68fd (patch) | |
| tree | d8b5831f5d903520731ac130889440c859b3f3a7 | |
| parent | 4c55eeee39c05aa56df5ffdca6ff5b233607727c (diff) | |
| download | emacs-25dadca0d175aa7f9f1654314f90af64cdcb68fd.tar.gz emacs-25dadca0d175aa7f9f1654314f90af64cdcb68fd.zip | |
Hyperlink symbol names without word syntax in Help
* lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2)
(lisp-cl-font-lock-keywords-2): Allow single-character symbol names.
* lisp/help-mode.el (help-xref-symbol-regexp): Also match symbol
names starting with symbol syntax (bug#6601, bug#24309).
* test/lisp/help-mode-tests.el (help-mode-tests-xref-button): Test
hyperlink creation for function names without symbol syntax.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 6 | ||||
| -rw-r--r-- | lisp/help-mode.el | 3 | ||||
| -rw-r--r-- | test/lisp/help-mode-tests.el | 21 |
3 files changed, 16 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 1ae216c1a27..8780c5dcd30 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -456,8 +456,7 @@ This will generate compile-time constants from BINDINGS." | |||
| 456 | ("\\(\\\\\\)\\([^\"\\]\\)" | 456 | ("\\(\\\\\\)\\([^\"\\]\\)" |
| 457 | (1 (elisp--font-lock-backslash) prepend)) | 457 | (1 (elisp--font-lock-backslash) prepend)) |
| 458 | ;; Words inside ‘’ and `' tend to be symbol names. | 458 | ;; Words inside ‘’ and `' tend to be symbol names. |
| 459 | (,(concat "[`‘]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)" | 459 | (,(concat "[`‘]\\(" lisp-mode-symbol-regexp "\\)['’]") |
| 460 | lisp-mode-symbol-regexp "\\)['’]") | ||
| 461 | (1 font-lock-constant-face prepend)) | 460 | (1 font-lock-constant-face prepend)) |
| 462 | ;; Constant values. | 461 | ;; Constant values. |
| 463 | (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>") | 462 | (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>") |
| @@ -507,8 +506,7 @@ This will generate compile-time constants from BINDINGS." | |||
| 507 | (,(concat "(" cl-errs-re "\\_>") | 506 | (,(concat "(" cl-errs-re "\\_>") |
| 508 | (1 font-lock-warning-face)) | 507 | (1 font-lock-warning-face)) |
| 509 | ;; Words inside ‘’ and `' tend to be symbol names. | 508 | ;; Words inside ‘’ and `' tend to be symbol names. |
| 510 | (,(concat "[`‘]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)" | 509 | (,(concat "[`‘]\\(" lisp-mode-symbol-regexp "\\)['’]") |
| 511 | lisp-mode-symbol-regexp "\\)['’]") | ||
| 512 | (1 font-lock-constant-face prepend)) | 510 | (1 font-lock-constant-face prepend)) |
| 513 | ;; Uninterned symbols, e.g., (defpackage #:my-package ...) | 511 | ;; Uninterned symbols, e.g., (defpackage #:my-package ...) |
| 514 | ;; must come before keywords below to have effect | 512 | ;; must come before keywords below to have effect |
diff --git a/lisp/help-mode.el b/lisp/help-mode.el index cd08b2b2ba4..7043f12c9a3 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el | |||
| @@ -357,8 +357,7 @@ Commands: | |||
| 357 | "\\(symbol\\|program\\|property\\)\\|" ; Don't link | 357 | "\\(symbol\\|program\\|property\\)\\|" ; Don't link |
| 358 | "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)" | 358 | "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)" |
| 359 | "[ \t\n]+\\)?" | 359 | "[ \t\n]+\\)?" |
| 360 | ;; Note starting with word-syntax character: | 360 | "['`‘]\\(\\(?:\\sw\\|\\s_\\)+\\|`\\)['’]")) |
| 361 | "['`‘]\\(\\sw\\(\\sw\\|\\s_\\)+\\|`\\)['’]")) | ||
| 362 | "Regexp matching doc string references to symbols. | 361 | "Regexp matching doc string references to symbols. |
| 363 | 362 | ||
| 364 | The words preceding the quoted symbol can be used in doc strings to | 363 | The words preceding the quoted symbol can be used in doc strings to |
diff --git a/test/lisp/help-mode-tests.el b/test/lisp/help-mode-tests.el index e0e82c9cc1a..43db59d4b1b 100644 --- a/test/lisp/help-mode-tests.el +++ b/test/lisp/help-mode-tests.el | |||
| @@ -72,14 +72,19 @@ Lisp concepts such as car, cdr, cons cell and list.") | |||
| 72 | #'info))))) | 72 | #'info))))) |
| 73 | 73 | ||
| 74 | (ert-deftest help-mode-tests-xref-button () | 74 | (ert-deftest help-mode-tests-xref-button () |
| 75 | (with-temp-buffer | 75 | (let* ((fmt "See also the function ‘%s’.") |
| 76 | (insert "See also the function ‘interactive’.") | 76 | ;; 1+ translates string index to buffer position. |
| 77 | (string-match help-xref-symbol-regexp (buffer-string)) | 77 | (beg (1+ (string-search "%" fmt)))) |
| 78 | (help-xref-button 8 'help-function) | 78 | (with-temp-buffer |
| 79 | (should-not (button-at 22)) | 79 | (dolist (fn '(interactive \` = + - * / %)) |
| 80 | (should-not (button-at 35)) | 80 | (erase-buffer) |
| 81 | (let ((button (button-at 30))) | 81 | (insert (format fmt fn)) |
| 82 | (should (eq (button-type button) 'help-function))))) | 82 | (goto-char (point-min)) |
| 83 | (re-search-forward help-xref-symbol-regexp) | ||
| 84 | (help-xref-button 8 'help-function) | ||
| 85 | (should-not (button-at (1- beg))) | ||
| 86 | (should-not (button-at (+ beg (length (symbol-name fn))))) | ||
| 87 | (should (eq (button-type (button-at beg)) 'help-function)))))) | ||
| 83 | 88 | ||
| 84 | (ert-deftest help-mode-tests-insert-xref-button () | 89 | (ert-deftest help-mode-tests-insert-xref-button () |
| 85 | (with-temp-buffer | 90 | (with-temp-buffer |