Open fehmud opened 5 years ago
Hi!
Currently, there is no such feature.
It could be possible to implement something along those lines. However, when applying highlighting to a large block, the font-lock mechanism becomes slow. I've done similar things in, for example, my objc-font-lock package.
Matching "nil" should be easy. Matching a variable and checking it's value could be done (as long as we talk about elisp, not an external lisp), even if I believe that we would incorrectly grey out code since the value may change in runtime. Arbitrary expressions are harder or evaluate since we would have to do it in a safe manner.
Anyway, I don't have much time to do Emacs development these days, but why don't you give it a try yourself?
-- Anders
On Thu, Oct 3, 2019 at 8:21 PM fehmud notifications@github.com wrote:
Hello Anders, and thank you for sharing such a clever package.
Would it be possible to add highlighting of when nil forms with the shadow face, to indicate disabled code? Even better, could this package shadow code when using when with a global boolean variable that evaluates to false?
Thank you in any case.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Lindydancer/lisp-extra-font-lock/issues/7?email_source=notifications&email_token=AAYGGQBKLUABJDKLCKSMPXTQMYZ3VA5CNFSM4I5GSAZKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HPPJWXA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYGGQBICF7RZKK2XDXBOMTQMYZ3VANCNFSM4I5GSAZA .
Thanks for your prompt feedback. You are right that checking a variable could be unreliable.
I have worked with Font Lock in the past and found it tricky, but I will look into it.
Hi!
Good luck. If you get stuck, or would like to discuss ideas, it's OK to ask me. I would love to see more people involved in developing font-lock packages.
-- Anders
On Fri, Oct 4, 2019 at 7:56 PM fehmud notifications@github.com wrote:
Thanks for your prompt feedback. You are right that checking a variable could be unreliable.
I have worked with Font Lock in the past and found it tricky, but I will look into it.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Lindydancer/lisp-extra-font-lock/issues/7?email_source=notifications&email_token=AAYGGQBYRB2RSXT2F3UN57LQM57T3A5CNFSM4I5GSAZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAMNTUA#issuecomment-538499536, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYGGQB3K5CBUA2YPHFH6BDQM57T3ANCNFSM4I5GSAZA .
Regrettably, I couldn't find much information on advanced customization of Font Lock. I have managed to almost shadow a when nil
form with the following code in an Emacs Lisp buffer:
(font-lock-add-keywords nil
'(("^ *\\((when +nil\\)"
(1 'shadow)
("."
(save-excursion
(up-list)
(point))
(re-search-backward ".")
(0 'shadow)))))
I said almost because comments and strings still appear in their original colors. I am leaving it here in case somebody is interested.
I have seen that you have written and shared Font Lock Studio, that seems a very useful package. If I will find a clear explanation on how advanced Font Lock works, I will look into it.
Thanks for your attention and for sharing useful code.
There is little written on the subject, unfortunately. I've been playing with the idea to write some kind of book, but currently I haven't got the time required...
I can point you in the right direction, e.g. to similar packages or to variables that you would need to override to make this work, if you feel that you would be interested in trying.
-- Anders
On Mon, Oct 7, 2019 at 9:22 PM fehmud notifications@github.com wrote:
Regrettably, I couldn't find much information on advanced customization of Font Lock. I have managed to almost shadow a when nil form with the following code in an Emacs Lisp buffer:
(font-lock-add-keywords nil '(("^ *\((when +nil\)" (1 'shadow) ("." (save-excursion (up-list) (point)) (re-search-backward ".") (0 'shadow)))))
I said almost because comments and strings still appear in their original colors. I am leaving it here in case anybody is interested.
I have seen that you have written and shared Font Lock Studio, that seems a very useful package. If I will find a clear explanation on how advanced Font Lock works, I will look into it.
Thanks for your attention and for sharing useful code.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Lindydancer/lisp-extra-font-lock/issues/7?email_source=notifications&email_token=AAYGGQGYZPD6KOD3GA3LLWTQNOEATA5CNFSM4I5GSAZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEARQCOQ#issuecomment-539164986, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYGGQC23YIUWINKAPP6SUTQNOEATANCNFSM4I5GSAZA .
Hello Anders, and thank you for sharing such a clever package.
Would it be possible to add highlighting of
when nil
forms with theshadow
face, to indicate disabled code? Even better, could this package shadow code when usingwhen
with a global boolean variable that evaluates to false?Thank you in any case.