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!
I figured it out. Turns out I had cloned an old branch of org-mode which was missing the org-block-background
variable! Deleted my org-mode folder and reinstalled using:
cd ~/.emacs.d/lisp
git clone https://github.com/Konubinix/org-mode.git
cd org-mode
make autoloads
make
make doc
Then revised my init.el to read:
;;;----- 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-background
'((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)
And presto!