如何为特定缓冲区设置本地面属性缓冲区?

9
我希望只在Org-Agenda缓冲区中更改面部属性。 因此,我需要局部更改Org-Agenda面部属性。
以下是我的代码:(全局)
(defun my-org-agenda-hl-line ()
  (hl-line-mode)
  (set-face-attribute 'hl-line nil
                  :box '(:color "deep pink" :line-width 2))
)
(add-hook 'org-agenda-mode-hook 'my-org-agenda-hl-line)

请帮我将此缓冲区本地化。谢谢。

2个回答

13

以下是您需要做的:

;; First create new face which is a copy of hl-line-face
(copy-face 'hl-line 'hl-line-agenda-face)

;; Change what you want in this new face 
(set-face-attribute 'hl-line-agenda-face nil
                    :box '(:color "deep pink" :line-width 2))

;; The function to use the new face
(defun my-org-agenda-hl-line ()
  (set (make-local-variable 'hl-line-face) ; This is how to make it local
       'hl-line-agenda-face)
    (hl-line-mode))

;; Finally, the hook
(add-hook 'org-agenda-mode-hook 'my-org-agenda-hl-line)

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接