5

I would like as said in the title customize colors of the differents levels in org-mode. I have tried from the customize-group menu then org-face but it looks like I can't change colors there. So, I've to do it manually but what shall I add in my .init.el file ? I've added the package color-theme and tried smth like this :

 (org-level-1 ((t (:foreground "yellow"))))

but I get the follwing error :

Symbol's function definition is void: org-level-1

Unfortunateley I'm quite new to debugging with Emacs...Thanks in advance.

  • Looks like a duplicate, but I don't have time to track it down... – Drew Sep 2 '16 at 18:14
3

I think your main problem here is actually you do not consider org-level-1 the face but org-level-1 the function (which is not existing as the error message indicates it). You can use something like that to customize in your init file

(custom-theme-set-faces 'user
                        `(org-level-1 ((t (:foreground "yellow")))))
  • my/org-mode-hook (above) didn't work for me, but this one did! – Phil Mitchell Oct 8 '16 at 18:29
2

You can customise the colours of different levels with the following steps:

M-x customize <RET>

Then in the search box, enter org level 1 and hit Search button. Then you can see Org level 1 face through Org level 8 face. Expand the nodes you want to modify and set the attributes as you want.

Don't forget to save the result with Save for future session.

2

You could also make a your own hook for org-mode. That way you could set multiple faces inside the hook and they will all be loaded after org-mode.

(defun my/org-mode-hook ()
  "My `org-mode' hook"
  (set-face-attribute org-level-1 nil :foreground "yellow")
  (set-face-attribute org-level-2 nil :foreground "blue"))  ; just add to the list

(add-hook 'org-mode-hook 'my/org-mode-hook)
  • Consider using an (eval-after-load "org" '(progn . . .)) statement instead of putting this on the org-mode-hook -- the latter potentially gets called a zillion times each Emacs session (e.g., every time an org-mode buffer is created), whereas the former will only do this customization/setup one time. Once its done, its done -- no need to do it more than one time per Emacs session. – lawlist Sep 2 '16 at 14:57
  • 2
    And consider setting the second argument of set-face-attribute to nil (instead of t) so that it applies to all frames (existing frames, and also future new frames). See the doc-string for set-face-attribute. – lawlist Sep 2 '16 at 15:05
  • @lawlist I have the second argument set as nil in my own config, though I was mirroring @loukios own choice of t, I'll change it in the anwser. – lookyhooky Sep 2 '16 at 18:18
  • If using a theme, would you need to insure it is loaded before org-mode when using the eval-after-load method? Some themes modify the face attributes of org-mode. – lookyhooky Sep 3 '16 at 16:18
  • There have been a lot of inquiries over the past year about the non-existence of a hook that runs after a theme loads, and the last I checked, there was still no such hook. A user named pkkm has added a hook to load-theme using defadvice: reddit.com/r/emacs/comments/4v7tcj/… (defvar after-load-theme-hook nil "Hook run after a color theme is loaded using 'load-theme'.") (defadvice load-theme (after run-after-load-theme-hook activate) "Run 'after-load-theme-hook'." (run-hooks 'after-load-theme-hook)) – lawlist Sep 3 '16 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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