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

sta*_*ner 8 emacs customization org-mode font-face emacs-faces

我想只更改Org-Agenda缓冲区中的face属性.所以我需要在本地更改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)
Run Code Online (Sandbox Code Playgroud)

请帮我在本地制作这个缓冲区.谢谢

Ale*_*iev 11

这是你需要做的:

;; 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)
Run Code Online (Sandbox Code Playgroud)