]> git.eshelyaron.com Git - emacs.git/commitdiff
Try to avoid fontifying macros in funcall position
authorDaniel Colascione <dancol@dancol.org>
Mon, 23 Mar 2015 08:38:12 +0000 (01:38 -0700)
committerDaniel Colascione <dancol@dancol.org>
Mon, 23 Mar 2015 08:38:20 +0000 (01:38 -0700)
* lisp/emacs-lisp/lisp-mode.el
(lisp--el-non-funcall-position-p): New function.
(lisp--el-match-keyword): Use it.

lisp/ChangeLog
lisp/emacs-lisp/lisp-mode.el

index 8f1534a3284a759a78ebbb77a6dfcd87490664ec..630265a0f4c9cb4bc31a42a0437dd0a73e72ba59 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-23  Daniel Colascione  <dancol@dancol.org>
+
+       * emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p): New function.
+       (lisp--el-match-keyword): Use it.
+
 2015-03-23  Daiki Ueno  <ueno@gnu.org>
 
        * subr.el (start-process): New function, ported from the C
index 9c4194557ef798903d6f49f8de3930e4a8ce87d4..52bc6a5405bc06caef52d1b669a470651304ce2b 100644 (file)
             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)