how does emacs choose which script to initialize with? - emacs

In both emacs 25.2.2 on Ubuntu 18.10, and 26.2 on arch we are experiencing the following weird behavior:
Ubuntu 18:
there is a .emacs file in my home directory.
If I run emacs, it works
.emacs sets indent style, font, and color
(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 :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight bold :height 180 :width normal :foundry "urw" :family "Nimbus Mono L")))))
(set-background-color "black")
(set-foreground-color "green")
When emacs is run by gnome-settings, it does not set the font correctly, but does set the indent and the color. I therefore conclude that the font setting is not working when gnome is first set up.
On arch, running emacs looks ok. But then if we load the file and M-x eval-buffer the font changes. Evaluating twice changes the font again. Eval a third time does nothing.
Can anyone explain what is happening, and how we can reliably select a font regardless of when the command is run?

Related

Emacs : "set default font" and init.el

I want to set up my starting default font.
I choose a font in Options --> set Default Font. then I save it with Options --> Save Options.
This writes at the end of my ~/.emacs.d/init.el file :
(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 :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant italic :weight bold :height 241 :width normal :foundry "microsoft" :family "Trebuchet MS" "Courier New" :foundry "monotype" :slant normal :weight bold :height 240 :width normal "Courier New"))))
When starting emacs again, the selected font is not loaded. And there is no problem with the init.d file, as reported in *Messages* or by --debug-init.
It seems the mechanism by which "set default font" finds fonts and init.d finds fonts are different ...
What do I do wrong ?
Running on Ubuntu 14.04LTS, Emacs 24
This works for me (Emacs 27.1)
;; Set default font
(set-face-attribute 'default nil
:family "Courier New"
:height 120
:weight 'normal
:width 'normal)
You can set it in your init.el file the following:
(set-default-font "Inconsolata 12")
or monaco font
(set-default-font "Monaco 12")

Emacs 23.3.1 fixedsys font issue

I have downloaded the Fixedsys.TTF font.
I have moved the font into the /usr/share/fonts/truetype directory.
I have opened Emacs and navigated to Options > Set Default Font... and selected
FixedsysTTF and specified Monospaced and size 11. I then used Options > Save Options.
I have noticed in my .emacs file:
'(default ((t (:stipple nil :background "#232323"
:foreground "#e6e1de" :inverse-video nil :box nil
:strike-through nil :overline nil :underline nil
:slant normal :weight semi-bold :height 110
:width normal :foundry "unknown" :family "FixedsysTTF"))))
I do some work in Emacs and close it with Ctrl+c Ctrl+x.
I then reopen Emacs and it does not produce the same font. Rather, if I follow step 2. again I find that Emacs has defaulted to Monospace Regular 10. Although the font that is actually shown is not even Monospace Regular 10.
In order to correct this situation I am required to manually follow step 2. again and then everything is fine until I exit and startup again.
My question is whether or not there is a simple fix for this? Or, what lisp functions are being called in the background when I do step 2 so I can just hack the .emacs file to forcefully load fixedsys.
PS: I did try the font Fixedsys Excelsior, which is perfect BUT for the fact that in said version of Emacs (that is not to say that this happens in ONLY said version, but I am restricted to 23.3.1) the 'A' character causes the proceeding character to overlap the 'A'. However, this version of Fixedsys does not cause a problem with Emacs, and it remembers the font on exiting and the re-opening. Therefore, it is either: correct the situation with the overlapping 'A', or get the other version of Fixedsys (the one linked in step 1) to work. I do actually prefer Fixedsys Excelsior, but I cannot live with an overlapping 'A'. FYI, when I use Fixedsys Excelsior I get the following in my .emacs file:
'(default ((t (:stipple nil :background "#232323"
:foreground "#e6e1de" :inverse-video nil :box nil
:strike-through nil :overline nil :underline nil :slant normal
:weight normal :height 117 :width normal :foundry "unknown"
:family "Fixedsys Excelsior 3.01"))))
Again, the font is downloaded from the Fixedsys Excelsior link above and then the TTF moved into /usr/share/fonts/truetype.
Can someone help sort out either of these issues?
I have found out how to solve this issue:
Downloaded this modified version of FixedSYS
Moved to /usr/share/fonts/truetype
Injected:
(set-face-attribute 'default nil :font "Fixedsys Excelsior 3.01-L-12") into my .emacs file
Just to let you know, your links to Fixedsys.TTF font are pointing to a video site with questionable credentials.
Chris

Emacs: how to specify where the true-type font is?

I want to make use of DejaVu font in emacs, on a cluster -- and I don't have access to install fonts system wide. I put fonts (they are free) in ~/.fonts. I want to make use of DejaVuSansMono.ttf. Normally I just put in .emacs:
(custom-set-variables
'(default ((t (:inherit nil :stipple nil :background "#ffffb1" :foreground "#141312" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 173 :width normal :foundry "monotype" :family "DejaVu Sans Mono")))))
But now emacs can't find the font!
So my question is - how can I help emacs to find the font? How can I specify the path to the font?
It looks like bdf-directory-list will fix it.
(setq bdf-directory-list '("/path/to/fonts"))
I can't try it right now - will be back later.

Changing a custom set face to display with those settings in certian emacs mode (text-mode, LaTeX-mode, etc..)

I had a custom-set-faces that I had used in an emacs startup file that was especially for when I launched latex files but I'm in the process of merging and updating my .emacs file so I don't launch a seperate start-up process for the latex file. I want to set it so this custom face is set only when latex mode is on. Since it is a custom face I don't think it is wise to set a LaTeX-mode-hook but I know there should be a way to do this. I only change the font and the text size basically for when I'm typing. I would also like this enabled for text-mode if possible. Attache the custom face below.
(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 :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "DejaVu Sans")))))
Instead of custom-set-faces you can set it with set-face-attribute, but it will still change the face "in all buffers".
(set-face-attribute 'default nil
:inherit nil
:stipple nil
:background "white"
:foreground "black"
:inverse-video nil
:box nil
:strike-through nil
:overline nil
:underline nil
:slant 'normal
:weight 'normal
:height 98
:width 'normal
:foundry "unknown"
:family "DejaVu Sans")
You should identify the right faces and only set them, don't set default. To identify which face is at point use this

Emacs customize-face loses/fails to recognise font-name it wrote to my .emacs itself

I used the Options/Set Default Font menu item to set my default emacs font to be LMMonoLtCond10 (it brought up a nice font-selector GUI widget to let me do this). My emacs immediately adopted the new font, and I was very happy. I then did Options/Save Options, and on inspecting my .emacs.d/init.el file saw that it had written the following there:
(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 :stipple nil :background "white" :foreground "black"
:inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal
:weight light :height 120 :width normal :foundry "unknown" :family "LMMonoLtCond10"))))
(There are a couple of other faces I've defined below that.)
Unfortunately, if I quit emacs, and restart, it completely fails to recreate the font configuration that I had selected. Instead, I think it's giving me LMRoman-12. Am I doing something wrong, or is this an emacs bug.
I'm using Emacs 23.1.1:
(emacs-version)
"GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1)
of 2011-03-05 on palmer, modified by Debian"
on an Ubuntu system.
Sounds like it might be a bug. M-x report-emacs-bug