By default font-lock-variable-name-face
is defined as follows:
'(font-lock-variable-name-face ((t (:foreground "black" :weight bold))))
Would it be possible to change its color for different modes such as for shell-mode
:
I have tried the following, which did not have any effect:
(add-hook 'shell-mode-hook
(lambda ()
'(font-lock-variable-name-face ((t (:foreground "LightGoldenrod" :weight bold))))))
dracula-theme.el
is located under ~/.emacs.d/themes
: https://github.com/dracula/emacs/blob/master/dracula-theme.el
minimal.el:
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'dracula t)
(defun my-shell-mode-faces ()
(face-remap-add-relative 'font-lock-variable-name-face '(:foreground "LightGoldenrod" :weight bold)))
(add-hook 'shell-mode-hook 'my-shell-mode-faces)
shell-mode
buffer with thefont-lock-variable-name-face
? I tried a few things likemake
,ls
,grep
, andvi
of a few different files -- but none of those produce output with thefont-lock-variable-name-face
.sh
like:test.sh
. Its just aShell-script
file. Example file can contain something like:#!/bin/bash RED="\033[1;31m"
whereRED
should be inLightGoldenrod
colortest.sh
, with the first line being#!/bin/bash RED="\033[1;31m"
STEP #2: Open the filetest.sh
and place the cursor on the wordRED
in the first line and typeC-u C-x =
and a*Help*
buffer pops up telling us that this isfont-lock-comment-face
. STEP #3: From the buffer containing thetest.sh
file, typeC-h m
, which is also known asM-x describe-mode
-- this opens a*Help*
buffer that tells us this is shell-script mode defined insh-script.el
-- follow the link forsh-script.el
in the*Help*
buffer ....sh-mode
. Based thereon, we conclude that the major-mode hook we are interested in issh-mode-hook
. CONCLUSION: From steps 1 to 3 above, we learned that the face isfont-lock-comment-face
and the major-mode hook issh-mode-hook
. Therefore, adjust the example in the answer below accordingly to suit your own needs using the relevant face and the relevant hook.