How to change org-mode tables background color in Spacemacs? - org-mode

I want to change how tables look in org-mode. I am running spacemacs master branch on Manjaro i3.
By default, the background color of the table doesn't match the plain text background.
I tried to customize by changing options in customize-group/org-faces/org-tables but I couldn't make it work.
Here is a snapshot of how it look now

What I did to modify the background of the org-mode tables, was using the theming layer to modify my theme.
Add the theming layer to your dotspacemacs-configuration-layers.
In the user-init section add:
(defun dotspacemacs/user-init ()
(setq theming-modifications
'((gruvbox-dark-soft ;; Your theme name
(org-table :background "#282828" :foreground "#fe8019")
))
)
)
It should work after reloading the configuration and the org-mode buffers.

Related

Change HTML tag color in emacs web-emmet-helm mode

I am trying to customize the text color for web-emmet-helm mode (I don't know which one is setting this particular syntax element) so that I can read it on a black terminal background. honestly I'm not too picky about my background color, but with the default settings I can't find any one color that allows me to see everything.
Does anyone know how to customize the syntax elements indicated in the screenshot? I've done a lot of google searching but probably don't know the right keywords to use. I don't know any lisp but can stick some lines into init.el if you provide them.
Thank you!
Put the point (text cursor) where you want to know about the face (text style) and do M-x describe-face. This will bring up a help window describing the face, including the name. Then you can do M-x customize-face, enter the face name, change the fg color, bg color, and whatever else, and save it. Use M-x list-colors-display to see all the named colors, or use hex RGB to set the color.
Adding the following block to init.el does the trick. The face names are all listed at http://web-mode.org in the Customization section.
(defun pk-web-mode-hook ()
"Hooks for Web mode."
(set-face-attribute 'web-mode-html-tag-bracket-face nil :foreground "White")
(set-face-attribute 'web-mode-html-tag-face nil :foreground "Yellow")
)
(add-hook 'web-mode-hook 'pk-web-mode-hook)

How do I change the highlight color for selected text with Emacs / deftheme?

I'm using Emacs 24; I've installed the zenburn theme, which is great, except I cannot see the selection highlight easily with the highlight color provided by zenburn:
By "selection" color, I mean the color of text that I've selected by setting a mark (C-space and moving the cursor to select text).
For the life of me, I cannot figure out how to change it. I've tried changing every combination of highlight, selection, etc.. that I can think of in zenburn-theme.el, but nothing seems to change it.
**For sanity's sake, I've tried changing other colors in the theme to make sure Emacs is loading the file properly - it is - those changes work.*
I would have especially thought that changing highlight would work, but no customizations to the highlight line seem to work:
;;;; Built-in
;;;;; basic coloring
...
`(highlight ((t (:background ,zenburn-bg-05 :foreground ,zenburn-yellow))))
How can I change the selection color?
What you're looking for is the region face. For example:
(set-face-attribute 'region nil :background "#666")
In addition to tungd's solution. You could also then change the font color to make it more readable. E.g. to white
(set-face-attribute 'region nil :background "#666" :foreground "#ffffff")
You can use the customize interface.
M-x customize-face
When prompted for which face, enter region. Then you'll see
something like:
Using customize makes it easy to experiment with lots of colors. Try
clicking [ Choose ] to access the color-picker), then
[ Apply and Save ]. It also nicely organizes your customizations
into a single file (rather than further polluting your init.el).

Emacs buffer-local font

For all my tasks I use URW Chancery L font in Emacs. But for some tasks,
like org-mode tables, shell or sunrise-commander, I would like to set mono-width font.
So, my question, how can I do it? All I found about it is set-default-font, which is not what I want.
Faces (i.e. the objects used to specify appearence of text such as font, color, ...) are mostly global in Emacs, although they can also be set on a frame basis, so you can do the above by creating a separate frame and change the `default' face to use in that frame.
This said, Emacs can also now also change face's appearence for specific buffers via face-remapping. E.g.
(face-remap-add-relative 'default '(:family "Monospace"))
should make the current buffer use Monospace. So adding the above to org-mode-hook might just solve your problem.
This snippet sets the "Arial" font family only in C mode:
(defun set-my-font ()
(overlay-put (make-overlay (point-min) (point-max) nil nil t)
'face '(:family "Monospace")))
(add-hook 'org-mode-hook 'set-my-font)
Replace with org-mode-hook with the desired mode(s), and it should work as well.
This solution effects creation of buffer-local font by setting the font family property of an overlay over the entire buffer. The overlay's face property only specifies the font family (Monospace), and Emacs redisplay is smart enough to merge it with other text properties, such as the colors specified by font-lock.
Did you try to customize org-table ?
You can modify it with org-menu > Customize > Customize > org-table
or use the command line
M-x set-face-font RET org-table RET -PfEd-DejaVu Sans Mono-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1
Use tab to auto-complete and see other available fonts
Finaly you could also directly modify you init.el to have something like
(custom-set-faces
'(org-table ((t (:foreground "LightSkyBlue" :family "DejaVu Sans Mono")))))

Change Emacs' background color

I have a function that sets Emacs' color theme to a theme defined by myself. In this function I do:
(set-face-attribute 'default cur-frame :foreground fg-color :background bg-color)
I then set the background color, foreground color, and cursor color for default-frame-alist, initial-frame-alist and special-display-frame-alist.
All of this works fine on my Mac. But when I use this on Linux, it looks fine for all frames that have already been opened, but on newly created frames it looks like this:
I do not have this problem with new frames if use the set-background-color / set-foreground-color functions instead of (set-face-attribute 'default ...). But if I do that I have to manually reset the colors for every frame that's already open.
I am using Emacs version 23.3 on both Mac and Ubuntu.
For clarification, this is the theme file I use:
my-color.el
set-face-attribute sets, as the name suggest, the attributes of a face (i.e., font-related properties), not the attributes of the frame. Use
(add-to-list 'default-frame-alist '(background-color . "lightgray"))
and similar to change frame-related properties.
(if (eq system-type 'darwin)
;; mac os x settings
(if (eq system-type 'gnu/linux)
(setq default-frame-alist '((background-color . "black")
(foreground-color . "gray")))))
something like this should help you maintain settings per OS.
It seems that it's better to use
(custom-set-faces
'(default ... )
'(region ... )
....
)
style to set faces, this way it will not have that problem.
Emacs uses1) (or does not paint over) the Gtk3.0 theme background in more recent Emacs versions. Changing background using e.g. set-background-color or default-frame-alist only works until I resize the window, after which the Gtk theme background "shines through" again.
I have not yet been able to figure out how to get emacs to always paint over the Gtk theme background, but at least I have found a way how to change the Gtk theme background color, for Emacs only: https://superuser.com/questions/699501/emacs-showing-grey-background-where-there-are-no-characters/937749#937749
So this does not fully solve changing the background color when you switch themes, but at least you can get rid of the black-white contrast you experience when opening new frames.
1) on my machine at least :)

Can I use cperl-mode with perl-mode colorization?

The Emacs cperl-mode seems to get confused less than perl-mode, but the Skittles effect makes the thing unusable for me. Does anyone have or know of an example of a .emacs block that causes cperl-mode to use the colorization from perl-mode, ideally in a form readable enough that I can go back and turn back on the default colors one element at a time until I reach something I'm comfortable with?
In particular there is a hideously shade of light green used for some builtins that I find quite unreadable, and I prefer my variables to not have the leading $ and $$ and such tinted red along with the variable name. Most of the rest are merely distracting.
Press M-x customize-group RET cperl-faces RET and change coloring to your liking.
With colour themes, the problem is limited to arrays and hashes - and it turns out that that's because cperl-mode defines those faces as being bold-weight, which colour themes don't appear to affect (Solarized doesn't).
In Emacs 23.3 on Mac OS, the following restored the colours to how the colour theme defined them:
(custom-set-faces
'(cperl-array-face ((t (:weight normal))))
'(cperl-hash-face ((t (:weight normal))))
)
You can also use the 'real' perl-mode coloring by overwriting font-lock settings with those of perl-mode.
(require 'perl-mode)
(add-hook 'cperl-mode-hook
(lambda ()
(setq font-lock-defaults
'((perl-font-lock-keywords perl-font-lock-keywords-1 perl-font-lock-keywords-2)
nil nil ((?\_ . "w")) nil
(font-lock-syntactic-face-function . perl-font-lock-syntactic-face-function)))
(font-lock-refresh-defaults)))
You can change the color theme if you don't like the particular default colors.