2

在同一帧内使用活动的小缓冲区,任何人都可以想出一种方法让 switch 的other-window行为类似于 a minibuffer-exit-hook(完全退出小缓冲区)?

本质上,我想让主窗口在焦点位于 minibuffer 中时显示非活动模式颜色,然后当我从半活动 minibuffer 移动到另一个窗口时将 modline 更新为活动(对于具有焦点的窗口)使用other-window.

例如,在同一框架中(并排)打开了两个窗口 -- 窗口 #1 是我的笔记 -- 窗口 #2 是我要修改的记录的老大哥数据库显示。因此,我打开 minibuffer 输入我的记录修改,然后在 Window #1 中的笔记和 minibuffer 之间来回切换以复制和粘贴相关部分。当使用other-window在三个区域之间跳转时,仍然很难知道焦点是在 minibuffer 中还是在另一个窗口中。

Window # 1 (notes)         |     Window # 2 (bbdb record display)
                           |
___________________________|_____________________________________
Name:  lawlist . . .

(defun enter-minibuffer-setup ()
(set-face-attribute 'mode-line nil
    :height 160 :foreground "gray70" :background "black")
(set (make-local-variable 'face-remapping-alist)
    '((default :background "gray10" :foreground "yellow"))))

(defun exit-minibuffer-setup ()
(set-face-attribute 'mode-line nil
    :height 160 :foreground "black" :background "gray70"))

(add-hook 'minibuffer-setup-hook 'enter-minibuffer-setup)

(add-hook 'minibuffer-exit-hook  'exit-minibuffer-setup)
4

2 回答 2

1

一种选择是“建议”该other-window函数在切换到 minibuffer 时执行某种形式。

例如,当您使用 循环返回时,以下代码会将 minibuffer 提示变为绿色other-window,如果您进入非 minibuffer 窗口,则会将提示变为灰色:

(defadvice other-window (after adv-other-window-minibuffer
                               (COUNT &optional ALL-FRAMES))
  "Make minibuffer prompt green when switched to"
  (if (minibufferp)
      (set-face-attribute 'minibuffer-prompt nil
                          :foreground "green" :background "black")
    (set-face-attribute 'minibuffer-prompt nil
                          :foreground "dark grey" :background "black")))

(ad-activate 'other-window)

当然,您不仅限于设置 minibuffer 提示,但我不清楚您究竟想要达到什么效果。

于 2013-10-24T02:18:23.503 回答
0

更新草稿——借(minibufferp)自@Carl Groner

(defun enter-minibuffer-setup ()
  (set-face-attribute 'mode-line nil
    :height 160 :foreground "gray70" :background "black")
  (set (make-local-variable 'face-remapping-alist)
    '((default :background "black" :foreground "yellow")))
  (set-face-attribute 'minibuffer-prompt nil
    :background "black" :foreground "cyan"))

(defun exit-minibuffer-setup ()
  (set-face-attribute 'mode-line nil
    :height 160 :foreground "black" :background "gray70")
  (set-face-attribute 'minibuffer-prompt nil
    :background "black" :foreground "cyan"))

(add-hook 'minibuffer-setup-hook 'enter-minibuffer-setup)

(add-hook 'minibuffer-exit-hook 'exit-minibuffer-setup)

(defun lawlist-minibuffer-conditions ()
  (cond
    ((minibufferp)
      (set-face-attribute 'mode-line nil
        :height 160 :foreground "gray70" :background "black")
      (set-face-attribute 'minibuffer-prompt nil
        :background "black" :foreground "cyan"))
    (t
      (set-face-attribute 'mode-line nil
        :height 160 :foreground "black" :background "gray70")
      (set-face-attribute 'minibuffer-prompt nil
        :background "black" :foreground "gray70")) ))

(defun lawlist-forward-window ()
(interactive)
  (other-window 1)
  (lawlist-minibuffer-conditions))

(defun lawlist-backward-window ()
(interactive)
  (other-window -1)
  (lawlist-minibuffer-conditions))
于 2013-10-24T01:24:25.460 回答