From 751adc4b9631cedcf9bec475afe40da4db7d74a1 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Mon, 9 Feb 2015 10:05:44 +0800 Subject: Add macro pcase-lambda Fixes: debbugs:19814 * emacs-lisp/lisp-mode.el (el-kws-re): Include `pcase-lambda'. * emacs-lisp/macroexp.el (macroexp-parse-body): New function. * emacs-lisp/pcase.el (pcase-lambda): New Macro. --- lisp/emacs-lisp/lisp-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 868a9578b0d..5d912097838 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -204,7 +204,7 @@ "defface")) (el-tdefs '("defgroup" "deftheme")) (el-kw '("while-no-input" "letrec" "pcase" "pcase-exhaustive" - "pcase-let" "pcase-let*" "save-restriction" + "pcase-lambda" "pcase-let" "pcase-let*" "save-restriction" "save-excursion" "save-selected-window" ;; "eval-after-load" "eval-next-after-load" "save-window-excursion" "save-current-buffer" -- cgit v1.2.3 From 51e7e463e93708a0e40688f91200e9e9869ec662 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sat, 14 Mar 2015 09:27:31 +0100 Subject: Font-lock elisp macros/special forms dynamically * emacs-lisp/lisp-mode.el (lisp--el-macro-regexp): New defconst. (lisp--el-update-macro-regexp, lisp--el-update-after-load) (lisp--el-match-macro): New functions. (lisp-mode-variables): Update lisp--el-macro-regexp and add lisp--el-update-after-load to after-load-functions. --- lisp/ChangeLog | 8 ++++++++ lisp/emacs-lisp/lisp-mode.el | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fb2291c534c..73ba0353d9d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2015-03-15 Tassilo Horn + + * emacs-lisp/lisp-mode.el (lisp--el-macro-regexp): New defconst. + (lisp--el-update-macro-regexp, lisp--el-update-after-load) + (lisp--el-match-macro): New functions. + (lisp-mode-variables): Update lisp--el-macro-regexp and add + lisp--el-update-after-load to after-load-functions. + 2015-03-15 Daniel Colascione * emacs-lisp/cl-indent.el diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 5d912097838..b4f87fdac66 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -181,6 +181,33 @@ nil))) res)) +(defconst lisp--el-macro-regexp nil + "A regular expression matching all loaded elisp macros. +Can be updated using `lisp--el-update-macro-regexp' after new +macros were defined.") + +(defun lisp--el-update-macro-regexp () + "Update `lisp--el-update-macro-regexp' from `obarray'. +Return non-nil only if the old and new value are different." + (let ((old-regex lisp--el-macro-regexp) + (elisp-macros nil)) + (mapatoms (lambda (a) + (when (or (macrop a) (special-form-p a)) + (push (symbol-name a) elisp-macros)))) + (setq lisp--el-macro-regexp + (concat "(" (regexp-opt elisp-macros t) "\\_>")) + (not (string= old-regex lisp--el-macro-regexp)))) + +(defun lisp--el-update-after-load (_file) + "Update `lisp--el-macro-regexp' and adjust font-lock in existing buffers." + (when (lisp--el-update-macro-regexp) + (dolist (buf (buffer-list)) + (when (derived-mode-p 'emacs-lisp-mode) + (font-lock-flush))))) + +(defun lisp--el-match-macro (limit) + (re-search-forward lisp--el-macro-regexp limit t)) + (pcase-let ((`(,vdefs ,tdefs ,el-defs-re ,cl-defs-re @@ -194,7 +221,9 @@ "when" "unless" "with-output-to-string" "ignore-errors" "dotimes" "dolist" "declare")) (lisp-errs '("warn" "error" "signal")) - ;; Elisp constructs. FIXME: update dynamically from obarray. + ;; Elisp constructs. Now they are update dynamically + ;; from obarray but they are also used for setting up + ;; the keywords for Common Lisp. (el-fdefs '("define-advice" "defadvice" "defalias" "define-derived-mode" "define-minor-mode" "define-generic-mode" "define-global-minor-mode" @@ -333,7 +362,7 @@ `( ;; Regexp negated char group. ("\\[\\(\\^\\)" 1 font-lock-negation-char-face prepend) ;; Control structures. Common Lisp forms. - (,(concat "(" el-kws-re "\\_>") . 1) + (lisp--el-match-macro . 1) ;; Exit/Feature symbols as constants. (,(concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\_>" "[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?") @@ -514,6 +543,9 @@ font-lock keywords will not be case sensitive." . lisp-font-lock-syntactic-face-function))) (setq-local prettify-symbols-alist lisp--prettify-symbols-alist) (when elisp + (unless lisp--el-macro-regexp + (lisp--el-update-macro-regexp)) + (add-hook 'after-load-functions #'lisp--el-update-after-load) (setq-local electric-pair-text-pairs (cons '(?\` . ?\') electric-pair-text-pairs))) (setq-local electric-pair-skip-whitespace 'chomp) -- cgit v1.2.3 From 9fdc166ee0ca212f7d5bf1cd9e1177932b0cd9aa Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Mon, 16 Mar 2015 10:25:14 +0100 Subject: Improve dynamic elisp keyword font-locking * emacs-lisp/byte-run.el (macro-declarations-alist): New declaration no-font-lock-keyword. (defmacro): Flush font-lock in existing elisp buffers. * emacs-lisp/lisp-mode.el (lisp--el-update-after-load) (lisp--el-update-macro-regexp, lisp--el-macro-regexp): Delete functions and defconst. (lisp--el-match-keyword): Rename from lisp--el-match-macro. (lisp--el-font-lock-flush-elisp-buffers): New function. (lisp-mode-variables): Remove code for updating lisp--el-macro-regexp, and add lisp--el-font-lock-flush-elisp-buffers to after-load-functions. --- lisp/ChangeLog | 15 ++++++++++++++ lisp/emacs-lisp/byte-run.el | 28 ++++++++++++++++++++----- lisp/emacs-lisp/lisp-mode.el | 49 ++++++++++++++++++-------------------------- 3 files changed, 58 insertions(+), 34 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 25571bab9c5..e365346c972 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2015-03-17 Tassilo Horn + + * emacs-lisp/byte-run.el (macro-declarations-alist): New + declaration no-font-lock-keyword. + (defmacro): Flush font-lock in existing elisp buffers. + + * emacs-lisp/lisp-mode.el (lisp--el-update-after-load) + (lisp--el-update-macro-regexp, lisp--el-macro-regexp): Delete + functions and defconst. + (lisp--el-match-keyword): Rename from lisp--el-match-macro. + (lisp--el-font-lock-flush-elisp-buffers): New function. + (lisp-mode-variables): Remove code for updating + lisp--el-macro-regexp, and add + lisp--el-font-lock-flush-elisp-buffers to after-load-functions. + 2015-03-17 Simen Heggestøyl * textmodes/css-mode.el (css--font-lock-keywords): Discriminate diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index caa7e3dad33..e0d6c3e7829 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -147,11 +147,16 @@ This is used by `declare'.") (defvar macro-declarations-alist (cons (list 'debug - #'(lambda (name _args spec) - (list 'progn :autoload-end - (list 'put (list 'quote name) - ''edebug-form-spec (list 'quote spec))))) - defun-declarations-alist) + #'(lambda (name _args spec) + (list 'progn :autoload-end + (list 'put (list 'quote name) + ''edebug-form-spec (list 'quote spec))))) + (cons + (list 'no-font-lock-keyword + #'(lambda (name _args val) + (list 'function-put (list 'quote name) + ''no-font-lock-keyword (list 'quote val)))) + defun-declarations-alist)) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -201,6 +206,19 @@ The return value is undefined. (message "Warning: Unknown macro property %S in %S" (car x) name)))) decls))) + ;; Refresh font-lock if this is a new macro, or it is an + ;; existing macro whose 'no-font-lock-keyword declaration + ;; has changed. + (if (and + ;; If lisp-mode hasn't been loaded, there's no reason + ;; to flush. + (fboundp 'lisp--el-font-lock-flush-elisp-buffers) + (or (not (fboundp name)) ;; new macro + (and (fboundp name) ;; existing macro + (member `(function-put ',name 'no-font-lock-keyword + ',(get name 'no-font-lock-keyword)) + declarations)))) + (lisp--el-font-lock-flush-elisp-buffers)) (if declarations (cons 'prog1 (cons def declarations)) def)))))) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index b4f87fdac66..6b3077302ed 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -181,32 +181,25 @@ nil))) res)) -(defconst lisp--el-macro-regexp nil - "A regular expression matching all loaded elisp macros. -Can be updated using `lisp--el-update-macro-regexp' after new -macros were defined.") - -(defun lisp--el-update-macro-regexp () - "Update `lisp--el-update-macro-regexp' from `obarray'. -Return non-nil only if the old and new value are different." - (let ((old-regex lisp--el-macro-regexp) - (elisp-macros nil)) - (mapatoms (lambda (a) - (when (or (macrop a) (special-form-p a)) - (push (symbol-name a) elisp-macros)))) - (setq lisp--el-macro-regexp - (concat "(" (regexp-opt elisp-macros t) "\\_>")) - (not (string= old-regex lisp--el-macro-regexp)))) - -(defun lisp--el-update-after-load (_file) - "Update `lisp--el-macro-regexp' and adjust font-lock in existing buffers." - (when (lisp--el-update-macro-regexp) +(defun lisp--el-match-keyword (limit) + (catch 'found + (while (re-search-forward "(\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>" limit t) + (let ((sym (intern-soft (match-string 1)))) + (when (or (special-form-p sym) + (and (macrop sym) + (not (get sym 'no-font-lock-keyword)))) + (throw 'found t)))))) + +(defun lisp--el-font-lock-flush-elisp-buffers (&optional file) + ;; Don't flush during load unless called from after-load-functions. + ;; In that case, FILE is non-nil. It's somehow strange that + ;; load-in-progress is t when an after-load-function is called since + ;; that should run *after* the load... + (when (or (not load-in-progress) file) (dolist (buf (buffer-list)) - (when (derived-mode-p 'emacs-lisp-mode) - (font-lock-flush))))) - -(defun lisp--el-match-macro (limit) - (re-search-forward lisp--el-macro-regexp limit t)) + (with-current-buffer buf + (when (derived-mode-p 'emacs-lisp-mode) + (font-lock-flush)))))) (pcase-let ((`(,vdefs ,tdefs @@ -362,7 +355,7 @@ Return non-nil only if the old and new value are different." `( ;; Regexp negated char group. ("\\[\\(\\^\\)" 1 font-lock-negation-char-face prepend) ;; Control structures. Common Lisp forms. - (lisp--el-match-macro . 1) + (lisp--el-match-keyword . 1) ;; Exit/Feature symbols as constants. (,(concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\_>" "[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?") @@ -543,9 +536,7 @@ font-lock keywords will not be case sensitive." . lisp-font-lock-syntactic-face-function))) (setq-local prettify-symbols-alist lisp--prettify-symbols-alist) (when elisp - (unless lisp--el-macro-regexp - (lisp--el-update-macro-regexp)) - (add-hook 'after-load-functions #'lisp--el-update-after-load) + (add-hook 'after-load-functions #'lisp--el-font-lock-flush-elisp-buffers) (setq-local electric-pair-text-pairs (cons '(?\` . ?\') electric-pair-text-pairs))) (setq-local electric-pair-skip-whitespace 'chomp) -- cgit v1.2.3 From c9998fcbf40c533004533dee96f2eb67349d55ae Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Fri, 20 Mar 2015 23:09:06 +0100 Subject: Fix elisp function name font-lock bug. * emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-1): Fix false positive in function name font-locking. --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/lisp-mode.el | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ee4e021b940..85e62be80c2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2015-03-20 Tassilo Horn + + * emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-1): Fix + false positive in function name font-locking. + 2015-03-20 Stefan Monnier * emacs-lisp/cl-macs.el (cl-defsubst): Ignore false-positive diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 6b3077302ed..d8901ac017d 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -320,14 +320,18 @@ `( ;; Definitions. (,(concat "(" el-defs-re "\\_>" ;; Any whitespace and defined object. - "[ \t'\(]*" - "\\(\\(?:\\sw\\|\\s_\\)+\\)?") + "[ \t']*" + ;; With cl-defstruct, the name may follow a paren, + ;; e.g. (cl-defstruct (foo-struct opts)...). + "\\(([ \t']*\\)?\\(\\(?:\\sw\\|\\s_\\)+\\)?") (1 font-lock-keyword-face) - (2 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) - (cond ((eq type 'var) font-lock-variable-name-face) - ((eq type 'type) font-lock-type-face) - (t font-lock-function-name-face))) - nil t)) + (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) + (cond ((eq type 'var) font-lock-variable-name-face) + ((eq type 'type) font-lock-type-face) + ;; If match-string 2 is non-nil, we encountered a + ;; form like (defalias (intern (concat s "-p"))). + ((not (match-string 2)) font-lock-function-name-face))) + nil t)) ;; Emacs Lisp autoload cookies. Supports the slightly different ;; forms used by mh-e, calendar, etc. ("^;;;###\\([-a-z]*autoload\\)" 1 font-lock-warning-face prepend)) -- cgit v1.2.3 From 73b8237c19200e7d8d3739b99ef1e4dc86f51873 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Fri, 20 Mar 2015 23:35:22 +0100 Subject: Fix CL function name font-lock bug. * emacs-lisp/lisp-mode.el (lisp-cl-font-lock-keywords-1): Fix false positive in function name font-locking. --- lisp/ChangeLog | 1 + lisp/emacs-lisp/lisp-mode.el | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 85e62be80c2..025941f809c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,7 @@ * emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-1): Fix false positive in function name font-locking. + (lisp-cl-font-lock-keywords-1): Ditto. 2015-03-20 Stefan Monnier diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index d8901ac017d..a3bb1a709f6 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -341,13 +341,16 @@ `( ;; Definitions. (,(concat "(" cl-defs-re "\\_>" ;; Any whitespace and defined object. - "[ \t'\(]*" - "\\(setf[ \t]+\\(?:\\sw\\|\\s_\\)+\\|\\(?:\\sw\\|\\s_\\)+\\)?") + "[ \t']*" + "\\(([ \t']*\\)?" ;; An opening paren. + "\\(\\(setf\\)[ \t]+\\(?:\\sw\\|\\s_\\)+\\|\\(?:\\sw\\|\\s_\\)+\\)?") (1 font-lock-keyword-face) - (2 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) + (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) (cond ((eq type 'var) font-lock-variable-name-face) ((eq type 'type) font-lock-type-face) - (t font-lock-function-name-face))) + ((or (not (match-string 2)) ;; Normal defun. + (and (match-string 2) ;; Setf-expander. + (match-string 4))) font-lock-function-name-face))) nil t))) "Subdued level highlighting for Lisp modes.") -- cgit v1.2.3 From fa734d07ab9dd00ad29d68668ed25247c9000aef Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sat, 21 Mar 2015 08:52:34 +0100 Subject: Handle setf methods in elisp font-locking. * emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-1): Also recognize (cl-)defmethod with (setf method) name. --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/lisp-mode.el | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 025941f809c..1cfefaa39df 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2015-03-21 Tassilo Horn + + * emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-1): Also + recognize (cl-)defmethod with (setf method) name. + 2015-03-20 Tassilo Horn * emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-1): Fix diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index a3bb1a709f6..9c4194557ef 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -249,7 +249,7 @@ (eieio-tdefs '("defclass")) (eieio-kw '("with-slots")) ;; Common-Lisp constructs supported by cl-lib. - (cl-lib-fdefs '("defmacro" "defsubst" "defun")) + (cl-lib-fdefs '("defmacro" "defsubst" "defun" "defmethod")) (cl-lib-tdefs '("defstruct" "deftype")) (cl-lib-kw '("progv" "eval-when" "case" "ecase" "typecase" "etypecase" "ccase" "ctypecase" "loop" "do" "do*" @@ -321,16 +321,19 @@ (,(concat "(" el-defs-re "\\_>" ;; Any whitespace and defined object. "[ \t']*" - ;; With cl-defstruct, the name may follow a paren, - ;; e.g. (cl-defstruct (foo-struct opts)...). - "\\(([ \t']*\\)?\\(\\(?:\\sw\\|\\s_\\)+\\)?") + "\\(([ \t']*\\)?" ;; An opening paren. + "\\(\\(setf\\)[ \t]+\\(?:\\sw\\|\\s_\\)+\\|\\(?:\\sw\\|\\s_\\)+\\)?") (1 font-lock-keyword-face) (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) (cond ((eq type 'var) font-lock-variable-name-face) ((eq type 'type) font-lock-type-face) ;; If match-string 2 is non-nil, we encountered a - ;; form like (defalias (intern (concat s "-p"))). - ((not (match-string 2)) font-lock-function-name-face))) + ;; form like (defalias (intern (concat s "-p"))), + ;; unless match-string 4 is also there. Then its a + ;; defmethod with (setf foo) as name. + ((or (not (match-string 2)) ;; Normal defun. + (and (match-string 2) ;; Setf method. + (match-string 4))) font-lock-function-name-face))) nil t)) ;; Emacs Lisp autoload cookies. Supports the slightly different ;; forms used by mh-e, calendar, etc. @@ -349,7 +352,7 @@ (cond ((eq type 'var) font-lock-variable-name-face) ((eq type 'type) font-lock-type-face) ((or (not (match-string 2)) ;; Normal defun. - (and (match-string 2) ;; Setf-expander. + (and (match-string 2) ;; Setf function. (match-string 4))) font-lock-function-name-face))) nil t))) "Subdued level highlighting for Lisp modes.") -- cgit v1.2.3 From d235b1d261ae9f275ac1f412dd8a8ad3f1c45e51 Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Mon, 23 Mar 2015 01:38:12 -0700 Subject: Try to avoid fontifying macros in funcall position * lisp/emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p): New function. (lisp--el-match-keyword): Use it. --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/lisp-mode.el | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8f1534a3284..630265a0f4c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2015-03-23 Daniel Colascione + + * emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p): New function. + (lisp--el-match-keyword): Use it. + 2015-03-23 Daiki Ueno * subr.el (start-process): New function, ported from the C diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 9c4194557ef..52bc6a5405b 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -181,13 +181,47 @@ nil))) res)) +(defun lisp--el-non-funcall-position-p (&optional pos) + "Heuristically determine whether POS is an evaluated position." + (setf pos (or pos (point))) + (save-match-data + (save-excursion + (goto-char pos) + (or (eql (char-before) ?\') + (let ((parent + (ignore-errors + (up-list -1) + (cond + ((looking-at (rx "(" (* (syntax -)) "(")) + (up-list -1) + (when (looking-at "(\\_") + (goto-char (match-end 0)) + 'let)) + ((looking-at + (rx "(" + (group-n 1 (+ (or (syntax w) (syntax _)))) + symbol-end)) + (prog1 (intern-soft (match-string-no-properties 1)) + (goto-char (match-end 1)))))))) + (or (eq parent 'declare) + (and (eq parent 'let) + (progn + (forward-sexp 1) + (< pos (point)))) + (and (eq parent 'condition-case) + (progn + (forward-sexp 2) + (< (point) pos))))))))) + (defun lisp--el-match-keyword (limit) (catch 'found (while (re-search-forward "(\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>" limit t) (let ((sym (intern-soft (match-string 1)))) (when (or (special-form-p sym) (and (macrop sym) - (not (get sym 'no-font-lock-keyword)))) + (not (get sym 'no-font-lock-keyword)) + (not (lisp--el-non-funcall-position-p + (match-beginning 0))))) (throw 'found t)))))) (defun lisp--el-font-lock-flush-elisp-buffers (&optional file) -- cgit v1.2.3 From b8d7d7e8e6b3f5542b52b57f2514960d7184210a Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Mon, 23 Mar 2015 01:42:56 -0700 Subject: Fix previous commit --- lisp/emacs-lisp/lisp-mode.el | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 52bc6a5405b..e96c8ed5cef 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -186,32 +186,32 @@ (setf pos (or pos (point))) (save-match-data (save-excursion - (goto-char pos) - (or (eql (char-before) ?\') - (let ((parent - (ignore-errors + (ignore-errors + (goto-char pos) + (or (eql (char-before) ?\') + (let ((parent (up-list -1) - (cond - ((looking-at (rx "(" (* (syntax -)) "(")) - (up-list -1) - (when (looking-at "(\\_") - (goto-char (match-end 0)) - 'let)) - ((looking-at - (rx "(" - (group-n 1 (+ (or (syntax w) (syntax _)))) - symbol-end)) - (prog1 (intern-soft (match-string-no-properties 1)) - (goto-char (match-end 1)))))))) - (or (eq parent 'declare) - (and (eq parent 'let) - (progn - (forward-sexp 1) - (< pos (point)))) - (and (eq parent 'condition-case) - (progn - (forward-sexp 2) - (< (point) pos))))))))) + (cond + ((looking-at (rx "(" (* (syntax -)) "(")) + (up-list -1) + (when (looking-at "(\\_") + (goto-char (match-end 0)) + 'let)) + ((looking-at + (rx "(" + (group-n 1 (+ (or (syntax w) (syntax _)))) + symbol-end)) + (prog1 (intern-soft (match-string-no-properties 1)) + (goto-char (match-end 1))))))) + (or (eq parent 'declare) + (and (eq parent 'let) + (progn + (forward-sexp 1) + (< pos (point)))) + (and (eq parent 'condition-case) + (progn + (forward-sexp 2) + (< (point) pos)))))))))) (defun lisp--el-match-keyword (limit) (catch 'found -- cgit v1.2.3 From bad7308e0c7bfe0192ac05d7aea72e1f7bea7b08 Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Mon, 23 Mar 2015 01:50:42 -0700 Subject: Fix previous commit (again) --- lisp/emacs-lisp/lisp-mode.el | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index e96c8ed5cef..4c9a39fe174 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -190,19 +190,22 @@ (goto-char pos) (or (eql (char-before) ?\') (let ((parent - (up-list -1) - (cond - ((looking-at (rx "(" (* (syntax -)) "(")) - (up-list -1) - (when (looking-at "(\\_") - (goto-char (match-end 0)) - 'let)) - ((looking-at - (rx "(" - (group-n 1 (+ (or (syntax w) (syntax _)))) - symbol-end)) - (prog1 (intern-soft (match-string-no-properties 1)) - (goto-char (match-end 1))))))) + (progn + (up-list -1) + (cond + ((ignore-errors + (and (eql (char-after) ?\() + (progn + (up-list -1) + (looking-at "(\\_")))) + (goto-char (match-end 0)) + 'let) + ((looking-at + (rx "(" + (group-n 1 (+ (or (syntax w) (syntax _)))) + symbol-end)) + (prog1 (intern-soft (match-string-no-properties 1)) + (goto-char (match-end 1)))))))) (or (eq parent 'declare) (and (eq parent 'let) (progn -- cgit v1.2.3