【问题标题】:How to set a buffer locally face attribute for a particular buffer?如何为特定缓冲区设置缓冲区本地人脸属性?
【发布时间】:2013-07-11 19:50:31
【问题描述】:

我只想更改 Org-Agenda 缓冲区中的人脸属性。 所以我需要更改 Org-Agenda 人脸属性 buffer local

这是我的代码:(全局)

(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)

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

【问题讨论】:

    标签: emacs customization font-face org-mode emacs-faces


    【解决方案1】:

    试试face-remap-add-relative

    (add-hook 'org-agenda-mode-hook
              (lambda ()
                (hl-line-mode)
                (face-remap-add-relative 'hl-line :box '(:color "deep pink" :line-width 2))))
    

    另外,请参阅How to modify-face for a specific buffer

    【讨论】:

      【解决方案2】:

      这是你需要做的:

      ;; 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)
      

      【讨论】:

        猜你喜欢
        • 2014-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-29
        • 1970-01-01
        • 2021-01-14
        相关资源
        最近更新 更多