aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Colascione2015-03-23 01:38:12 -0700
committerDaniel Colascione2015-03-23 01:38:20 -0700
commitd235b1d261ae9f275ac1f412dd8a8ad3f1c45e51 (patch)
treef0ad20b881e2d66616e4651d04fdc097eb821f23
parent47e0e319329a1ecf9da4fa1afd2b9f2738fada67 (diff)
downloademacs-d235b1d261ae9f275ac1f412dd8a8ad3f1c45e51.tar.gz
emacs-d235b1d261ae9f275ac1f412dd8a8ad3f1c45e51.zip
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.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/emacs-lisp/lisp-mode.el36
2 files changed, 40 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8f1534a3284..630265a0f4c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12015-03-23 Daniel Colascione <dancol@dancol.org>
2
3 * emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p): New function.
4 (lisp--el-match-keyword): Use it.
5
12015-03-23 Daiki Ueno <ueno@gnu.org> 62015-03-23 Daiki Ueno <ueno@gnu.org>
2 7
3 * subr.el (start-process): New function, ported from the C 8 * 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 @@
181 nil))) 181 nil)))
182 res)) 182 res))
183 183
184(defun lisp--el-non-funcall-position-p (&optional pos)
185 "Heuristically determine whether POS is an evaluated position."
186 (setf pos (or pos (point)))
187 (save-match-data
188 (save-excursion
189 (goto-char pos)
190 (or (eql (char-before) ?\')
191 (let ((parent
192 (ignore-errors
193 (up-list -1)
194 (cond
195 ((looking-at (rx "(" (* (syntax -)) "("))
196 (up-list -1)
197 (when (looking-at "(\\_<let\\*?\\_>")
198 (goto-char (match-end 0))
199 'let))
200 ((looking-at
201 (rx "("
202 (group-n 1 (+ (or (syntax w) (syntax _))))
203 symbol-end))
204 (prog1 (intern-soft (match-string-no-properties 1))
205 (goto-char (match-end 1))))))))
206 (or (eq parent 'declare)
207 (and (eq parent 'let)
208 (progn
209 (forward-sexp 1)
210 (< pos (point))))
211 (and (eq parent 'condition-case)
212 (progn
213 (forward-sexp 2)
214 (< (point) pos)))))))))
215
184(defun lisp--el-match-keyword (limit) 216(defun lisp--el-match-keyword (limit)
185 (catch 'found 217 (catch 'found
186 (while (re-search-forward "(\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>" limit t) 218 (while (re-search-forward "(\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>" limit t)
187 (let ((sym (intern-soft (match-string 1)))) 219 (let ((sym (intern-soft (match-string 1))))
188 (when (or (special-form-p sym) 220 (when (or (special-form-p sym)
189 (and (macrop sym) 221 (and (macrop sym)
190 (not (get sym 'no-font-lock-keyword)))) 222 (not (get sym 'no-font-lock-keyword))
223 (not (lisp--el-non-funcall-position-p
224 (match-beginning 0)))))
191 (throw 'found t)))))) 225 (throw 'found t))))))
192 226
193(defun lisp--el-font-lock-flush-elisp-buffers (&optional file) 227(defun lisp--el-font-lock-flush-elisp-buffers (&optional file)