diff options
| author | Alan Mackenzie | 2015-09-12 08:54:44 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2015-09-14 09:46:39 +0000 |
| commit | e348a668cec6b49030aef5a1c48abd64a373645e (patch) | |
| tree | 5ee3871d02aa7a3d15f337473b00d1f4fa01eb8b | |
| parent | c387f5082380eb8242299d2864600d35ae5d0e8a (diff) | |
| download | emacs-e348a668cec6b49030aef5a1c48abd64a373645e.tar.gz emacs-e348a668cec6b49030aef5a1c48abd64a373645e.zip | |
Elisp mode: Make font-lock and imenu handle escaped characters in symbols
Fixes debbugs#21449.
lisp/emacs-lisp/lisp-mode.el (lisp-imenu-generic-expression)
(lisp--el-match-keyword, lisp-el-font-lock-keywords-1)
(lisp-cl-font-lock-keywords-1, lisp-el-font-lock-keywords-2)
(lisp-cl-font-lock-keywords-2, lisp-string-in-doc-position-p):
Insert "\\|\\\\." into regexps which match symbols.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 8aa34c7bef9..7be7cb341ca 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -110,7 +110,7 @@ | |||
| 110 | ;; CLOS and EIEIO | 110 | ;; CLOS and EIEIO |
| 111 | "defgeneric" "defmethod") | 111 | "defgeneric" "defmethod") |
| 112 | t)) | 112 | t)) |
| 113 | "\\s-+\\(\\(\\sw\\|\\s_\\)+\\)")) | 113 | "\\s-+\\(\\(\\sw\\|\\s_\\|\\\\.\\)+\\)")) |
| 114 | 2) | 114 | 2) |
| 115 | (list (purecopy "Variables") | 115 | (list (purecopy "Variables") |
| 116 | (purecopy (concat "^\\s-*(" | 116 | (purecopy (concat "^\\s-*(" |
| @@ -122,11 +122,11 @@ | |||
| 122 | "defconstant" | 122 | "defconstant" |
| 123 | "defparameter" "define-symbol-macro") | 123 | "defparameter" "define-symbol-macro") |
| 124 | t)) | 124 | t)) |
| 125 | "\\s-+\\(\\(\\sw\\|\\s_\\)+\\)")) | 125 | "\\s-+\\(\\(\\sw\\|\\s_\\|\\\\.\\)+\\)")) |
| 126 | 2) | 126 | 2) |
| 127 | ;; For `defvar', we ignore (defvar FOO) constructs. | 127 | ;; For `defvar', we ignore (defvar FOO) constructs. |
| 128 | (list (purecopy "Variables") | 128 | (list (purecopy "Variables") |
| 129 | (purecopy (concat "^\\s-*(defvar\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" | 129 | (purecopy (concat "^\\s-*(defvar\\s-+\\(\\(\\sw\\|\\s_\\|\\\\.\\)+\\)" |
| 130 | "[[:space:]\n]+[^)]")) | 130 | "[[:space:]\n]+[^)]")) |
| 131 | 1) | 131 | 1) |
| 132 | (list (purecopy "Types") | 132 | (list (purecopy "Types") |
| @@ -143,7 +143,7 @@ | |||
| 143 | ;; CLOS and EIEIO | 143 | ;; CLOS and EIEIO |
| 144 | "defclass") | 144 | "defclass") |
| 145 | t)) | 145 | t)) |
| 146 | "\\s-+'?\\(\\(\\sw\\|\\s_\\)+\\)")) | 146 | "\\s-+'?\\(\\(\\sw\\|\\s_\\|\\\\.\\)+\\)")) |
| 147 | 2)) | 147 | 2)) |
| 148 | 148 | ||
| 149 | "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.") | 149 | "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.") |
| @@ -220,7 +220,7 @@ | |||
| 220 | (defun lisp--el-match-keyword (limit) | 220 | (defun lisp--el-match-keyword (limit) |
| 221 | ;; FIXME: Move to elisp-mode.el. | 221 | ;; FIXME: Move to elisp-mode.el. |
| 222 | (catch 'found | 222 | (catch 'found |
| 223 | (while (re-search-forward "(\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>" limit t) | 223 | (while (re-search-forward "(\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)\\_>" limit t) |
| 224 | (let ((sym (intern-soft (match-string 1)))) | 224 | (let ((sym (intern-soft (match-string 1)))) |
| 225 | (when (or (special-form-p sym) | 225 | (when (or (special-form-p sym) |
| 226 | (and (macrop sym) | 226 | (and (macrop sym) |
| @@ -349,7 +349,7 @@ | |||
| 349 | ;; Any whitespace and defined object. | 349 | ;; Any whitespace and defined object. |
| 350 | "[ \t']*" | 350 | "[ \t']*" |
| 351 | "\\(([ \t']*\\)?" ;; An opening paren. | 351 | "\\(([ \t']*\\)?" ;; An opening paren. |
| 352 | "\\(\\(setf\\)[ \t]+\\(?:\\sw\\|\\s_\\)+\\|\\(?:\\sw\\|\\s_\\)+\\)?") | 352 | "\\(\\(setf\\)[ \t]+\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\|\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)?") |
| 353 | (1 font-lock-keyword-face) | 353 | (1 font-lock-keyword-face) |
| 354 | (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) | 354 | (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) |
| 355 | (cond ((eq type 'var) font-lock-variable-name-face) | 355 | (cond ((eq type 'var) font-lock-variable-name-face) |
| @@ -373,7 +373,7 @@ | |||
| 373 | ;; Any whitespace and defined object. | 373 | ;; Any whitespace and defined object. |
| 374 | "[ \t']*" | 374 | "[ \t']*" |
| 375 | "\\(([ \t']*\\)?" ;; An opening paren. | 375 | "\\(([ \t']*\\)?" ;; An opening paren. |
| 376 | "\\(\\(setf\\)[ \t]+\\(?:\\sw\\|\\s_\\)+\\|\\(?:\\sw\\|\\s_\\)+\\)?") | 376 | "\\(\\(setf\\)[ \t]+\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\|\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)?") |
| 377 | (1 font-lock-keyword-face) | 377 | (1 font-lock-keyword-face) |
| 378 | (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) | 378 | (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) |
| 379 | (cond ((eq type 'var) font-lock-variable-name-face) | 379 | (cond ((eq type 'var) font-lock-variable-name-face) |
| @@ -395,22 +395,22 @@ | |||
| 395 | (lisp--el-match-keyword . 1) | 395 | (lisp--el-match-keyword . 1) |
| 396 | ;; Exit/Feature symbols as constants. | 396 | ;; Exit/Feature symbols as constants. |
| 397 | (,(concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\_>" | 397 | (,(concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\_>" |
| 398 | "[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?") | 398 | "[ \t']*\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)?") |
| 399 | (1 font-lock-keyword-face) | 399 | (1 font-lock-keyword-face) |
| 400 | (2 font-lock-constant-face nil t)) | 400 | (2 font-lock-constant-face nil t)) |
| 401 | ;; Erroneous structures. | 401 | ;; Erroneous structures. |
| 402 | (,(concat "(" el-errs-re "\\_>") | 402 | (,(concat "(" el-errs-re "\\_>") |
| 403 | (1 font-lock-warning-face)) | 403 | (1 font-lock-warning-face)) |
| 404 | ;; Words inside \\[] tend to be for `substitute-command-keys'. | 404 | ;; Words inside \\[] tend to be for `substitute-command-keys'. |
| 405 | ("\\\\\\\\\\[\\(\\(?:\\sw\\|\\s_\\)+\\)\\]" | 405 | ("\\\\\\\\\\[\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)\\]" |
| 406 | (1 font-lock-constant-face prepend)) | 406 | (1 font-lock-constant-face prepend)) |
| 407 | ;; Words inside ‘’ and '' and `' tend to be symbol names. | 407 | ;; Words inside ‘’ and '' and `' tend to be symbol names. |
| 408 | ("['`‘]\\(\\(?:\\sw\\|\\s_\\)\\(?:\\sw\\|\\s_\\)+\\)['’]" | 408 | ("['`‘]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)['’]" |
| 409 | (1 font-lock-constant-face prepend)) | 409 | (1 font-lock-constant-face prepend)) |
| 410 | ;; Constant values. | 410 | ;; Constant values. |
| 411 | ("\\_<:\\(?:\\sw\\|\\s_\\)+\\_>" 0 font-lock-builtin-face) | 411 | ("\\_<:\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\_>" 0 font-lock-builtin-face) |
| 412 | ;; ELisp and CLisp `&' keywords as types. | 412 | ;; ELisp and CLisp `&' keywords as types. |
| 413 | ("\\_<\\&\\(?:\\sw\\|\\s_\\)+\\_>" . font-lock-type-face) | 413 | ("\\_<\\&\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\_>" . font-lock-type-face) |
| 414 | ;; ELisp regexp grouping constructs | 414 | ;; ELisp regexp grouping constructs |
| 415 | (,(lambda (bound) | 415 | (,(lambda (bound) |
| 416 | (catch 'found | 416 | (catch 'found |
| @@ -447,19 +447,19 @@ | |||
| 447 | (,(concat "(" cl-kws-re "\\_>") . 1) | 447 | (,(concat "(" cl-kws-re "\\_>") . 1) |
| 448 | ;; Exit/Feature symbols as constants. | 448 | ;; Exit/Feature symbols as constants. |
| 449 | (,(concat "(\\(catch\\|throw\\|provide\\|require\\)\\_>" | 449 | (,(concat "(\\(catch\\|throw\\|provide\\|require\\)\\_>" |
| 450 | "[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?") | 450 | "[ \t']*\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)?") |
| 451 | (1 font-lock-keyword-face) | 451 | (1 font-lock-keyword-face) |
| 452 | (2 font-lock-constant-face nil t)) | 452 | (2 font-lock-constant-face nil t)) |
| 453 | ;; Erroneous structures. | 453 | ;; Erroneous structures. |
| 454 | (,(concat "(" cl-errs-re "\\_>") | 454 | (,(concat "(" cl-errs-re "\\_>") |
| 455 | (1 font-lock-warning-face)) | 455 | (1 font-lock-warning-face)) |
| 456 | ;; Words inside ‘’ and '' and `' tend to be symbol names. | 456 | ;; Words inside ‘’ and '' and `' tend to be symbol names. |
| 457 | ("['`‘]\\(\\(?:\\sw\\|\\s_\\)\\(?:\\sw\\|\\s_\\)+\\)['’]" | 457 | ("['`‘]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)['’]" |
| 458 | (1 font-lock-constant-face prepend)) | 458 | (1 font-lock-constant-face prepend)) |
| 459 | ;; Constant values. | 459 | ;; Constant values. |
| 460 | ("\\_<:\\(?:\\sw\\|\\s_\\)+\\_>" 0 font-lock-builtin-face) | 460 | ("\\_<:\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\_>" 0 font-lock-builtin-face) |
| 461 | ;; ELisp and CLisp `&' keywords as types. | 461 | ;; ELisp and CLisp `&' keywords as types. |
| 462 | ("\\_<\\&\\(?:\\sw\\|\\s_\\)+\\_>" . font-lock-type-face) | 462 | ("\\_<\\&\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\_>" . font-lock-type-face) |
| 463 | ;; This is too general -- rms. | 463 | ;; This is too general -- rms. |
| 464 | ;; A user complained that he has functions whose names start with `do' | 464 | ;; A user complained that he has functions whose names start with `do' |
| 465 | ;; and that they get the wrong color. | 465 | ;; and that they get the wrong color. |
| @@ -482,7 +482,7 @@ | |||
| 482 | (let* ((firstsym (and listbeg | 482 | (let* ((firstsym (and listbeg |
| 483 | (save-excursion | 483 | (save-excursion |
| 484 | (goto-char listbeg) | 484 | (goto-char listbeg) |
| 485 | (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)") | 485 | (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\|\\\\.\\)+\\)") |
| 486 | (match-string 1))))) | 486 | (match-string 1))))) |
| 487 | (docelt (and firstsym | 487 | (docelt (and firstsym |
| 488 | (function-get (intern-soft firstsym) | 488 | (function-get (intern-soft firstsym) |