* custom-set-faces for various file types @ 2020-11-22 17:30 Christopher Dimech 2020-11-22 20:57 ` Michael Heerdegen 0 siblings, 1 reply; 9+ messages in thread From: Christopher Dimech @ 2020-11-22 17:30 UTC (permalink / raw) To: Help Gnu Emacs I am setting custom-set-faces for various file types (e.g. .org). I see that emacs requires only one instance of custom-set-variables. When setting custom-set-faces for org mode, is it acceptable to put the custom-set-faces code for that file type in the corresponding org-init.el file (etc for other file types). Or is it a better strategy in have all custom-set-faces together? Regards Christopher ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 17:30 custom-set-faces for various file types Christopher Dimech @ 2020-11-22 20:57 ` Michael Heerdegen 2020-11-22 21:16 ` Christopher Dimech 0 siblings, 1 reply; 9+ messages in thread From: Michael Heerdegen @ 2020-11-22 20:57 UTC (permalink / raw) To: help-gnu-emacs Christopher Dimech <dimech@gmx.com> writes: > I am setting custom-set-faces for various file types (e.g. .org). > I see that emacs requires only one instance of custom-set-variables. > > When setting custom-set-faces for org mode, is it acceptable to put > the custom-set-faces code for that file type in the corresponding > org-init.el file (etc for other file types). > > Or is it a better strategy in have all custom-set-faces together? What is your goal? Faces looking differently depending on the major mode? Michael. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 20:57 ` Michael Heerdegen @ 2020-11-22 21:16 ` Christopher Dimech 2020-11-22 21:39 ` Michael Heerdegen 0 siblings, 1 reply; 9+ messages in thread From: Christopher Dimech @ 2020-11-22 21:16 UTC (permalink / raw) To: Michael Heerdegen; +Cc: help-gnu-emacs > Sent: Sunday, November 22, 2020 at 9:57 PM > From: "Michael Heerdegen" <michael_heerdegen@web.de> > To: help-gnu-emacs@gnu.org > Subject: Re: custom-set-faces for various file types > > Christopher Dimech <dimech@gmx.com> writes: > > > I am setting custom-set-faces for various file types (e.g. .org). > > I see that emacs requires only one instance of custom-set-variables. > > > > When setting custom-set-faces for org mode, is it acceptable to put > > the custom-set-faces code for that file type in the corresponding > > org-init.el file (etc for other file types). > > > > Or is it a better strategy in have all custom-set-faces together? > > What is your goal? Faces looking differently depending on the major > mode? I would like that some special constructs are highligthed so that the contrast would be suitable for assistive reasons. For instance, in current texinfo modes, constructs in pure tex do not get highlighted. So I have some code that uses custom-set-faces in texi-init.el. The Manual says that custom-set-variables must be only called once. I can call it once in emacs-init.el, then call custom-set-faces in each major mode init file where I would like a change. Another possibility is to put them all together in emacs-init.el that sets the highlighting, even though I would also have separate org-init.el, texi-init.el, and so on. > Michael. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 21:16 ` Christopher Dimech @ 2020-11-22 21:39 ` Michael Heerdegen 2020-11-22 22:04 ` Christopher Dimech 2020-11-22 22:10 ` Christopher Dimech 0 siblings, 2 replies; 9+ messages in thread From: Michael Heerdegen @ 2020-11-22 21:39 UTC (permalink / raw) To: help-gnu-emacs Christopher Dimech <dimech@gmx.com> writes: > > What is your goal? Faces looking differently depending on the major > > mode? > > I would like that some special constructs are highligthed so that the > contrast would be suitable for assistive reasons. For instance, in > current texinfo modes, constructs in pure tex do not get highlighted. > So I have some code that uses custom-set-faces in texi-init.el. > > The Manual says that custom-set-variables must be only called once. > [...] I don't think custom is the right tool for your purpose. Face definitions are global. You can switch between settings ("themes"), but the effect is always global. For texinfo, maybe you could instead change the font-locking of the mode? It's defined in `texinfo-font-lock-keywords'. Maybe it's enough to add an entry to that list? Emacs also supports per-buffer modifications of faces. The mechanism is called "face-remap". You could use it in the mode's hooks to change how a face looks like in buffers using that mode. `face-remap-add-relative' is the function to use, takes a face and a list of specs. Using that would be a cleaner solution for your case I think. Michael. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 21:39 ` Michael Heerdegen @ 2020-11-22 22:04 ` Christopher Dimech 2020-11-22 22:10 ` Christopher Dimech 1 sibling, 0 replies; 9+ messages in thread From: Christopher Dimech @ 2020-11-22 22:04 UTC (permalink / raw) To: Michael Heerdegen; +Cc: help-gnu-emacs I was using this for org mode (custom-set-faces '(org-level-1 ((t (:foreground "cyan1")))) '(org-level-2 ((t (:foreground "chartreuse")))) '(org-level-3 ((t (:foreground "dark orange")))) '(org-level-4 ((t (:foreground "yellow")))) '(org-level-5 ((t (:foreground "magenta")))) '(org-level-6 ((t (:foreground "tan1")))) '(org-level-7 ((t (:foreground "deep sky blue")))) '(org-level-8 ((t (:foreground "orange red")))) ) > Sent: Sunday, November 22, 2020 at 10:39 PM > From: "Michael Heerdegen" <michael_heerdegen@web.de> > To: help-gnu-emacs@gnu.org > Subject: Re: custom-set-faces for various file types > > Christopher Dimech <dimech@gmx.com> writes: > > > > What is your goal? Faces looking differently depending on the major > > > mode? > > > > I would like that some special constructs are highligthed so that the > > contrast would be suitable for assistive reasons. For instance, in > > current texinfo modes, constructs in pure tex do not get highlighted. > > So I have some code that uses custom-set-faces in texi-init.el. > > > > The Manual says that custom-set-variables must be only called once. > > [...] > > I don't think custom is the right tool for your purpose. Face > definitions are global. You can switch between settings ("themes"), but > the effect is always global. > > For texinfo, maybe you could instead change the font-locking of the > mode? It's defined in `texinfo-font-lock-keywords'. Maybe it's enough > to add an entry to that list? > > Emacs also supports per-buffer modifications of faces. The mechanism is > called "face-remap". You could use it in the mode's hooks to change how > a face looks like in buffers using that mode. `face-remap-add-relative' > is the function to use, takes a face and a list of specs. Using that > would be a cleaner solution for your case I think. > > Michael. > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 21:39 ` Michael Heerdegen 2020-11-22 22:04 ` Christopher Dimech @ 2020-11-22 22:10 ` Christopher Dimech 2020-11-22 22:53 ` Christopher Dimech 1 sibling, 1 reply; 9+ messages in thread From: Christopher Dimech @ 2020-11-22 22:10 UTC (permalink / raw) To: Michael Heerdegen; +Cc: help-gnu-emacs Could you help me redo the following using face-remap (add-hook 'texinfo-mode-hook (custom-set-faces '(font-lock-variable-name-face ((t (:foreground "green")))) '(font-lock-builtin-face ((t (:foreground "green")))) )) ;; ---------------------------------------------------------------------- ;; Colourise Texinfo Outlines Levels (Chapters, Sections, Headlines) (custom-set-faces '(texinfo-heading ((t (:inherit font-lock-function-name-face :foreground "#ffdd00"))) )) ;; ---------------------------------------------------------------------- ;; Colourise Org-Mode Heading Levels (custom-set-faces '(org-level-1 ((t (:foreground "cyan1")))) '(org-level-2 ((t (:foreground "chartreuse")))) '(org-level-3 ((t (:foreground "dark orange")))) '(org-level-4 ((t (:foreground "yellow")))) '(org-level-5 ((t (:foreground "magenta")))) '(org-level-6 ((t (:foreground "tan1")))) '(org-level-7 ((t (:foreground "deep sky blue")))) '(org-level-8 ((t (:foreground "orange red")))) ) > Sent: Sunday, November 22, 2020 at 10:39 PM > From: "Michael Heerdegen" <michael_heerdegen@web.de> > To: help-gnu-emacs@gnu.org > Subject: Re: custom-set-faces for various file types > > Christopher Dimech <dimech@gmx.com> writes: > > > > What is your goal? Faces looking differently depending on the major > > > mode? > > > > I would like that some special constructs are highligthed so that the > > contrast would be suitable for assistive reasons. For instance, in > > current texinfo modes, constructs in pure tex do not get highlighted. > > So I have some code that uses custom-set-faces in texi-init.el. > > > > The Manual says that custom-set-variables must be only called once. > > [...] > > I don't think custom is the right tool for your purpose. Face > definitions are global. You can switch between settings ("themes"), but > the effect is always global. > > For texinfo, maybe you could instead change the font-locking of the > mode? It's defined in `texinfo-font-lock-keywords'. Maybe it's enough > to add an entry to that list? > > Emacs also supports per-buffer modifications of faces. The mechanism is > called "face-remap". You could use it in the mode's hooks to change how > a face looks like in buffers using that mode. `face-remap-add-relative' > is the function to use, takes a face and a list of specs. Using that > would be a cleaner solution for your case I think. > > Michael. > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 22:10 ` Christopher Dimech @ 2020-11-22 22:53 ` Christopher Dimech 2020-11-22 23:38 ` Michael Heerdegen 0 siblings, 1 reply; 9+ messages in thread From: Christopher Dimech @ 2020-11-22 22:53 UTC (permalink / raw) To: Christopher Dimech; +Cc: Michael Heerdegen, help-gnu-emacs Would this be good (add-hook 'org-mode-hook (lambda () (face-remap-add-relative '(org-level-1 ((t (:foreground "cyan1")))) '(org-level-2 ((t (:foreground "chartreuse")))) '(org-level-3 ((t (:foreground "dark orange")))) '(org-level-4 ((t (:foreground "yellow")))) '(org-level-5 ((t (:foreground "magenta")))) '(org-level-6 ((t (:foreground "tan1")))) '(org-level-7 ((t (:foreground "deep sky blue")))) '(org-level-8 ((t (:foreground "orange red")))) ))) > Sent: Sunday, November 22, 2020 at 11:10 PM > From: "Christopher Dimech" <dimech@gmx.com> > To: "Michael Heerdegen" <michael_heerdegen@web.de> > Cc: help-gnu-emacs@gnu.org > Subject: Re: custom-set-faces for various file types > > Could you help me redo the following using face-remap > > (add-hook 'texinfo-mode-hook > (custom-set-faces > '(font-lock-variable-name-face ((t (:foreground "green")))) > '(font-lock-builtin-face ((t (:foreground "green")))) )) > > ;; ---------------------------------------------------------------------- > ;; Colourise Texinfo Outlines Levels (Chapters, Sections, Headlines) > (custom-set-faces > '(texinfo-heading > ((t (:inherit font-lock-function-name-face > :foreground "#ffdd00"))) )) > > ;; ---------------------------------------------------------------------- > ;; Colourise Org-Mode Heading Levels > (custom-set-faces > '(org-level-1 ((t (:foreground "cyan1")))) > '(org-level-2 ((t (:foreground "chartreuse")))) > '(org-level-3 ((t (:foreground "dark orange")))) > '(org-level-4 ((t (:foreground "yellow")))) > '(org-level-5 ((t (:foreground "magenta")))) > '(org-level-6 ((t (:foreground "tan1")))) > '(org-level-7 ((t (:foreground "deep sky blue")))) > '(org-level-8 ((t (:foreground "orange red")))) ) > > > > > Sent: Sunday, November 22, 2020 at 10:39 PM > > From: "Michael Heerdegen" <michael_heerdegen@web.de> > > To: help-gnu-emacs@gnu.org > > Subject: Re: custom-set-faces for various file types > > > > Christopher Dimech <dimech@gmx.com> writes: > > > > > > What is your goal? Faces looking differently depending on the major > > > > mode? > > > > > > I would like that some special constructs are highligthed so that the > > > contrast would be suitable for assistive reasons. For instance, in > > > current texinfo modes, constructs in pure tex do not get highlighted. > > > So I have some code that uses custom-set-faces in texi-init.el. > > > > > > The Manual says that custom-set-variables must be only called once. > > > [...] > > > > I don't think custom is the right tool for your purpose. Face > > definitions are global. You can switch between settings ("themes"), but > > the effect is always global. > > > > For texinfo, maybe you could instead change the font-locking of the > > mode? It's defined in `texinfo-font-lock-keywords'. Maybe it's enough > > to add an entry to that list? > > > > Emacs also supports per-buffer modifications of faces. The mechanism is > > called "face-remap". You could use it in the mode's hooks to change how > > a face looks like in buffers using that mode. `face-remap-add-relative' > > is the function to use, takes a face and a list of specs. Using that > > would be a cleaner solution for your case I think. > > > > Michael. > > > > > > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 22:53 ` Christopher Dimech @ 2020-11-22 23:38 ` Michael Heerdegen 2020-11-22 23:52 ` Christopher Dimech 0 siblings, 1 reply; 9+ messages in thread From: Michael Heerdegen @ 2020-11-22 23:38 UTC (permalink / raw) To: Christopher Dimech; +Cc: help-gnu-emacs Christopher Dimech <dimech@gmx.com> writes: > Would this be good > > (add-hook 'org-mode-hook > (lambda () > (face-remap-add-relative > '(org-level-1 ((t (:foreground "cyan1")))) > '(org-level-2 ((t (:foreground "chartreuse")))) > '(org-level-3 ((t (:foreground "dark orange")))) > '(org-level-4 ((t (:foreground "yellow")))) > '(org-level-5 ((t (:foreground "magenta")))) > '(org-level-6 ((t (:foreground "tan1")))) > '(org-level-7 ((t (:foreground "deep sky blue")))) > '(org-level-8 ((t (:foreground "orange red")))) ))) So far you only showed settings of different, mode specific faces. Your situation seems to be less complex than I understood, and you don't need face remapping for these examples; simple `face-spec-set' calls are good enough. BTW, as far as I recall, if you know what your are doing, it is even ok to have multiple `custom-set-faces' calls in your init file. I don't recall what happens when your custom file gets written, probably it will save your settings a second time there, and that may cause trouble (only later, much later...) So, for your init file, `face-spec-set' is better, and for per mode settings of the faces shared by several modes, you want to use face remapping. `text-scale-mode' is such a use case, for example (it modifies the `default' face, i.e., by inheriting, mostly all faces, buffer locally). Michael. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: custom-set-faces for various file types 2020-11-22 23:38 ` Michael Heerdegen @ 2020-11-22 23:52 ` Christopher Dimech 0 siblings, 0 replies; 9+ messages in thread From: Christopher Dimech @ 2020-11-22 23:52 UTC (permalink / raw) To: Michael Heerdegen; +Cc: help-gnu-emacs > Sent: Monday, November 23, 2020 at 12:38 AM > From: "Michael Heerdegen" <michael_heerdegen@web.de> > To: "Christopher Dimech" <dimech@gmx.com> > Cc: help-gnu-emacs@gnu.org > Subject: Re: custom-set-faces for various file types > > Christopher Dimech <dimech@gmx.com> writes: > > > Would this be good > > > > (add-hook 'org-mode-hook > > (lambda () > > (face-remap-add-relative > > '(org-level-1 ((t (:foreground "cyan1")))) > > '(org-level-2 ((t (:foreground "chartreuse")))) > > '(org-level-3 ((t (:foreground "dark orange")))) > > '(org-level-4 ((t (:foreground "yellow")))) > > '(org-level-5 ((t (:foreground "magenta")))) > > '(org-level-6 ((t (:foreground "tan1")))) > > '(org-level-7 ((t (:foreground "deep sky blue")))) > > '(org-level-8 ((t (:foreground "orange red")))) ))) > > So far you only showed settings of different, mode specific faces. Your > situation seems to be less complex than I understood, and you don't need > face remapping for these examples; simple `face-spec-set' calls are good > enough. Correct. They are already mode specific. Still I might need to change others and would have a good system. It would also help others making modifications without having to figure out what to do. Still, as you suggest I can code tho part for mode specific faces differently. Then others can find a number of different constructs to learn from, rather than just one way that simply solve mp problems. > BTW, as far as I recall, if you know what your are doing, it is even ok > to have multiple `custom-set-faces' calls in your init file. I don't > recall what happens when your custom file gets written, probably it will > save your settings a second time there, and that may cause trouble (only > later, much later...) > > So, for your init file, `face-spec-set' is better, and for per mode > settings of the faces shared by several modes, you want to use face > remapping. `text-scale-mode' is such a use case, for example (it > modifies the `default' face, i.e., by inheriting, mostly all faces, > buffer locally). > > > Michael. > > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-11-22 23:52 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-11-22 17:30 custom-set-faces for various file types Christopher Dimech 2020-11-22 20:57 ` Michael Heerdegen 2020-11-22 21:16 ` Christopher Dimech 2020-11-22 21:39 ` Michael Heerdegen 2020-11-22 22:04 ` Christopher Dimech 2020-11-22 22:10 ` Christopher Dimech 2020-11-22 22:53 ` Christopher Dimech 2020-11-22 23:38 ` Michael Heerdegen 2020-11-22 23:52 ` Christopher Dimech
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.