summaryrefslogtreecommitdiff
path: root/cider-mode.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-11-28 00:47:20 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-11-28 00:48:28 +0000
commit94386d563419edd7a0f4e809636a7d7e50fd7c38 (patch)
treedb7e169c0fda57f6ddbb12184ea9a7a3e5687807 /cider-mode.el
parent2155a6b698ba7fbf4b98c8dbaa2975a60bf392ef (diff)
Make the locals font-lock a little smarter
Diffstat (limited to 'cider-mode.el')
-rw-r--r--cider-mode.el22
1 files changed, 18 insertions, 4 deletions
diff --git a/cider-mode.el b/cider-mode.el
index 3b7afaf9..3f429380 100644
--- a/cider-mode.el
+++ b/cider-mode.el
@@ -553,10 +553,24 @@ property."
(when (and (not (bobp))
(get-text-property (1- (point)) 'cider-block-dynamic-font-lock))
(ignore-errors (beginning-of-defun)))
- (ignore-errors
- (cider--parse-and-apply-locals
- end (unless (bobp)
- (get-text-property (1- (point)) 'cider-locals)))))))
+ (let ((locals-above (unless (bobp)
+ (get-text-property (1- (point)) 'cider-locals))))
+ (save-excursion
+ ;; If there are locals above the current sexp, reapply them to the
+ ;; current sexp.
+ (when (and locals-above
+ (condition-case nil
+ (progn (up-list) t)
+ (scan-error nil)))
+ (add-text-properties beg (point) `(cider-locals ,locals-above)))
+ ;; Extend the region being font-locked to include whole sexps.
+ (goto-char end)
+ (when (condition-case nil
+ (progn (up-list) t)
+ (scan-error nil))
+ (setq end (max end (point)))))
+ (ignore-errors
+ (cider--parse-and-apply-locals end locals-above))))))
(apply func beg end rest)))