我可以更改非活动迷你缓冲区的背景颜色吗?


9

无效的迷你缓冲区

我尝试了以下设置:

(add-hook 'minibuffer-setup-hook
      (lambda ()
        (make-local-variable 'face-remapping-alist)
        (add-to-list 'face-remapping-alist '(default (:background "green")))))

(set-face-background 'minibuffer-prompt "blue")

但它们只影响活动的迷你缓冲区:

主动式迷你缓冲区


1
我相信这也称为回声区域。
马拉巴巴2014年

1
@Malabarba:称为回显区域(当微型缓冲区处于非活动状态时)。
德鲁

Answers:


6

minibuffer-setup-hook 仅在设置(即激活)微型缓冲区时使用,而不是在禁用微型缓冲区时使用。

minibuffer-exit-hook退出迷你缓冲区时生效。也有minibuffer-inactive-mode-hook

但是,尽管它们确实会启动颜色更改(如通过(debug)在hook函数的开头添加,然后通过逐步进入调试器所示d),但似乎kill-local-variables在某些时候会删除添加的颜色。我现在没有时间进一步检查,但也许可以,或者其他人可以快速找到解决方案。抱歉,仅提供不完整的信息。

现在就走了-但很快,我猜想也许您根本不需要摆弄钩子,而只需对名称匹配的所有缓冲区进行面部映射即可\` \*Minibuf-[0-9]+\*\'


FWIW,我使用一个单独的minibuffer框架,然后将minibuffer-exit-hook其着色为框架背景:

(defun 1on1-color-minibuffer-frame-on-exit ()
  "Change background of minibuffer frame to reflect the minibuffer depth.
Use this when reducing the minibuffer recursion depth."
  (when 1on1-minibuffer-frame
    (save-window-excursion
      (select-frame 1on1-minibuffer-frame)
      (cond ((= (minibuffer-depth) 2)
             (set-background-color 1on1-active-minibuffer-frame-background))
            ((< (minibuffer-depth) 2)
             (set-background-color 1on1-inactive-minibuffer-frame-background))
            (t
             (set-background-color (hexrgb-increment-hue ; Change bg hue slightly.
                                    (frame-parameter nil 'background-color)
                                    1on1-color-minibuffer-frame-on-exit-increment)))))))

根据您的分析,我想使face-remapping-alist 永久性有效吗?有关代码标记中的反引号,请参见此答案
吉尔斯(Gilles)'所以

链接你在404提供的结果
康博·普拉萨德·

@ComproPrasad:已修复。谢谢。
提请

3

您可以尝试:

(dolist (buf '(" *Echo Area 0*" " *Echo Area 1*"))
  (with-current-buffer (get-buffer buf)
    (make-local-variable 'face-remapping-alist)
    (add-to-list 'face-remapping-alist '(default (:background "green")))))
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.