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!
C-u C-x =
, and that will tell you (among other things) the name of the fonts at that point. Then you canM-x customize-face
the font you want to change, or manually change it in your.emacs
file. - lawlistface:org-block
property...? - Adamorg-block
(e.g., "Face text in #+begin ... #+end blocks.") and see if that helps --M-x customize-face RET org-block RET
On my Emacs-Trunk developer snapshot, it shows inheritingshadow
. So you can remove the inheriting and set it to whatever you want, or modifyshadow
instead. - lawlist.emacs
file and take a peek regarding how it is customized as toorg-block
orshadow
depending upon which you decided. Then you can copy that relevant section over to yourinit.el
and get rid of your.emacs
file if everything is already in yourinit.el
. Back it up of course (just in case . . .), before you dust it. - lawlistorg-block-background
face has been removed in org 8.3.1 Currently it seems the only way to get this behavior back if you're using the old version is to manually reverse the change introduced. See my answer. - xji