I would like to use a custom link, i.e. [[h:blue][blue highlighted text]], to create highlighted text. The background color of the highlighted text is specified by the path. I have

 :export (lambda (path desc backend)
    ((eq 'html backend)
     (format "<span style=\"background-color: %s\">%s</span>" path (or desc ""))
 ;:face `(:foreground ,(lambda (path) (format "%s" path)))
 :face '(:background "yellow")     

The export works as expected, but I need to hard-code the background face to make any sort of highlighting. How can I fix this statement?

 :face `(:foreground ,(lambda (path) (format "%s" path)))

so the path can specify the color in emacs?

  • Did you look at org macros? It seems like you could use a macro to do this markup as well. Is there an advantage to creating a custom link vs a macro? Thanks.
    – Melioratus
    Commented May 20 at 15:09

1 Answer 1


Here's my answer

(defun path-color (path)
  (list :background path))

then update the face statement to

 :face 'path-color

I based my answer by reviewing the last example of http://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9/. I don't understand why list is needed.

  • you don't "need' a list, you could also return `(:background ,path) I think. Commented May 18, 2019 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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