I have this code:
(add-hook
'org-mode-hook
(lambda ()
(when (string-match "notes\\.org$" buffer-file-name)
(face-remap-add-relative 'default :background "yellow"))))
and it should change the background color of the buffer where is notes.org
file.
However, it doesn't work.
I have tried this as well:
(add-hook
'org-mode-hook
(lambda ()
(when (string-match "notes\\.org$" buffer-file-name)
(set-face-attribute 'default nil :background "yellow"))))
But it is still not working.
The echo area says if: Wrong type argument: stringp, nil
Any idea what am I doing wrong?
... (when (and (not (null buffer-file-name)) (string-match-p "notes\\.org$" buffer-file-name)) ...) ...
(add-hook 'org-mode-hook (lambda () (when (and (not (null buffer-file-name)) (string-match-p "notes\\.org$" buffer-file-name)) (face-remap-add-relative 'default '(:foreground "black" :background "yellow")))))
(not (null X))
is the same asX
. ;-)