Get fewer false positives for :keyword and &options
* lisp/emacs-lisp/lisp-mode.el (lisp-mode--search-key): New function to check more carefully for start of :keywords and &options (bug#51574). (lisp-fdefs): Use it.
This commit is contained in:
parent
e5de29aa47
commit
a498e5f830
1 changed files with 21 additions and 6 deletions
|
@ -325,6 +325,20 @@ This will generate compile-time constants from BINDINGS."
|
||||||
(throw 'matched t)))
|
(throw 'matched t)))
|
||||||
(throw 'matched nil)))))
|
(throw 'matched nil)))))
|
||||||
|
|
||||||
|
(defun lisp-mode--search-key (char bound)
|
||||||
|
(catch 'found
|
||||||
|
(while (re-search-forward
|
||||||
|
(concat "\\_<" char (rx lisp-mode-symbol) "\\_>")
|
||||||
|
bound t)
|
||||||
|
(when (or (< (match-beginning 0) (+ (point-min) 2))
|
||||||
|
;; A quoted white space before the &/: means that this
|
||||||
|
;; is not the start of a :keyword or an &option.
|
||||||
|
(not (eql (char-after (- (match-beginning 0) 2))
|
||||||
|
?\\))
|
||||||
|
(not (memq (char-after (- (match-beginning 0) 1))
|
||||||
|
'(?\s ?\n ?\t))))
|
||||||
|
(throw 'found t)))))
|
||||||
|
|
||||||
(let-when-compile
|
(let-when-compile
|
||||||
((lisp-fdefs '("defmacro" "defun"))
|
((lisp-fdefs '("defmacro" "defun"))
|
||||||
(lisp-vdefs '("defvar"))
|
(lisp-vdefs '("defvar"))
|
||||||
|
@ -496,11 +510,11 @@ This will generate compile-time constants from BINDINGS."
|
||||||
(,(rx "\\\\=")
|
(,(rx "\\\\=")
|
||||||
(0 font-lock-builtin-face prepend))
|
(0 font-lock-builtin-face prepend))
|
||||||
;; Constant values.
|
;; Constant values.
|
||||||
(,(concat "\\_<:" (rx lisp-mode-symbol) "\\_>")
|
(,(lambda (bound) (lisp-mode--search-key ":" bound))
|
||||||
(0 font-lock-builtin-face))
|
(0 font-lock-builtin-face))
|
||||||
;; ELisp and CLisp `&' keywords as types.
|
;; ELisp and CLisp `&' keywords as types.
|
||||||
(,(concat "\\_<&" (rx lisp-mode-symbol) "\\_>")
|
(,(lambda (bound) (lisp-mode--search-key "&" bound))
|
||||||
. font-lock-type-face)
|
(0 font-lock-builtin-face))
|
||||||
;; ELisp regexp grouping constructs
|
;; ELisp regexp grouping constructs
|
||||||
(,(lambda (bound)
|
(,(lambda (bound)
|
||||||
(catch 'found
|
(catch 'found
|
||||||
|
@ -549,11 +563,12 @@ This will generate compile-time constants from BINDINGS."
|
||||||
;; must come before keywords below to have effect
|
;; must come before keywords below to have effect
|
||||||
(,(concat "#:" (rx lisp-mode-symbol) "") 0 font-lock-builtin-face)
|
(,(concat "#:" (rx lisp-mode-symbol) "") 0 font-lock-builtin-face)
|
||||||
;; Constant values.
|
;; Constant values.
|
||||||
(,(concat "\\_<:" (rx lisp-mode-symbol) "\\_>")
|
(,(lambda (bound) (lisp-mode--search-key ":" bound))
|
||||||
(0 font-lock-builtin-face))
|
(0 font-lock-builtin-face))
|
||||||
;; ELisp and CLisp `&' keywords as types.
|
;; ELisp and CLisp `&' keywords as types.
|
||||||
(,(concat "\\_<&" (rx lisp-mode-symbol) "\\_>")
|
(,(lambda (bound) (lisp-mode--search-key "&" bound))
|
||||||
. font-lock-type-face)
|
(0 font-lock-builtin-face))
|
||||||
|
;; ELisp regexp grouping constructs
|
||||||
;; This is too general -- rms.
|
;; This is too general -- rms.
|
||||||
;; A user complained that he has functions whose names start with `do'
|
;; A user complained that he has functions whose names start with `do'
|
||||||
;; and that they get the wrong color.
|
;; and that they get the wrong color.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue