Emacs 24: Mode-Line Style - emacs

I am trying to change the styling of the modeline in emacs 24.
I want to add an overline and an underline. Underline works fine, but overline is not working for some reason. Here is my code so far (added to .emacs):
(set-face-attribute 'mode-line nil
:foreground "gray0"
:background "cyan"
:overline "cyan"
:underline "cyan")
Any ideas on how to get the overline working?
Also is there a way to set the distance between the borders and text?
Thanks

If I remember correctly, the default mode-line spec has a non-nil :box spec, so it might solve your problem to add the line :box nil to your code listed above.

Related

how does emacs choose which script to initialize with?

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?

Change color of buffer name in mode-line

It would be nice to have the buffer/file name more visible inside the mode-line specially when working with many files.
How to change the color of buffer name inside mode-line?
You can also use:
(set-face-attribute 'mode-line-buffer-id nil :foreground "black")
or for carbon emacs:
(set-face-attribute 'modeline-buffer-id nil :foreground "black")
Just customize face mode-line-buffer-id: M-x customize-face.
I use this value, for instance (from my custom-file):
(mode-line-buffer-id ((t (:overline "red" :underline "red"))))
IOW, I have both an overline and an underline, for the buffer name.

how to unset the foreground color of whitespace-mode for Emacs

In programming files, I use whitespace-mode to highlight the tab and long lines. The default highlighting is too garnish for me.I just want to highlight them with a gray background and keep whatever normal color it should be for the font. How could I set that?
The following setup does not work. I'd like the code beyond 80 columns appearing yellowish, as the characters inside 80 columns in the snapshot.
;; face for long lines' tails
(set-face-attribute 'whitespace-line nil
:background "#555"
:weight 'bold)
;; face for Tabs
(set-face-attribute 'whitespace-tab nil
:background "#555"
:weight 'bold)
set-face-attribute changes only the attributes you specify.
Set :foreground to nil:
(set-face-attribute 'whitespace-line nil
:foreground nil
:background "#555"
:weight 'bold)
For me the unpleasant color turned out to be trailing-whitespace and I'm using this:
;; whitepace looks rediculous in color themes.
(defadvice color-theme-install (after my-color-theme-install-after activate)
"Fix trailing-whitespace after color theme destroys it"
(set-face-attribute 'trailing-whitespace nil
:foreground 'unspecified
:inverse-video 'unspecified
:slant 'unspecified
:weight 'unspecified
:background "#fff"))

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.

Change Emacs syntax highlighting colors

I'm running Emacs, editing files in C++ mode and PHP mode. I love syntax highlighting as a concept, but the default colors are a travesty. I can barely read some of them: way too dark. What is the easiest way to change their values? I can't seem to find anything about this on the web. I don't even mind changing the binary as I'm compiling my own Emacs. I just want to find the place where it says blue is #0000FF and change it to #AAAAFF for example.
I find it easiest to use color-theme for this sort of thing.
But if you don't want to do that, put the cursor over the offending text, and hit M-x customize-face. It should default to the face that the cursor is over.
See 49.1.6 Customizing Specific Items.
Two ways - you can install the package color-theme, which has lots of nice schemes to select and is easier to do it by hand. The by-hand looks like this (in your .emacs 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 "lightyellow2" :foreground "gray20" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight bold :width normal :family "liberation mono"))))
'(background "blue")
'(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
'(font-lock-comment-face ((t (:foreground "MediumAquamarine"))))
'(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
'(font-lock-doc-string-face ((t (:foreground "green2"))))
'(font-lock-function-name-face ((t (:foreground "SkyBlue"))))
'(font-lock-keyword-face ((t (:bold t :foreground "CornflowerBlue"))))
'(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
'(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
'(font-lock-string-face ((t (:foreground "LimeGreen"))))
...
etc. etc.
You can also type
`M-x customize-face RET`
which will give you all the customizations to set, ultimately end up in your .emacs file.
Put the cursor on a face ("color") that you want to change. Hit C-u C-x =. That will tell you which face(s) are present at that position, and it will let you click to customize it/them. Save your customizations.
If you don't care about color highlighting at all, or none of the previous answers work for you (or take too much time and effort to figure out), here is a very simple solution that will get rid of colors altogether.
Typing the following will get rid of colors:
M-x global-font-lock-mode
You can also do this as an interim step to allow you to actually see everything your screen to try any of the above answers. In my case, this was very useful because the color of certain key pieces of text which would allow me to change colors were themselves nearly invisible - for instance, the prompt of M-x.
If you want the change to be permanent, you can add this to your .emacs file:
(setq-default global-font-lock-mode nil)
Starting with Emacs 24.1, you can use M-x customize-themes to select a colour theme.
Emacs comes with a dozen or so themes with varying brightness and colourfulness, so you'll most likely find something that mostly matches your preferences.
You can also find more colour themes installable through MELPA at https://peach-melpa.org/ - no, that web site seems to be down. You can search for "theme" at melpa.org, but it doesn't show any screenshots.