【发布时间】:2012-04-20 01:25:45
【问题描述】:
我通常让 hl-line 采用较暗的当前背景阴影。这在编辑缓冲区时效果很好。但是,在某些缓冲区中,例如 Org 议程和 Gnus 组缓冲区,我想使用更鲜艳的颜色(代替光标)。
具体来说,我想改变 gnus-hl-line 中 hl-line 的颜色而不影响其他缓冲区中 hl-line 的颜色。
(add-hook 'gnus-summary-mode-hook 'gnus-hl-line)
(add-hook 'gnus-group-mode-hook 'gnus-hl-line)
(defun gnus-hl-line ()
(hl-line-mode 1)
(set (make-local-variable 'line-move-visual) nil)
(setq cursor-type nil))
谢谢,
使用 Phil 的建议的最终解决方案。它大部分时间都使用中性 hl 线,但有时可以看到粗体 hl 线,例如在 Gnus 和 Org 议程中
;; From emacs-wiki:
(defun shade-color (intensity)
"print the #rgb color of the background, dimmed according to intensity"
(interactive "nIntensity of the shade : ")
(apply 'format "#%02x%02x%02x"
(mapcar (lambda (x)
(if (> (lsh x -8) intensity)
(- (lsh x -8) intensity)
0))
(color-values (cdr (assoc 'background-color (frame-parameters)))))))
;; Default hl
(global-hl-line-mode t)
(make-variable-buffer-local 'global-hl-line-mode)
(set-face-background hl-line-face (shade-color 08))
(defface hl-line-highlight-face
'((t :inherit highlight))
"Face for highlighting the current line with `hl-line-fancy-highlight'."
:group 'hl-line)
(defun hl-line-fancy-highlight ()
(set (make-local-variable 'hl-line-face) 'hl-line-highlight-face)
;; (set (make-local-variable 'line-move-visual) nil)
;; (set (make-local-variable 'cursor-type) nil)
(setq global-hl-line-mode nil)
(hl-line-mode))
(add-hook 'org-agenda-mode-hook 'hl-line-fancy-highlight)
(add-hook 'gnus-summary-mode-hook 'hl-line-fancy-highlight)
(add-hook 'gnus-group-mode-hook 'hl-line-fancy-highlight)
【问题讨论】:
-
您能否解释一下代码中的哪里可以分别设置 org-agenda、gnus-summary 和 gnus-group 的强度和颜色?谢谢!
标签: emacs line text-cursor