* emacs settings priority
@ 2024-04-05 7:17 crstml
2024-04-05 12:10 ` Eli Zaretskii
0 siblings, 1 reply; 10+ messages in thread
From: crstml @ 2024-04-05 7:17 UTC (permalink / raw)
To: help-gnu-emacs
Hello all
I have some issues when I want to set the fonts in emacs and I
think that they are related to the priority of the various means
(X resource, command line, init file) used for that.
I've tried without success to find in the manual information
about these priorities/precedences.
Is it possible to know how emacs decides what font is used when the
same font is specified in more places: X resource, command line,
init file?
But the question can also be generalized to other properties not
only for fonts.
Thank you in advance
Cristian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-05 7:17 emacs settings priority crstml
@ 2024-04-05 12:10 ` Eli Zaretskii
2024-04-05 16:07 ` crstml
0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2024-04-05 12:10 UTC (permalink / raw)
To: help-gnu-emacs
> From: crstml@libero.it
> Date: Fri, 5 Apr 2024 09:17:38 +0200
>
> Hello all
>
> I have some issues when I want to set the fonts in emacs and I
> think that they are related to the priority of the various means
> (X resource, command line, init file) used for that.
>
> I've tried without success to find in the manual information
> about these priorities/precedences.
>
> Is it possible to know how emacs decides what font is used when the
> same font is specified in more places: X resource, command line,
> init file?
Why is it important to know? Users aren't supposed to specify
contradictory setting via several different means of doing so.
Anyway, some information about this can be found in "Startup Summary"
node of the ELisp reference manual, which describes the order in which
the various stages of the initialization happen.
> But the question can also be generalized to other properties not
> only for fonts.
There's no generalized answer.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-05 12:10 ` Eli Zaretskii
@ 2024-04-05 16:07 ` crstml
2024-04-05 17:14 ` Eli Zaretskii
0 siblings, 1 reply; 10+ messages in thread
From: crstml @ 2024-04-05 16:07 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs
Eli Zaretskii wrote:
>> From: crstml@libero.it
>> Date: Fri, 5 Apr 2024 09:17:38 +0200
>>
>> Hello all
>>
>> I have some issues when I want to set the fonts in emacs and I
>> think that they are related to the priority of the various means
>> (X resource, command line, init file) used for that.
>>
>> I've tried without success to find in the manual information
>> about these priorities/precedences.
>>
>> Is it possible to know how emacs decides what font is used when the
>> same font is specified in more places: X resource, command line,
>> init file?
> Why is it important to know?
When a user specify some setting in the command line for example he expects
some feedback from the application. If the effect of that setting is not visible
the user must understand the cause.
> Users aren't supposed to specify
> contradictory setting via several different means of doing so.
Is the fact that the users aren't supposed to specify different settings
via several different means an overall design decision? If yes, then the
users should be aware of this decision and it should be specified in the
manual.
But (personal opinion based on my way of using emacs) such a design decision
is not very wise. Users must be able to control how the settings are applied
or what are the causes of their impossibility of specifying settings.
Maybe I want to start an instance of emacs with a different background color
and font size in a certain context (using the command line or a context
dependent configuration file) and I see that these settings are not applied.
How can I understand why not or what can I do?
>
> Anyway, some information about this can be found in "Startup Summary"
> node of the ELisp reference manual, which describes the order in which
> the various stages of the initialization happen.
>
>> But the question can also be generalized to other properties not
>> only for fonts.
> There's no generalized answer.
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-05 16:07 ` crstml
@ 2024-04-05 17:14 ` Eli Zaretskii
2024-04-06 12:58 ` crstml
0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2024-04-05 17:14 UTC (permalink / raw)
To: help-gnu-emacs
> From: crstml@libero.it
> Date: Fri, 5 Apr 2024 18:07:57 +0200
>
> Eli Zaretskii wrote:
> >>
> >> I've tried without success to find in the manual information
> >> about these priorities/precedences.
> >>
> >> Is it possible to know how emacs decides what font is used when the
> >> same font is specified in more places: X resource, command line,
> >> init file?
> > Why is it important to know?
> When a user specify some setting in the command line for example he expects
> some feedback from the application. If the effect of that setting is not visible
> the user must understand the cause.
If you can describe a situation where a setting from the command line
didn't have any effect, please do.
> > Users aren't supposed to specify
> > contradictory setting via several different means of doing so.
> Is the fact that the users aren't supposed to specify different settings
> via several different means an overall design decision? If yes, then the
> users should be aware of this decision and it should be specified in the
> manual.
>
> But (personal opinion based on my way of using emacs) such a design decision
> is not very wise. Users must be able to control how the settings are applied
> or what are the causes of their impossibility of specifying settings.
>
> Maybe I want to start an instance of emacs with a different background color
> and font size in a certain context (using the command line or a context
> dependent configuration file) and I see that these settings are not applied.
>
> How can I understand why not or what can I do?
Please describe a specific situation where this happens, and let's
take it from there. You seem to be talking about some general
principles, and I'm not sure that is useful. In general, Emacs does
sensible things in these cases, so it isn't like the user is
completely in the dark.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-05 17:14 ` Eli Zaretskii
@ 2024-04-06 12:58 ` crstml
2024-04-06 16:07 ` Eli Zaretskii
2024-04-06 17:55 ` tpeplt
0 siblings, 2 replies; 10+ messages in thread
From: crstml @ 2024-04-06 12:58 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs
Eli Zaretskii wrote:
>> From: crstml@libero.it
>> Date: Fri, 5 Apr 2024 18:07:57 +0200
>>
>> Eli Zaretskii wrote:
>>>> I've tried without success to find in the manual information
>>>> about these priorities/precedences.
>>>>
>>>> Is it possible to know how emacs decides what font is used when the
>>>> same font is specified in more places: X resource, command line,
>>>> init file?
>>> Why is it important to know?
>> When a user specify some setting in the command line for example he expects
>> some feedback from the application. If the effect of that setting is not visible
>> the user must understand the cause.
> If you can describe a situation where a setting from the command line
> didn't have any effect, please do.
Of course. Here is my configuration:
---- begin OS Version ----
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
Basically a clean Debian 12 installation.
---- end OS Version ----
---- begin ~/.emacs ----
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :extend nil :stipple nil :background "black" :foreground "gray" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal))))
'(font-lock-builtin-face ((t (:foreground "cornflower blue"))))
'(font-lock-comment-delimiter-face ((default (:inherit font-lock-comment-face)) (((class color) (min-colors 16)) nil)))
'(font-lock-comment-face ((t (:foreground "red"))))
'(font-lock-function-name-face ((((class color) (min-colors 88) (background dark)) (:foreground "gray" :weight bold))))
'(font-lock-keyword-face ((((class color) (min-colors 88) (background dark)) (:foreground "RoyalBlue"))))
'(font-lock-string-face ((((class color) (min-colors 88) (background dark)) (:foreground "orange"))))
'(font-lock-type-face ((((class color) (min-colors 88) (background dark)) (:foreground "darkslategray"))))
'(font-lock-variable-name-face ((t (:foreground "goldenrod"))))
'(mode-line ((((class color) (min-colors 88)) (:background "orange" :foreground "black")))))
;;No other contents is present in this file
;;
---- end ~/.emacs ----
Here are the tests:
1) Try the following command lines:
emacs -fn 10x20 &
emacs -fn lucidasanstypewriter-24 &
There is no difference between the emacs instances regarding the fonts.
2) Rename the .emacs to .emacs.disabled and run the same commands again.
mv .emacs .emacs.disabled
emacs -fn 10x20 &
emacs -fn lucidasanstypewriter-24 &
Now without the .emacs file the -fn command line option is taken
into account.
From these tests it's obvious that -fn has lower precedence than the .emacs
file. It turns that probably I always need to specify an init file in the
command line when I start emacs (if sometimes I want a different behavior).
Not that it's impossible or difficult. But I had to do some experiments to
understand what is going on and in the end I was interested if this stuff
is documented probably with some advice/best practices about how the users
should set up their environments.
>>> Users aren't supposed to specify
>>> contradictory setting via several different means of doing so.
>> Is the fact that the users aren't supposed to specify different settings
>> via several different means an overall design decision? If yes, then the
>> users should be aware of this decision and it should be specified in the
>> manual.
>>
>> But (personal opinion based on my way of using emacs) such a design decision
>> is not very wise. Users must be able to control how the settings are applied
>> or what are the causes of their impossibility of specifying settings.
>>
>> Maybe I want to start an instance of emacs with a different background color
>> and font size in a certain context (using the command line or a context
>> dependent configuration file) and I see that these settings are not applied.
>>
>> How can I understand why not or what can I do?
> Please describe a specific situation where this happens, and let's
> take it from there. You seem to be talking about some general
> principles, and I'm not sure that is useful. In general, Emacs does
> sensible things in these cases, so it isn't like the user is
> completely in the dark.
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-06 12:58 ` crstml
@ 2024-04-06 16:07 ` Eli Zaretskii
2024-04-08 14:52 ` crstml
2024-04-06 17:55 ` tpeplt
1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2024-04-06 16:07 UTC (permalink / raw)
To: help-gnu-emacs
> From: crstml@libero.it
> Date: Sat, 6 Apr 2024 14:58:57 +0200
>
> Eli Zaretskii wrote:
> (custom-set-faces
> ;; custom-set-faces was added by Custom.
> ;; If you edit it by hand, you could mess it up, so be careful.
> ;; Your init file should contain only one such instance.
> ;; If there is more than one, they won't work right.
> '(default ((t (:inherit nil :extend nil :stipple nil :background "black" :foreground "gray" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal))))
> '(font-lock-builtin-face ((t (:foreground "cornflower blue"))))
> '(font-lock-comment-delimiter-face ((default (:inherit font-lock-comment-face)) (((class color) (min-colors 16)) nil)))
> '(font-lock-comment-face ((t (:foreground "red"))))
> '(font-lock-function-name-face ((((class color) (min-colors 88) (background dark)) (:foreground "gray" :weight bold))))
> '(font-lock-keyword-face ((((class color) (min-colors 88) (background dark)) (:foreground "RoyalBlue"))))
> '(font-lock-string-face ((((class color) (min-colors 88) (background dark)) (:foreground "orange"))))
> '(font-lock-type-face ((((class color) (min-colors 88) (background dark)) (:foreground "darkslategray"))))
> '(font-lock-variable-name-face ((t (:foreground "goldenrod"))))
> '(mode-line ((((class color) (min-colors 88)) (:background "orange" :foreground "black")))))
>
> ;;No other contents is present in this file
> ;;
>
> ---- end ~/.emacs ----
>
> Here are the tests:
>
> 1) Try the following command lines:
>
> emacs -fn 10x20 &
> emacs -fn lucidasanstypewriter-24 &
>
> There is no difference between the emacs instances regarding the fonts.
>
> 2) Rename the .emacs to .emacs.disabled and run the same commands again.
>
> mv .emacs .emacs.disabled
> emacs -fn 10x20 &
> emacs -fn lucidasanstypewriter-24 &
>
> Now without the .emacs file the -fn command line option is taken
> into account.
I can reproduce this only partially. I don't have the 10x20 and
Lucida Sans Typewritere fonts, but I do have Lucida Sans Unicode, so I
tried
emacs -fn "Lucida Sans Unicode-24"
What this did is that Emacs uses Lucida Sans Unicode font as its
default, but does NOT use the "24" size-specification. If I remove
the ":height 113" part from your default-face spec in .emacs, then
both the font and the size specified on the command line are used.
> From these tests it's obvious that -fn has lower precedence than the .emacs
> file.
That conclusion is generally incorrect. There's no "precedence" here.
The command-line options are processed _after_ the .emacs file, but if
you specify overlapping settings, what happens when the command line
is processed depends on what exactly you specified. In this case, you
specified the size in .emacs and font plus size on the command line,
and what happens as result is subject to the Emacs logic of merging
overlapping font specifications.
> It turns that probably I always need to specify an init file in the
> command line when I start emacs (if sometimes I want a different behavior).
Any reason why you specify the font size both on the command line and
in the init file?
> Not that it's impossible or difficult. But I had to do some experiments to
> understand what is going on and in the end I was interested if this stuff
> is documented probably with some advice/best practices about how the users
> should set up their environments.
The best advice and practice I can recommend is never to specify
overlapping or contradicting settings. Then you will not need to
wonder which one takes precedence and what will be the result. Take
it from someone who uses Emacs for the past 30+ years.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-06 12:58 ` crstml
2024-04-06 16:07 ` Eli Zaretskii
@ 2024-04-06 17:55 ` tpeplt
2024-04-06 18:17 ` tpeplt
1 sibling, 1 reply; 10+ messages in thread
From: tpeplt @ 2024-04-06 17:55 UTC (permalink / raw)
To: crstml; +Cc: Eli Zaretskii, help-gnu-emacs
crstml@libero.it writes:
>
> 2) Rename the .emacs to .emacs.disabled and run the same commands again.
>
> mv .emacs .emacs.disabled
> emacs -fn 10x20 &
> emacs -fn lucidasanstypewriter-24 &
>
> Now without the .emacs file the -fn command line option is taken
> into account.
>
1. You can save some steps in your debugging process, above, by using
the Emacs options ‘-Q’ (or ‘--quick’) or ‘-q’ (or ‘--no-init-file’).
These options tell Emacs not to load your Emacs initialization file
(‘.emacs’). (These options are described in the man page for Emacs.)
On my system, the ‘lucidasanstypewriter’ font is installed, but the
‘10x20’ font is not.
$ emacs -fn lucidasanstypewriter-24 &
works as expected.
2. As you can see from your ‘.emacs’ file, the ‘custom-set-faces’
expression is complex. If you want to change the font that Emacs
uses, you can try the following option in the menu:
Options -> Set Default Font...
It gives you the capability of seeing what the various fonts that you
have installed look like and to choose one easily or change to
another font. If the checkbox for the menu entry:
Options -> Use System Font
is checked, then you will need to click on that box to unset it.
a. If you do not see a menu bar near the top of your Emacs frame,
then type:
M-x menu-bar-mode RET
This command (‘menu-bar-mode’) toggles the display of the menu.
b. If you do change your font via the menu, then you will need to
save the change so that it will be used the next time that you
start Emacs (*Warning*: This will overwrite your
‘custom-set-faces’ expression in your ‘.emacs’ file. If you want
to be safe, copy your ‘.emacs’ file to another file BEFORE the next
command):
Options -> Save Options
After you have done this, you will see a change to the
‘custom-set-faces’ expression in your ‘.emacs’ file.
--
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-06 17:55 ` tpeplt
@ 2024-04-06 18:17 ` tpeplt
2024-04-08 14:58 ` crstml
0 siblings, 1 reply; 10+ messages in thread
From: tpeplt @ 2024-04-06 18:17 UTC (permalink / raw)
To: crstml; +Cc: Eli Zaretskii, help-gnu-emacs
tpeplt <tpeplt@gmail.com> writes:
>
> 1. You can save some steps in your debugging process, above, by using
> the Emacs options ‘-Q’ (or ‘--quick’) or ‘-q’ (or ‘--no-init-file’).
> These options tell Emacs not to load your Emacs initialization file
> (‘.emacs’). (These options are described in the man page for Emacs.)
>
> On my system, the ‘lucidasanstypewriter’ font is installed, but the
> ‘10x20’ font is not.
>
> $ emacs -fn lucidasanstypewriter-24 &
>
> works as expected.
Correction: I left out the ‘-q’ option in the command, above. It should
read:
$ emacs -q -fn lucidasanstypewriter-24 &
to avoid loading the ‘.emacs’ file.
--
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-06 16:07 ` Eli Zaretskii
@ 2024-04-08 14:52 ` crstml
0 siblings, 0 replies; 10+ messages in thread
From: crstml @ 2024-04-08 14:52 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs
Eli Zaretskii wrote:
>> From: crstml@libero.it
>> Date: Sat, 6 Apr 2024 14:58:57 +0200
>>
>> Eli Zaretskii wrote:
>> (custom-set-faces
>> ;; custom-set-faces was added by Custom.
>> ;; If you edit it by hand, you could mess it up, so be careful.
>> ;; Your init file should contain only one such instance.
>> ;; If there is more than one, they won't work right.
>> '(default ((t (:inherit nil :extend nil :stipple nil :background "black" :foreground "gray" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal))))
>> '(font-lock-builtin-face ((t (:foreground "cornflower blue"))))
>> '(font-lock-comment-delimiter-face ((default (:inherit font-lock-comment-face)) (((class color) (min-colors 16)) nil)))
>> '(font-lock-comment-face ((t (:foreground "red"))))
>> '(font-lock-function-name-face ((((class color) (min-colors 88) (background dark)) (:foreground "gray" :weight bold))))
>> '(font-lock-keyword-face ((((class color) (min-colors 88) (background dark)) (:foreground "RoyalBlue"))))
>> '(font-lock-string-face ((((class color) (min-colors 88) (background dark)) (:foreground "orange"))))
>> '(font-lock-type-face ((((class color) (min-colors 88) (background dark)) (:foreground "darkslategray"))))
>> '(font-lock-variable-name-face ((t (:foreground "goldenrod"))))
>> '(mode-line ((((class color) (min-colors 88)) (:background "orange" :foreground "black")))))
>>
>> ;;No other contents is present in this file
>> ;;
>>
>> ---- end ~/.emacs ----
>>
>> Here are the tests:
>>
>> 1) Try the following command lines:
>>
>> emacs -fn 10x20 &
>> emacs -fn lucidasanstypewriter-24 &
>>
>> There is no difference between the emacs instances regarding the fonts.
>>
>> 2) Rename the .emacs to .emacs.disabled and run the same commands again.
>>
>> mv .emacs .emacs.disabled
>> emacs -fn 10x20 &
>> emacs -fn lucidasanstypewriter-24 &
>>
>> Now without the .emacs file the -fn command line option is taken
>> into account.
> I can reproduce this only partially. I don't have the 10x20 and
> Lucida Sans Typewritere fonts, but I do have Lucida Sans Unicode, so I
> tried
>
> emacs -fn "Lucida Sans Unicode-24"
>
> What this did is that Emacs uses Lucida Sans Unicode font as its
> default, but does NOT use the "24" size-specification. If I remove
> the ":height 113" part from your default-face spec in .emacs, then
> both the font and the size specified on the command line are used.
Also this one is a good test because it proves that settings in the
configuration file can interfere with what was specified in the command
line.
>> From these tests it's obvious that -fn has lower precedence than the .emacs
>> file.
> That conclusion is generally incorrect. There's no "precedence" here.
> The command-line options are processed _after_ the .emacs file, but if
> you specify overlapping settings, what happens when the command line
> is processed depends on what exactly you specified. In this case, you
> specified the size in .emacs and font plus size on the command line,
> and what happens as result is subject to the Emacs logic of merging
> overlapping font specifications.
This is valuable information.
>
>> It turns that probably I always need to specify an init file in the
>> command line when I start emacs (if sometimes I want a different behavior).
> Any reason why you specify the font size both on the command line and
> in the init file?
Not any very special reason. However, here is my usecase: I use emacs daily and I have a
init file that I use since years. Now, I need in certain circumstances to start an emacs
instance from a script with some different faces (different background color and font
size) than those in the configuration file. Trying to do it provided "no results"... due
to the reasons you have mentioned above.
>
>> Not that it's impossible or difficult. But I had to do some experiments to
>> understand what is going on and in the end I was interested if this stuff
>> is documented probably with some advice/best practices about how the users
>> should set up their environments.
> The best advice and practice I can recommend is never to specify
> overlapping or contradicting settings. Then you will not need to
> wonder which one takes precedence and what will be the result. Take
> it from someone who uses Emacs for the past 30+ years.
>
Good to know. In this case I think that probably the best solution for my case
would be to start emacs with a different init file.
Thank you for your advice
Cristian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs settings priority
2024-04-06 18:17 ` tpeplt
@ 2024-04-08 14:58 ` crstml
0 siblings, 0 replies; 10+ messages in thread
From: crstml @ 2024-04-08 14:58 UTC (permalink / raw)
To: tpeplt; +Cc: help-gnu-emacs
tpeplt wrote:
> tpeplt <tpeplt@gmail.com> writes:
>
>> 1. You can save some steps in your debugging process, above, by using
>> the Emacs options ‘-Q’ (or ‘--quick’) or ‘-q’ (or ‘--no-init-file’).
>> These options tell Emacs not to load your Emacs initialization file
>> (‘.emacs’). (These options are described in the man page for Emacs.)
>>
>> On my system, the ‘lucidasanstypewriter’ font is installed, but the
>> ‘10x20’ font is not.
>>
>> $ emacs -fn lucidasanstypewriter-24 &
>>
>> works as expected.
> Correction: I left out the ‘-q’ option in the command, above. It should
> read:
>
> $ emacs -q -fn lucidasanstypewriter-24 &
>
> to avoid loading the ‘.emacs’ file.
>
Thank you for your help tpeplt.
Cristian
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-04-08 14:58 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-05 7:17 emacs settings priority crstml
2024-04-05 12:10 ` Eli Zaretskii
2024-04-05 16:07 ` crstml
2024-04-05 17:14 ` Eli Zaretskii
2024-04-06 12:58 ` crstml
2024-04-06 16:07 ` Eli Zaretskii
2024-04-08 14:52 ` crstml
2024-04-06 17:55 ` tpeplt
2024-04-06 18:17 ` tpeplt
2024-04-08 14:58 ` crstml
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.