1

I wish to map the text properties onto a list and them insert them on a new buffer. For some reason the following snippet doesn't work. I've used the -map utility from dash.el package for the map.

    (-map
 (lambda (x) (insert (propertize "a"
                     'font-lock-face
                     '(:foreground x))))

 '("red" "green" "orange"))

I wish to achieve something like this

enter image description here

1

I am not familiar with using the dash library, but the problem likely has to do with using a single quote for the list of face properties instead of using a backtick/comma combination.

(mapc
  (lambda (x) (insert (propertize "a" 'face `(:foreground ,x))))
  '("red" "green" "orange"))

Here is an alternative to the backtick/comma list format, which uses the function list:

(mapc
  (lambda (x) (insert (propertize "a" 'face (list :foreground x))))
  '("red" "green" "orange"))

I have not delved into the usages of the font-lock-face property described in the manual, so I just used face for this example since I am more familiar with it. https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Properties.html#Special-Properties


Here are links to the manual for the quote versus the backquote:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Quoting.html#Quoting

https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html#Backquote

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.