I trying to change helm-source-header style with code below:
(set-face-attribute 'helm-source-header nil
:background "gray30"
:height 90)
After Emacs initialization i have an error:
error: Invalid face, helm-source-header
But if I run this code after initialization changes applying to helm without problems.
I guess that I should run this code after helm init, but how can I do it?
Try
(eval-after-load 'helm
(lambda ()
(set-face-attribute 'helm-source-header nil
:background "gray30"
:height 90)))
(Looks not bad with zenburn-theme by the way, thanks for the idea!)
Related
I am trying to configure hl-line or hl-line+ in emacs to respect the existing highlights/text background colors in the buffer.
I have configured hl-line in ~/.emacs as follows:
(require 'hl-line)
(global-hl-line-mode 1)
Then I highlight the symbol at point using highlight-symbol-at-point (M-s h .). This highlights the symbol under the cursor all over the buffer with a yellow background.
However, when I move the cursor over a line containing that symbol, the hl-line overlay hides the yellow background. My expectation would be for the line to be highlighted, but for the yellow background to be respected.
After doing some digging, I also tried with the hl-line+ package as it has an overlay priority option that sounds promising. I downloaded the hl-line+.el file and setup my ~/.emacs as follows:
(add-to-list 'load-path (expand-file-name "~/.emacs.d/packages/hl-line+/"))
(require 'hl-line+)
(global-hl-line-mode 1)
(setq-default hl-line-overlay-priority -100)
However, this still has the same incorrect behivour to hide the existing yellow background.
Anybody knows how to configure either of these packages to respect the existing background colors?
highlight-symbol uses font-lock, which adds text properties (face or font-lock-face) to chars in the buffer.
Overlay properties (including face and `font-lock-face) are not applied to chars in the buffer. They're applied to buffer positions. They "overlay" the buffer contents; they're not part of the buffer contents.
Overlay properties always take priority over text properties. This means overlay highlighting always overrides text-property highlighting (e.g. by font-lock).
Overlay priorities only specify the relative priority among overlays. Again, any overlay highlighting overrides any text-property highlighting.
So I think the answer is that you can't do what you request. (Someone else will correct me, if there's a way around this.)
Reading the hi-lock.el documentation, this explanation stood out:
"In buffers where Font Lock mode is enabled, patterns are highlighted
using font lock. In buffers where Font Lock mode is disabled,
patterns are applied using overlays"
So as it turns out, the hi-lock.el package is able to highlight using overlays, but only when font lock mode is disabled. I tested this by disabling font lock with M-x font-lock-mode, and I can confirm the highlighting is now properly displayed when also highlighting the current line with hl-line. The problem is that all language syntax highlighting is now gone, so this option is no good.
If anybody knows how to configure hi-lock.el to use overlays with font-lock-mode enabled, then that would be the best answer.
In the meantime, there is an alternative MELPA package that supports overlay highlighting, and it woks like a charm with hl-line: symbol-overlay.el.
Having said that, I am not too fond of default key bindings and highlighting colors. For reference I leave here my configuration:
(require 'symbol-overlay)
(global-set-key (kbd "<f2>") 'symbol-overlay-jump-next)
(global-set-key (kbd "S-<f2>") 'symbol-overlay-jump-prev)
(global-set-key (kbd "C-<f2>") 'symbol-overlay-put)
(global-set-key (kbd "M-<f2>") 'symbol-overlay-query-replace)
(global-set-key (kbd "<f7>") 'symbol-overlay-mode)
(global-set-key (kbd "<f8>") 'symbol-overlay-remove-all)
(set-face-attribute 'symbol-overlay-default-face nil :background "coral1" :foreground "black")
(set-face-attribute 'symbol-overlay-face-1 nil :background "gold2" :foreground "black")
(set-face-attribute 'symbol-overlay-face-2 nil :background "chocolate2" :foreground "black")
(set-face-attribute 'symbol-overlay-face-3 nil :background "PaleGreen2" :foreground "black")
(set-face-attribute 'symbol-overlay-face-4 nil :background "SkyBlue2" :foreground "black")
(set-face-attribute 'symbol-overlay-face-5 nil :background "PaleVioletRed2" :foreground "black")
(set-face-attribute 'symbol-overlay-face-6 nil :background "IndianRed2" :foreground "black")
(set-face-attribute 'symbol-overlay-face-7 nil :background "PaleTurquoise2" :foreground "black")
(set-face-attribute 'symbol-overlay-face-8 nil :background "MediumOrchid2" :foreground "black")
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?
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
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
I'm getting the error Unable to load color "unspecified-bg" [16 times] when using emacsclient -c. I've started up emacs using emacs --daemon. This seems to mean that my custom faces won't load.
When starting emacs as usual, and then using M-x server-start, then this problem doesn't happen at all. How can I get emacsclient -c to load the faces properly?
Here's the relevant code:
(custom-set-faces '(default ((t (:inherit nil :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :foundry "unknown" :family "Inconsolata")))))
I'm not 100% sure this would fix your problem, but you really should be using color-theme for syntax highlighting. Custom is meant for beginning emacs users, so I'd suggest you try out color-theme and see if it works. Here's how I have it set up on my machine:
Download the package from the color-theme homepage.
Put the color-theme folder somewhere like ~/.emacs.d/color-theme/.
Make sure this folder is in your load-path. I took the following code from a Steve Yegge post:
In your .emacs:
(defvar emacs-root "~/.emacs.d/")
(labels
((add-path
(p)
(add-to-list
'load-path
(concat emacs-root p))))
(add-path "lisp")
(add-path "color-theme-6.6.0")
(add-path "cedet-1.0"))
(require 'color-theme)
Then you define your color theme:
;; Color-theme
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
;; Set custom color theme
(defun color-theme-mine ()
"My custom color theme"
(interactive)
(set-cursor-color "#ffffff")
(color-theme-install
'(color-theme-mine
;; Super-light grey on Dark grey
((foreground-color . "#e0e0e0")
(background-color . "#151515")
(background-mode . dark))
(font-lock-comment-face ((t (:foreground "#106010")))) ;; Forest Green
;; More definitions below
;; ...
(color-theme-mine)) ;; end eval-after-load
This will load color-them-mine when you start emacs. You can see all available color themes by typing M-x color-theme <TAB>. To see the full list of faces available, use the command M-x list-faces-display.
Sounds like this might be bug #4776: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4776#5. If not, consider filing a bug report for this one, using M-x report-emacs-bug.