2

The face org-block-begin-line allows to customize the first line of the following block

#+BEGIN_SRC lang :var arg1=1 arg2=2 ... #+END_SRC 

However, I would like to customize the faces within the line, by highlighting the lang, and certain properties, like highlighting only arg2=2.

Digging further, we can see that the use of the face is done within (org-fontify-meta-lines-and-blocks-1). But nothing there seems to allow to split the line in several blocks, and even less by doing it conditionally.

Something similar was proposed by rasmus ( https://pank.eu/blog/pretty-babel-src-blocks.html ) to implement further modification on the line, but this is not quite what I am looking for.

Might there be a package already available out there to add some colors // apply some regexp on this line ?

Also, it might be interesting if the same rules could apply on an inline src_lang() and a #+CALL: type of line.

1 Answer 1

0

I am not a fan on my approach, but I ended up redefining (org-fontify-meta-lines-and-blocks-1). I am posting the idea here :

(defun org-fontify-meta-lines-and-blocks-1 (limit) "Fontify #+ lines and blocks." (let ((case-fold-search t)) (when (re-search-forward "^\\([ \t]*#\\(\\(\\+[a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\(\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)\\)" limit t) (let ((beg (match-beginning 0)) (block-start (match-end 0)) (block-end nil) (lang (match-string 7)) ;; -- Aurix addon -- (beglang (match-beginning 7)) (endlang (match-end 7)) (meta (match-string 8)) (begmeta (match-beginning 8)) ;; ----------------- ;; ... ;; -- Aurix addon -- (when (equal lang "my-lang") (add-text-properties beglang endlang '(face my-lang-face)) (when (string-match ":var[ \t]+arg1=\"\\([^\"]+\\)\"" meta) (let ((begt (+ begmeta (match-beginning 1))) (endt (+ begmeta (match-end 1)))) (add-text-properties begt endt '(face my-arg1-face)) ) ) ;; ... ) ;; ----------------- t)) ;; ... )))) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.