Skip to content

Commit c8fb695

Browse files
committed
[Fix #1371] Font-lock deprecated vars with a background color
1 parent cb47d71 commit c8fb695

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### New features
66

7+
* [#1371](https://github.com/clojure-emacs/cider/issues/1371): Font-lock deprecated vars with a background color.
78
* [#1232](https://github.com/clojure-emacs/cider/pull/1232): Add `cider-load-buffer-and-switch-to-repl-buffer`.
89
* [#1325](https://github.com/clojure-emacs/cider/issues/1325): Jump to error location when clicking on the error message in the stack-trace pop-up.
910
* [#1301](https://github.com/clojure-emacs/cider/issues/1301): CIDER can do dynamic font-locking of defined variables, functions, and macros. This is controlled by the `cider-font-lock-dynamically` custom option.

cider-mode.el

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Returns to the buffer in which the command was invoked."
314314
(cider--deep-vector-to-list (read indent))))))
315315

316316
;;; Dynamic font locking
317-
(defcustom cider-font-lock-dynamically '(macro core)
317+
(defcustom cider-font-lock-dynamically '(macro core deprecated)
318318
"Specifies how much dynamic font-locking CIDER should use.
319319
Dynamic font-locking this refers to applying syntax highlighting to vars
320320
defined in the currently active nREPL connection. This is done in addition
@@ -326,30 +326,45 @@ that should be font-locked:
326326
`macro' (default): Any defined macro gets the `font-lock-builtin-face'.
327327
`function': Any defined function gets the `font-lock-function-face'.
328328
`var': Any non-local var gets the `font-lock-variable-face'.
329+
`deprecated' (default): Any deprecated var gets the `cider-deprecated' face.
329330
`core' (default): Any symbol from clojure.core (face depends on type).
330331
331332
The value can also be t, which means to font-lock as much as possible."
332333
:type '(choice (set :tag "Fine-tune font-locking"
333334
(const :tag "Any defined macro" macro)
334335
(const :tag "Any defined function" function)
335336
(const :tag "Any defined var" var)
337+
(const :tag "Any defined deprecated" deprecated)
336338
(const :tag "Any symbol from clojure.core" core))
337339
(const :tag "Font-lock as much as possible" t))
338340
:group 'cider
339341
:package-version '(cider . "0.10.0"))
340342

343+
(defface cider-deprecated
344+
'((((background light)) :background "light goldenrod")
345+
(((background dark)) :background "#432"))
346+
"Faced used on depreacted vars"
347+
:group 'cider)
348+
349+
(defconst cider-deprecated-properties
350+
'(face cider-deprecated
351+
help-echo "This var is deprecated. \\[cider-doc] for version information."))
352+
341353
(defun cider--compile-font-lock-keywords (symbols-plist core-plist)
342354
"Return a list of font-lock rules for the symbols in SYMBOLS-PLIST."
343355
(let ((cider-font-lock-dynamically (if (eq cider-font-lock-dynamically t)
344-
'(function var macro core)
356+
'(function var macro core deprecated)
345357
cider-font-lock-dynamically))
358+
deprecated
346359
macros functions vars instrumented)
347360
(when (memq 'core cider-font-lock-dynamically)
348361
(while core-plist
349362
(let ((sym (pop core-plist))
350363
(meta (pop core-plist)))
351364
(when (nrepl-dict-get meta "cider-instrumented")
352365
(push sym instrumented))
366+
(when (nrepl-dict-get meta "deprecated")
367+
(push sym deprecated))
353368
(cond
354369
((nrepl-dict-get meta "macro")
355370
(push sym macros))
@@ -362,6 +377,9 @@ The value can also be t, which means to font-lock as much as possible."
362377
(meta (pop symbols-plist)))
363378
(when (nrepl-dict-get meta "cider-instrumented")
364379
(push sym instrumented))
380+
(when (and (nrepl-dict-get meta "deprecated")
381+
(memq 'deprecated cider-font-lock-dynamically))
382+
(push sym deprecated))
365383
(cond
366384
((and (memq 'macro cider-font-lock-dynamically)
367385
(nrepl-dict-get meta "macro"))
@@ -380,6 +398,8 @@ The value can also be t, which means to font-lock as much as possible."
380398
`((,(regexp-opt functions 'symbols) 0 font-lock-function-name-face append)))
381399
,@(when vars
382400
`((,(regexp-opt vars 'symbols) 0 font-lock-variable-name-face append)))
401+
,@(when deprecated
402+
`((,(regexp-opt deprecated 'symbols) 0 cider-deprecated-properties append)))
383403
,@(when instrumented
384404
`((,(regexp-opt instrumented 'symbols) 0 'cider-instrumented-face append))))))
385405

0 commit comments

Comments
 (0)