I am trying to do exactly this for my C code, but once I edit latex, the setting is still active in uncomfortable places. I need to preserve the setting once I exit emacs and in all the buffers with C code.
How can I restrict the behavior to only buffers with C code?
This is what I have in .emacs
(defun my-c-mode-faces ()
'(font-lock-comment-face ((t (:foreground "dark gray"))))
'(font-lock-function-name-face ((t (:foreground "#fce94f" :weight bold :height 1.5))))
'(font-lock-keyword-face ((t (:foreground "#b4fa70" :weight bold)))))
(add-hook 'c-mode-hook 'my-c-mode-faces)
face-remap-add-relative)
with a major-mode-hook: https://stackoverflow.com/a/28008006/2112489 . The O.P. would probably want to use thec-mode-hook
, but C-mode uses a few additional hooks that could also potentially be used. – lawlist May 30 '18 at 03:28c-mode-hook
as it relates to the second example (with the desired face), then you will be all set. Every time you open a buffer in c-mode or switch to c-mode, theface-remapping-alist
variable will be set accordingly and the face will be buffer-local. As in the famous old commercial with Life cereal -- "try it, you'll like it". If you actually try the second linked example with thec-mode-hook
as it relates to the desired face, and if you really have problems, then edit your question to show what you have tried ... – lawlist May 30 '18 at 06:53