[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacs settings priority
From: |
crstml |
Subject: |
Re: emacs settings priority |
Date: |
Mon, 8 Apr 2024 16:52:59 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18.2 |
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