ddoherty03 / commify

Emacs package for toggling commas on and off in numbers.
GNU General Public License v3.0
12 stars 3 forks source link

Integrating with font-lock? #2

Closed cpitclaudel closed 1 week ago

cpitclaudel commented 8 years ago

Could this be integrated with font-lock? Numbers would be given a display property that adds the separators, without actual modifications to the buffer.

ddoherty03 commented 8 years ago

Not sure. I'm no elisp expert, but a brief look made it seem as though only the face can be changed with font lock.

I like the idea, though.

cpitclaudel commented 8 years ago

I like the idea, though.

Cool :) It's definitely feasible, and it should be pretty easy. Font-lock supports arbitrary text properties, not just face; Look at prettify-symbols-mode, nameless, or glasses-mode for examples.

From the docs:

font-lock-keywords is a variable defined in ‘font-lock.el’.
...

Documentation:
A list of the keywords to highlight.
...

MATCH-HIGHLIGHT should be of the form:

 (SUBEXP FACENAME [OVERRIDE [LAXMATCH]])
...

FACENAME is an expression whose value is the face name to use.
Instead of a face, FACENAME can evaluate to a property list of
the form (face FACE PROP1 VAL1 PROP2 VAL2 ...)  in which case all
the listed text-properties will be set rather than just FACE.  In
such a case, you will most likely want to put those properties in
‘font-lock-extra-managed-props’ or to override
‘font-lock-unfontify-region-function’.
ddoherty03 commented 8 years ago

I will. Thanks for the pointer.

cpitclaudel commented 8 years ago

Great, thanks!

ddoherty03 commented 1 week ago

I am closing this as beyond the scope of the package, but thanks for the suggestion.