I am trying to change the background color of R code blocks in Org-mode 8. In Org-mode 7, I was able to use:
(defface org-block-background
'((t (:background "#dadada")))
"Face used for the source block background.")
But the org-block-background
variable seems to have disappeared in version 8...?
I tried:
(defface org-block
'((t (:background "#dadada")))
"Face used for the source block background.")
which works for:
#+BEGIN_SRC
#+END_SRC
and
#+BEGIN_latex
#+END_latex
But for some reason, the background color disappears, the moment I specify a language, e.g...
#+BEGIN_SRC R
#+END_SRC
I am working on a mac, running Emacs 24.3 and have upgraded org-mode to v8, using:
cd ~/.emacs.d/lisp
git clone git://orgmode.org/org-mode.git
cd org-mode
make autoloads
make
make doc
Here is the config from my init.el file:
;;;----- Startup ----------------------------;
;;; Add src directory to path
(add-to-list 'load-path "~/.emacs.d/lisp/")
;;;----- Org-Mode ---------------------------;
;;; Add upgraded org-mode to load path
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/lisp")
(add-to-list 'load-path "~/.emacs.d/lisp/org-mode/contrib/lisp" t)
;;; fontify code in code blocks
(setq org-src-fontify-natively t)
(defface org-block-begin-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the begin of source blocks.")
(defface org-block
'((t (:background "#dadada")))
"Face used for the source block background.")
(defface org-block-end-line
'((t (:foreground "#666666" :background "#dadada")))
"Face used for the line delimiting the end of source blocks.")
(require 'org)
;;;----- ESS/R ------------------------------;
(add-to-list 'load-path "~/.emacs.d/lisp/ess/lisp/")
(load "ess-site")
;;;------ Babel ------------------------------;
;;; Support R
(org-babel-do-load-languages
'org-babel-load-languages
'((R . t)
(latex . t)))
;;;----- Look & feel ----------------------------;
;;; Set default theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'solarized-light t)
Any ideas?
Thanks!
FYI, this will not work for current versions of Org Mode (from the Git master branch), after this commit http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=f8b42e8 - at least until something changes. This is announced here (July, 2014) and continues to be in effect for Org Mode users, e.g. see here (April, 2015). Anyone dedicated to restoring the old behavior locally might be able to do it from the commit's diff - I haven't tried. Future versions of Org Mode may restore the feature, possibly going about it in a different way. For now, this is about all you can get:
(The first SRC block above gets a background from my setting for org-block
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With