Skip to content

Commit 94386d5

Browse files
committed
Make the locals font-lock a little smarter
1 parent 2155a6b commit 94386d5

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

cider-mode.el

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,24 @@ property."
553553
(when (and (not (bobp))
554554
(get-text-property (1- (point)) 'cider-block-dynamic-font-lock))
555555
(ignore-errors (beginning-of-defun)))
556-
(ignore-errors
557-
(cider--parse-and-apply-locals
558-
end (unless (bobp)
559-
(get-text-property (1- (point)) 'cider-locals)))))))
556+
(let ((locals-above (unless (bobp)
557+
(get-text-property (1- (point)) 'cider-locals))))
558+
(save-excursion
559+
;; If there are locals above the current sexp, reapply them to the
560+
;; current sexp.
561+
(when (and locals-above
562+
(condition-case nil
563+
(progn (up-list) t)
564+
(scan-error nil)))
565+
(add-text-properties beg (point) `(cider-locals ,locals-above)))
566+
;; Extend the region being font-locked to include whole sexps.
567+
(goto-char end)
568+
(when (condition-case nil
569+
(progn (up-list) t)
570+
(scan-error nil))
571+
(setq end (max end (point)))))
572+
(ignore-errors
573+
(cider--parse-and-apply-locals end locals-above))))))
560574
(apply func beg end rest)))
561575

562576

0 commit comments

Comments
 (0)