reddit / emacs

Change set-face-attribute for a specific theme permanently

pragmat1c1 · 2022-05-18 08:51
I am using Protesilaos Stavrou's excellent modus-themes, and I am loving it. Now I'd like to add a gray background to code blocks in org-files, and I can make it work with the code below, but whenever I re-open a buffer, I need to re-evaluate the code below. How can I make the change permanent, without re-evaluationg my `init.el` file constantly? ;;;; add colors to code and quote blocks (setq org-fontify-quote-and-verse-blocks t) ;; https://stackoverflow.com/questions/44811679/orgmode-change-code-block-background-color ;; The example below will darken the code block by 4 percent (notice the number 4 at the last parameter) relative to the background color of your emacs theme. However, if you change your theme during editing the color of the code block will stay the same. (require 'color) (set-face-attribute 'org-block nil :background (color-darken-name (face-attribute 'default :background) 4)) ;; 4% darker ## Edit Apparently the theme comes with lots of customization options, see here: https://elpa.gnu.org/packages/modus-themes.html So `M-x customize-variable RET modus-themes-org-blocks RET` give me the option to change the background of org-blocks.
mrolivertaylor · 2022-05-18 16:30
The modus themes are very customizable. Here's my setup: (custom-set-variables '(modus-themes-mixed-fonts t) '(modus-themes-italic-constructs t) '(modus-themes-links '(neutral-underline)) '(modus-themes-org-blocks 'gray-background) '(modus-themes-org-agenda '((header-block . (variable-pitch 1.6)) (header-date . (bold-today)) (scheduled . rainbow)))) (custom-set-variables '(modus-themes-vivendi-color-overrides '((bg-main . "#24242d") (bg-inactive . "#2f2f3b") (bg-hl-line . "#2f2f3b")))) (defun disable-current-themes nil "Disables all currently enabled themes." (interactive) (if custom-enabled-themes (mapcar 'disable-theme custom-enabled-themes))) (defun load-custom-modus-vivendi nil (custom-set-variables '(modus-themes-mode-line '(accented borderless)) '(modus-themes-syntax '(yellow-comments faint))) (disable-current-themes) (modus-themes-load-vivendi)) (defun load-custom-modus-operandi nil (custom-set-variables '(modus-themes-mode-line nil) '(modus-themes-syntax nil)) (disable-current-themes) (modus-themes-load-operandi))
pragmat1c1 · 2022-05-18 18:40
Excellent setup. Learned new things. Thank you.