I am using funcall
to set a typeface by calling a function select-typeface
. I would like to remove select-typeface
, calling (face (funcall level-typeface depth match)
.
Cannot simply do
(let ( (face (funcall level-typeface depth match)) )
in function colourise
.
I might remove funcall
and just use
(let ( (face (level-typeface depth match)) )
Changing from select-typeface
to level-typeface
has became problematic, because the face is not being applied at loc
.
(defun level-typeface (depth match)
"Typeface for colouring a nested glyph at a particular depth.
DEPTH Depth level of nested glyph.
MATCH Indicates whether glyph is matched by a closing brace.
LOC Location of glyph.
Returns one of `pigment-N' (N=1..dmax), or
`pigment-unmatched-typeface', or `pigment-mismatched-typeface'"
(cond
( (<= depth 0) 'pigment-unmatched-typeface)
( (not match) 'pigment-mismatched-typeface)
( t
(let* ( (dcur depth)
(dmax maxdepth)
(n (mod dcur dmax))
(levn (number-to-string n)) )
(when (= n 0) (setq levn "8"))
(intern-soft (concat "pigment-" levn)) ))) )
(defcustom select-typeface #'level-typeface
"Select typeface function for colouring."
:tag "Select function for colourising glyphs."
:type 'function
:group 'rich)
(defun colourise (loc depth match)
"Highlight a single glyph at LOC according to DEPTH.
LOC Location of character to add text properties to.
DEPTH Nested depth at LOC, which determines the face to use.
MATCH For a mismatched glyph, MATCH is `nil'."
(let ( (face (funcall select-typeface depth match)) )
(when face
(font-lock-prepend-text-property loc (1+ loc) 'face face) )))