0

Customise org-babel source block color such that:

  1. when the block is folded, the #+begin_src line is the default color
  2. when the block is open, the #+begin_src and #+end_src lines are highlighted a different color.

I include many src blocks in my files, which are mostly collapsed, so I would like some highlighting to draw my attention to location of the block that is open.

1 Answer 1

0

What if you call M-x, m, set-background-color, LightYellow? A cheap trick. However, it may be easier, than tracking down those particular faces and custom changing them in an org-mode hook?

Define a key-binding to set-background-color or add to your init.el file?


Try in init.el:

 (add-hook 'org-mode-hook
      (lambda () (if (window-system) (progn (custom-set-faces
          '(org-block-begin-line ((t (:underline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF" :extend t))))
          '(org-block ((t (:background "#EFF0F1" :extend t))))
          '(org-block-end-line ((t (:overline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF" :extend t))))
) ))
  ))

Like the 2nd answer in this SE post. orgmode - change code block background color

1
  • I don't know what the 'm' means in M-x m set-background-color LightYellow. If i just use M-x set-background-color LightYellow the entire emacs background changes, not just the background of the lines beginning and ending the block.
    – user615536
    Aug 2, 2022 at 12:11

Your Answer

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

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