emacs color-theme problem - emacs

I created my own color theme using this website. I've added a new .el file to my ./site-lisp/color-theme/themes directory with the following code:
(defun your-config-name-here ()
(interactive)
(color-theme-install
'(your-config-name-here
((background-color . "#ffffff")
(background-mode . light)
(border-color . "#000000")
(cursor-color . "#333333")
(foreground-color . "#000000")
(mouse-color . "black"))
(fringe ((t (:background "#000000"))))
(mode-line ((t (:foreground "#000000" :background "#666666"))))
(region ((t (:background "#999999"))))
(font-lock-builtin-face ((t (:foreground "#000000"))))
(font-lock-comment-face ((t (:foreground "#000000"))))
(font-lock-function-name-face ((t (:foreground "#000000"))))
(font-lock-keyword-face ((t (:foreground "#000000"))))
(font-lock-string-face ((t (:foreground "#000000"))))
(font-lock-type-face ((t (:foreground"#000000"))))
(font-lock-variable-name-face ((t (:foreground "#000000"))))
(minibuffer-prompt ((t (:foreground "#7299ff" :bold t))))
(font-lock-warning-face ((t (:foreground "Red" :bold t))))
)))
(provide 'your-config-name-here)
And this in my .emacs file:
(add-to-list 'load-path "~/../site-lisp/color-theme/")
(add-to-list 'load-path "~/../site-lisp/color-theme/themes")
(require 'color-theme)
(require 'your-config-name-here)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(your-config-name-here)))
The problem is that I've noticed that when I change settings in your-config-name-here.el and exit emacs and reload it, that the changes don't take affect until I do this:
M-x load-file ~/../site-lisp/color-theme/themes/your-config-name-here.el
M-x your-config-name-here
It 'feels' like color-theme is caching the settings somewhere and not reloading then on start-up. What am I missing?

In your code, you have a call to 'color-theme-initialize, which doesn't exist as a function in the package color-theme.el.
(eval-after-load "color-theme"
'(progn
;; remove this call (color-theme-initialize)
(your-config-name-here)))
And then your code works.

Related

why does syntax highlighting disable when I use web-mode in emacs?

This is my init.el
(require 'web-mode)
(setq web-mode-tag-auto-close-style 1)
(setq web-mode-enable-auto-closing t)
What should I do?
For example
'(web-mode-doctype-face
((t (:foreground "#4A8ACA"))))
'(web-mode-html-tag-face
((t (:foreground "#4A8ACA"))))

emacs 24.3 ignoring foreground/background color with color-theme?

I've been using color-theme for quite awhile to set colors in my .emacs:
(defun custom-theme ()
(interactive)
(color-theme-install
'(custom-theme
((background-color . "black")
(background-mode . dark)
(border-color . "#0d1b2b")
(cursor-color . "#fce94f")
(foreground-color . "#dddddd")
(mouse-color . "black"))
(isearch ((t (:inverse-video t :underline t ))))
(lazy-highlight ((t (:inverse-video t :underline t ))))
(hl-line ((t (:background "gray13" ))))
(fringe ((t (:background "#0d1b2b" ))))
(mode-line ((t (:foreground "#bbbbbb" :background "#353e4b"))))
(region ((t (:background "gray13" ))))
(font-lock-builtin-face ((t (:foreground "#9c56dc" ))))
(font-lock-comment-face ((t (:foreground "#187093" ))))
(font-lock-function-name-face ((t (:foreground "#edd400" :underline t ))))
(font-lock-keyword-face ((t (:foreground "#b47113" ))))
(font-lock-string-face ((t (:foreground "#e65351" ))))
(font-lock-type-face ((t (:foreground "#3257d2" ))))
(font-lock-constant-face ((t (:foreground "#cc1e1e" ))))
(font-lock-variable-name-face ((t (:foreground "#cccccc" ))))
(minibuffer-prompt ((t (:foreground "#729fcf" :bold t ))))
(font-lock-warning-face ((t (:foreground "#BB0000" :inverse-video t :underline "#bbbbbb" ))))
)
)
)
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(custom-theme)))
However, in 24.3 now, for some reason when I open emacs in the terminal (emacs -nw), it's ignoring the background and foreground colors, so I get a white editor background regardless. What's more, emacs is ignoring the -bg and -fg flags passed on the command line.
I've found that I can sort of force the colors on frame setup with something like this:
(defun on-after-init ()
(unless (display-graphic-p (selected-frame))
(progn
(set-face-background 'default "black" (selected-frame))
(set-face-foreground 'default "#dddddd" (selected-frame)))))
(add-hook 'window-setup-hook 'on-after-init)
But this feels like a hack, I'd like to understand why emacs isn't interpreting my color theme correctly. My TERM is set to xterm-256color, though setting back to plain xterm doesn't seem to affect anything.

only highlight "*", not the entire heading line in org-mode, emacs

How can I only highlight the * star, not the entire heading line, to keep texts in same color? In the great emacs org-mode
thanks guys
excample (replace * by #, for cann't bold * in stack-overflow)
(not below)
# heading text
this is text body
(but below)
# heading text
this is text body
Updated Answer
See the variable org-level-color-stars-only, which contains a doc-string that states: "Non-nil means fontify only the stars in each headline. When nil, the entire headline is fontified. Changing it requires restart of `font-lock-mode' to become effective also in regions already fontified."
USAGE:  (setq org-level-color-stars-only t)
Previous Answer
You can remove or add stars as you see fit -- this example uses two (2) stars together. If you do just one star, then that would also affect two (2) and three (3) stars together. Maybe one of our forum local regexp experts could please give us the code for one star (but not more than one star) :)
(defvar bumble-bee (make-face 'bumble-bee))
(set-face-attribute 'bumble-bee nil :background "black" :foreground "yellow")
(font-lock-add-keywords 'org-mode (list
(list (concat "\\*\\*")
'(0 bumble-bee t))
))
These control the title of tasks -- you could set them all the same or make them different. Anything you don't want, just set to nil or set to the same color as whatever your regular font is.
(custom-set-faces
'(org-level-1 ((t (:foreground "orange" :bold t))))
'(org-level-2 ((t (:foreground "black" :bold t))))
'(org-level-3 ((t (:foreground "pink" :bold t))))
'(org-level-4 ((t (:foreground "cyan" :bold t))))
)
The other components of the first line are usually: org-tag; org-tag-faces; org-todo-keyword-faces; org-priority-faces; and org-warning:
(setq org-todo-keyword-faces '(
("Active" . (:foreground "red"))
("Next Action" . (:foreground "ForestGreen"))
("Reference" . (:foreground "purple"))
("Someday" . (:foreground "gray65"))
("None" . (:foreground "green"))
("Delegated" . (:foreground "cyan")) ))
(setq org-tag-faces '(
("TODO" . org-warning)
))
(setq org-priority-faces '(
(?A . (:foreground "firebrick" :weight bold))
(?B . (:foreground "orange"))
(?C . (:foreground "green"))
(?D . (:foreground "purple"))
(?E . (:foreground "blue")) ))
(custom-set-faces
'(org-tag ((t (:background "gray97" :foreground "gray50"
:box (:line-width 1 :color "black") :weight regular))))
'(org-warning ((t (:foreground "black"))))
)

configure colors in hexl-mode emacs

I would like to configure the colors of different sections of data when displayed with hexl-mode.
For example, I would like the address ranges to be with white background,
the bytes in yellow, and the ASCII in red (whatever).
00000000: 2550 4446 2d31 2e34 0a25 c7ec 8fa2 0a35 %PDF-1.4.%.....5
00000010: 2030 206f 626a 0a3c 3c2f 4c65 6e67 7468 0 obj.<
I tried updating my color-theme like that:
(hexl-address-region ((t (:background "#252525"))))
(hexl-ascii-region ((t (:foreground "#cfbfad"))))
But it's obviously not working. The colors are not changed :(
My full color theme:
(eval-when-compile
(require 'color-theme))
(defun sublime-text-2 ()
"Color theme that looks like the Sublime Text 2 editor."
(interactive)
(color-theme-install
'(sublime-text-2
((background-color . "#171717")
(background-mode . light)
(border-color . "#1a1a1a")
(cursor-color . "#fce94f")
(foreground-color . "#cfbfad")
(mouse-color . "black"))
(fringe ((t (:background "#1a1a1a"))))
(mode-line ((t (:foreground "#eeeeec" :background "#555753"))))
(region ((t (:foreground "#404040" :background "#CC9900"))))
(font-lock-builtin-face ((t (:foreground "#52e3f6"))))
(font-lock-comment-face ((t (:foreground "#ffffff"))))
(font-lock-function-name-face ((t (:foreground "#edd400"))))
(font-lock-keyword-face ((t (:foreground "#ff007f"))))
(font-lock-string-face ((t (:foreground "#ece47e"))))
(font-lock-type-face ((t (:foreground"#8ae234"))))
(font-lock-variable-name-face ((t (:foreground "#8ae234"))))
(minibuffer-prompt ((t (:foreground "#729fcf" :bold t))))
(font-lock-warning-face ((t (:foreground "Red" :bold t))))
(hexl-address-region ((t (:background "#252525"))))
(hexl-ascii-region ((t (:foreground "#cfbfad"))))
(speedbar-directory-face ((t (:foreground "light blue"))))
(speedbar-tag-face ((t (:foreground "#cfbfad"))))
)))
I was able to replicate your problem. There seems to be a problem with hexl-mode where it does not fontify the buffer when the mode starts.
To force hexl-mode to fontify the buffer, add this to your .emacs
(require 'hexl)
(add-hook 'hexl-mode-hook 'font-lock-fontify-buffer)
I also filed a bug report about the issue.

How do I set the colour of brackets/braces/parentheses in Emacs?

I'd like to specify the colour of {}, () and [] in a custom colour theme. Is this possible?
Update: Here's the source. Please note the in-development status of this theme; it is unsafe for use both at the workplace and around the home.
;;; Color theme based on Moria for VIM.
(defun color-theme-moria ()
"A color theme based on Moria for VIM."
(interactive)
(color-theme-install
'(color-theme-moria
((foreground-color . "#000000") ;done
(cursor-color . "#ffffff")
(background-color . "#f0f0f0") ;done
(background-mode . light)) ;done
(default ((t (nil)))) ;done
(underline ((t (:underline t)))) ;done
(modeline ((t (:foreground "black" :background "#000000"))))
(modeline-buffer-id ((t (:foreground "red" :background "#0000ff"))))
(modeline-mousable ((t (:foreground "cyan" :background "#007080"))))
(modeline-mousable-minor-mode ((t (:foreground "cyan" :background "#007080"))))
(highlight ((t (:background "#d0d0d0")))) ;done
(region ((t (:background "#c0c0c0")))) ;done
(font-lock-builtin-face ((t (:foreground "black"))))
(font-lock-constant-face ((t (:foreground "#ff0000")))) ;hmmm
(font-lock-comment-face ((t (:foreground "#786000")))) ;done
(font-lock-function-name-face ((t (:foreground "#000000" )))) ;done
; highlight ma brackets
(font-lock-add-keywords nil '(("\\([\{\}\\[\]\(\)]+\\)" 1 font-lock-keyword-face prepend)))
(font-lock-preprocessor-face ((t (:foreground "#912F11" :bold t))))
(font-lock-keyword-face ((t (:foreground "#1f3f81" :bold t)))) ; done e.g. defun
(font-lock-string-face ((t (:foreground "#077807")))) ;done
(font-lock-variable-name-face ((t (:foreground "#ff0000" )))) ;hmmm
(font-lock-warning-face ((t (:foreground "#ff0000"))))
(highlight-changes-face ((t (:background "#ff0000"))))
(highlight-changes-delete-face ((t (:foreground "red" :background "pink"))))
(show-paren-match ((t (:foreground "#2e3436" :background "#73d216"))))
(widget-field-face ((t (:foreground "pink" :background "red"))))
(widget-inactive-face ((t (:foreground "gray"))))
(custom-button-face ((t (:foreground "yellow" :background "dark blue"))))
(custom-state-face ((t (:foreground "mediumaquamarine"))))
(custom-face-tag-face ((t (:foreground "goldenrod" :underline t))))
(custom-documentation-face ((t (:foreground "#10D010"))))
(custom-set-face ((t (:foreground "#2020D0"))))
)
)
)
Try:
(font-lock-add-keywords nil '(("\\([\{\}\\[\]\(\)]+\\)" 1 font-lock-keyword-face prepend)))
For parent match only:
Evaluate the following expression or put it into your .emacs:
(custom-set-faces
'(show-paren-match ((t (:background "blue"))))
'(show-paren-mismatch ((((class color)) (:background "red" :foreground "white")))))
You can use rainbow-delimiters mode, you can install it from MELPA in Emacs24 packages system or download rainbow-delimiters.el from:
emacswiki-RainbowDelimiters
place rainbow-delimiters.el on your emacs load-path
write init code in your .emacs file:
(require 'rainbow-delimiters)
(global-rainbow-delimiters-mode)