emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d235b1d: Try to avoid fontifying macros in funcall


From: Daniel Colascione
Subject: [Emacs-diffs] master d235b1d: Try to avoid fontifying macros in funcall position
Date: Mon, 23 Mar 2015 08:38:28 +0000

branch: master
commit d235b1d261ae9f275ac1f412dd8a8ad3f1c45e51
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    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 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8f1534a..630265a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-23  Daniel Colascione  <address@hidden>
+
+       * emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p): New 
function.
+       (lisp--el-match-keyword): Use it.
+
 2015-03-23  Daiki Ueno  <address@hidden>
 
        * 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 9c41945..52bc6a5 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 "(\\_<let\\*?\\_>")
+                        (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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]