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"))))
)
Related
On Fedora Release 31. Using Xming on Windows 7 as X server. EDIT: also Emacs 24.3 running on RHEL7 with MobaXterm 12.2 4204, whether in -Q mode or not
The scrollbar I'm seeing is a medium-dark rectangle (the scrollbar "elevator") with rounded left-hand corners and square right-hand corners, in a light-gray vertical area (the scrollbar "track"). When I mouse over the rectangle it switches to dark gray.
When I click it, it turns blue. After about 1/2 second, if not moved, it narrows about 2 pixels on the right [EDIT: on the 24.3/RHEL7/MobaXterm setup, narrows on both sides], and refuses to move. Moving the mouse will sometimes get one scroll of the window contents, and sometimes not.
If I click it and move it slightly in that 1/2 second, it will move, and continue to be movable even if I hold still for a while. But I have to move it substantially (at least half its height, it seems, in a 2000 line file) or it will then freeze at the 1/2 second mark.
Here's my current .emacs file:
(defun switch-to-next-buffer-frank ()
(interactive)
(switch-to-buffer (other-buffer)))
(defun switch-to-prev-window ()
(interactive)
(other-window -1))
(defun scroll-one-line-up (&optional arg)
"Scroll the selected window up (forward in the text) one line (or N lines)."
(interactive "p")
(scroll-up (or arg 1)))
(defun scroll-one-line-down (&optional arg)
"Scroll the selected window down (backward in the text) one line (or N)."
(interactive "p")
(scroll-down (or arg 1)))
(global-set-key [(control ?z)] 'scroll-one-line-up)
(global-set-key [(meta ?z)] 'scroll-one-line-down)
(global-set-key [(meta ?g)] 'goto-line)
(global-set-key [(control ?x)(k)] 'kill-this-buffer)
(global-set-key [(control meta ?l)] 'switch-to-next-buffer)
(global-set-key [(control shift meta ?l)] 'switch-to-prev-buffer)
(global-set-key [(control tab)] 'other-window)
(global-set-key [(control shift iso-lefttab)] 'switch-to-prev-window)
(modify-syntax-entry ?_ "w")
(setq scroll-bar-mode 'left)
(setq scroll-bar-adjust-thumb-portion nil)
(setq gutter-buffers-tab-visible-p nil)
(setq inhibit-startup-screen t)
(setq mouse-yank-at-point t)
(setq inhibit-startup-buffer-menu t)
(tool-bar-mode -1)
(delete-selection-mode 1)
;(setq inhibit-splash-screen t)
;(setq inhibit-startup-message t)
;(setq initial-scratch-message nil)
;(delete-selection-mode 1)
;
;(defun ask-user-about-supersession-threat (fn)
; "blatantly ignore files that changed on disk"
; )
(custom-set-variables
;; custom-set-variables 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.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(ansi-color-names-vector
["#3F3F3F" "#CC9393" "#7F9F7F" "#F0DFAF" "#8CD0D3" "#DC8CC3" "#93E0E3" "#DCDCCC"])
'(background-color "#000000")
'(background-mode dark)
'(company-quickhelp-color-background "#4F4F4F")
'(company-quickhelp-color-foreground "#DCDCCC")
'(cursor-color "#ffffff")
'(custom-enabled-themes (quote (manoj-dark)))
'(custom-safe-themes
(quote
("54f2d1fcc9bcadedd50398697618f7c34aceb9966a6cbaa99829eb64c0c1f3ca" "4138944fbed88c047c9973f68908b36b4153646a045648a22083bd622d1e636d" "8885761700542f5d0ea63436874bf3f9e279211707d4b1ca9ed6f53522f21934" "59e82a683db7129c0142b4b5a35dbbeaf8e01a4b81588f8c163bd255b76f4d21" default)))
'(fci-rule-color "#383838")
'(font-use-system-font t)
'(foreground-color "#00ff00")
'(gutter-buffers-tab-visible-p nil t)
'(indent-tabs-mode nil)
'(nrepl-message-colors
(quote
("#CC9393" "#DFAF8F" "#F0DFAF" "#7F9F7F" "#BFEBBF" "#93E0E3" "#94BFF3" "#DC8CC3")))
'(pdf-view-midnight-colors (quote ("#DCDCCC" . "#383838")))
'(query-user-mail-address nil)
'(tool-bar-mode nil)
'(user-mail-address "fsheeran#gmail.com")
'(vc-annotate-background "#2B2B2B")
'(vc-annotate-color-map
(quote
((20 . "#BC8383")
(40 . "#CC9393")
(60 . "#DFAF8F")
(80 . "#D0BF8F")
(100 . "#E0CF9F")
(120 . "#F0DFAF")
(140 . "#5F7F5F")
(160 . "#7F9F7F")
(180 . "#8FB28F")
(200 . "#9FC59F")
(220 . "#AFD8AF")
(240 . "#BFEBBF")
(260 . "#93E0E3")
(280 . "#6CA0A3")
(300 . "#7CB8BB")
(320 . "#8CD0D3")
(340 . "#94BFF3")
(360 . "#DC8CC3"))))
'(vc-annotate-very-old-color "#DC8CC3"))
(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 (:foreground "#00ff00" :background "#000000" :size "10pt" :family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 144 :width normal))))
'(font-lock-builtin-face ((t (:foreground "#00ccff"))))
'(font-lock-comment-delimiter-face ((t (:foreground "#ffff00" :slant normal))))
'(font-lock-comment-face ((t (:foreground "#ffff00" :slant normal))))
'(font-lock-constant-face ((t (:foreground "#00ff99" :weight normal))))
'(font-lock-function-name-face ((t (:foreground "#00ff00" :weight normal :height 1.0))))
'(font-lock-preprocessor-face ((t (:foreground "#ff4040"))))
'(font-lock-string-face ((t (:foreground "#00ffee"))))
'(font-lock-type-face ((t (:foreground "#33ccff"))))
'(font-lock-variable-name-face ((t (:foreground "#66ff00"))))
'(italic ((t nil)))
'(mode-line ((t (:background "#445555" :foreground "#ffffff" :box (:line-width 2 :color "#445555") :height 1.0))))
'(mode-line-buffer-id ((t (:background "#445555" :foreground "#55ff55" :weight normal :height 1.0))))
'(mode-line-emphasis ((t (:weight normal))))
'(mode-line-highlight ((t (:box (:line-width 2 :color "#445555")))))
'(mode-line-inactive ((t (:background "#445555" :foreground "#ffffff" :box (:line-width 2 :color "#445555") :weight normal :height 1.0))))
'(scroll-bar ((t (:background "#334444" :foreground "#ddffff")))))
Here's a screenshot: of emacs -Q 24.3/RHEL7/MobaXterm:
Then here is the same window after I've held the top scrollbar about 1 second without moving after clicking down:
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.
I want to define a bunch of faces for different characters like below:
(defface char-face-a
'((((type tty) (class color)) (:background "yellow" :foreground "black"))
(((type tty) (class mono)) (:inverse-video t))
(((class color) (background dark)) (:background "yellow" :foreground "black"))
(((class color) (background light)) (:background "yellow" :foreground "black"))
(t (:background "gray")))
"Face for marking up A's"
:group 'char-faces)
(defface char-face-b
'((((type tty) (class color)) (:background "red" :foreground "black"))
(((type tty) (class mono)) (:inverse-video t))
(((class color) (background dark)) (:background "red" :foreground "black"))
(((class color) (background light)) (:background "red" :foreground "black"))
(t (:background "gray")))
"Face for marking up B's"
:group 'char-faces)
...
...
Is there anyway to avoid explicitly write all the defface definitions and make the code less redundant? (I know make-face, but it seems deprecated and can't set attributes according to different terminal types as defface does.)
make-face is not at all deprecated, AFAICT.
defface can make use of inheritance -- see face attribute :inherit.
Dunno whether that helps in your particular context.
How about a macro and a loop that operates on a mapping of suffixes <-> colors:
(defmacro brian-def-char-face (letter backgrnd foregrnd)
`(defface ,(intern (concat "brian-char-face-"
letter))
'((((type tty) (class color))
(:background
,backgrnd
:foreground
,foregrnd))
(((type tty) (class color)) (:inverse-video t))
(((class color) (background dark))
(:foreground
,foregrnd
:background
,backgrnd))
(((class color) (background light))
(:foreground
,foregrnd
:background
,backgrnd))
(t (:background "gray")))
,(concat "Face for marking up " (upcase letter) "'s")))
(let ((letcol-alist '((s . (white black))
(t . (black yellow))
(u . (green pink)))))
(loop for elem in letcol-alist
for l = (format "%s" (car elem))
for back = (format "%s" (cadr elem))
for fore = (format "%s" (caddr elem))
do
(eval (macroexpand `(brian-def-char-face ,l ,back ,fore)))))
Gives you new faces:
brian-char-face-s, brian-char-face-t, and brian-char-face-u
Now you just need to maintain the list of letter<->color mappings, and possibly extend the macro to support other face properties (if desired).
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.
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.