org-faces.el contains this code
(org-copy-face 'mode-line 'org-mode-line-clock
"Face used for clock display in mode line.")
;; ...snip...
(provide 'org-faces)
;;; org-faces.el ends here
Which makes the right side of my modeline (the org clock display) have the same face as 'mode-line. Using my .emacs I'd like to change this behavior so that the org clock display uses the same face as 'mode-line-inactive.
I tried adding this to .emacs:
(require 'org-faces) ;;necessary?
(org-copy-face 'mode-line-inactive 'org-mode-line-clock
"Face used for clock display in mode line."
:background "blue")
(provide 'org-faces) ;;necessary?
but the modeline is unchanged after evaluating .emacs. Where am I going wrong? I'm pretty new to Lisp. Thanks for any help.
You should redefine the face, as I do for "org-todo":
(set-face-attribute 'org-todo nil
:weight 'bold :box '(:line-width 1 :color "#D8ABA7")
:foreground "#D8ABA7" :background "#FFE6E4")
You may (or must, maybe, depending on where you place the above lines) leave the requiring of org-faces, but clearly not the provide line.
Alternatively, use a color theme that improves Org's use (such as my Emacs Leuven theme, see https://github.com/fniessen/emacs-leuven-theme), eventually customizing it to suit your taste.
This seems to work:
(eval-after-load "org-faces"
'(set-face-attribute 'org-mode-line-clock nil
:inherit nil))
That is, make the org-mode-line-clock no longer inherit attributes from the mode-line face. It seems like it gets the attributes from mode-line or mode-line-inactive as appropriate, when displayed in the mode line.
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")
I'm in the process of configuring linum, hlinum, and hl-line for Emacs 24, and something I'm running into some trouble with is getting the hlinum highlight to match/inherit the background color of the line highlight.
In my Elisp file responsible for face customizations, I have the following:
(eval-after-load 'hl-line
'(progn
(set-face-attribute 'hl-line nil
:background "#222222")))
(eval-after-load 'hlinum
'(progn
(set-face-attribute 'linum-highlight-face nil
:inherit 'hl-line)))
However, the hlinum face remains unchanged. Specifying the linum-highlight-face background manually works, but I'd rather have it pick up on the color for hl-line.
How can I get linum-highlight-face to use the same background color as hl-line?
Related to this StackOverflow question, I added
:background 'unspecified
below the :inherit line for hlinum, and it used the same color.
I installed Prelude on my emacs24. I'm using ubuntu 12.04
It worked perfectly the first time I used it, but all the next times it doesn't.
On my current line the font color is gray so it's hard to see what I write. Previously it was a Bold case, keeping any color the line had for reserved words.
How can I fix this?
or also the empty lines with spaces are all yellow
I've been trying to fix it on the:
~/.emacs.d/elpa/zenburn-theme-20130716.1457/zenburn-theme.el
file but I can't find a solution... I think the problem could be between this lines:
;;;;; hl-line-mode
`(hl-line-face ((,class (:background ,zenburn-bg-05))
(t :weight bold)))
`(hl-line ((,class (:background ,zenburn-bg-05)) ; old emacsen
(t :weight bold)))
Thanks!
You can change the background and foreground to whatever you want, or turn it off completely. You can add bold or underline or overline or slant, or whatever floats your boat. One of my very first projects was to take the settings from color-theme and put it into my .emacs file and I haven't used a specific color theme since. Oh, and of course you want to open your .emacs or init file to see if there are any settings that conflict with the color theme you are using.
(global-hl-line-mode 1) ;; highlight current line -- see hl-line.el
(custom-set-faces
'(highlight ((t (:background "grey80" :foreground "black" :bold t)))) ;; highlight current line
)
Important:
Add to .bashrc file:
export TERM=xterm-256color
and I found the perfect configuration for me. Here it goes:
;;;;; hl-line-mode
(custom-set-faces
'(highlight ((t (:background "grey20" :foreground nil :bold t)))) ;; highligh\
t current line
)
This way you keep every color for reserved words all bold and a gray background for the current line. Everything will be beautiful =)
I use the volatitle-highlights-mode(VHL) to hightlights last edit region. But the background color of the VHL is much too light in color for the solarized-theme. So I want change the background color of the VHL.
I found the snippets from the VHL, as follow:
(defface vhl/default-face
(cond
((or vhl/.xemacsp
(vhl/.face-inheritance-possible-p))
'((((class color) (background light))
(:background "yellow1"))
(((class color) (background dark))
(:background "SkyBlue4"))
(t :inverse-video t)))
(t
'((t
:inherit secondary-selection
))))
"Face used for volatile highlights."
:group 'volatile-highlights)
this snippets specify the color of the VHL background, so how can I customize the background color in my .emacs.d to override the default VHL background color.
Snippets welcome! Thanks.
You can also just use M-x customize-face RET vhl/default-face. It does not matter how the face is defined: you can still use Customize to customize it.
The code above looks strange: It seems to check whether face inheritance is possible and, if not, try to inherit from the secondary-selection face (!!)
Anyway, the easiest thing to do is use customize-face, like wvxvw suggested in the comments to your question. I don't quite understand your response to his answer: setting a face that doesn't exist won't cause any error. However, if you're worried, you can cut the (custom-set-face .... ) form that appears in your .emacs and stick it in a file in .emacs.d: the warning about only using one instance in your .emacs is so that the customize infrastructure knows how to edit the file.
For example, how can I make a minor mode that changes the default foreground color to gray, and upon exiting the minor mode, the foreground color is back to black? This mode might be useful when you don't like certain text to be seen over your shoulders.
For now, I run the following code to turn text color to gray:
(set-face-attribute 'default (selected-frame) :foreground "darkgrey")
And the following code to get back.
(set-face-attribute 'default (selected-frame) :foreground "SystemWindowText")
But this affects all buffers.
You can use buffer-face-mode based on overlays, it also lets to change the background of text in your buffer.
(make-face 'hard-to-read-font)
(set-face-attribute 'hard-to-read-font nil :background "darkgrey" :foreground "grey")
(define-minor-mode hard-to-read-mode
"This mode might be useful when you don't like certain text to be seen over your shoulders."
:init-value nil :lighter " hard-to-read" :keymap nil
(if hard-to-read-mode
(progn
(font-lock-mode nil)
(buffer-face-mode t)
(buffer-face-set 'hard-to-read-font))
(progn
(font-lock-mode t)
(buffer-face-mode nil))))
;; change this to mode you need
;; or turn it on manually
;; (add-hook 'text-mode-hook
;; (lambda ()
;; (hard-to-read-mode t)))
update: You know, this isn't secure. It works against human eyes, but anyone can use camera and then just increase contrast to read the text.