如何调整 undo-tree-visualizer window 的大小?
How to resize the undo-tree-visualizer window?
我一直在尝试在 emacs 中打开时自动调整 undo-tree-visualizer window 的大小。为了解决这个问题,我做了一个钩子,这个钩子确实调整了 window 的大小,但是一旦钩子是 运行,光标就会停在 *undo-tree*
window 上,为了解决这个问题,我必须使用 (save-selected-window)
命令,但它不起作用。然后我决定尝试使用 (evil-window-left)
函数(我使用的是邪恶模式)强制 emacs 返回到之前的 window 但是它只会给我这个错误:
错误:
Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 0)
evil-window-left()
(if (not (get-buffer-window " *undo-tree*")) nil (select-window (get-buffer-window " *undo-tree*")) (evil-window-set-width 45) (evil-window-left))
undo-tree-hook()
run-hooks(change-major-mode-after-body-hook special-mode-hook undo-tree-visualizer-mode-hook)
apply(run-hooks (change-major-mode-after-body-hook special-mode-hook undo-tree-visualizer-mode-hook))
run-mode-hooks(undo-tree-visualizer-mode-hook)
undo-tree-visualizer-mode()
代码:
(defun undo-tree-hook ()
"Hook to make the undo-tree-visualizer window to automatically resize to become smaller"
(interactive)
(unless (not (get-buffer-window undo-tree-visualizer-buffer-name))
(select-window (get-buffer-window undo-tree-visualizer-buffer-name))
(evil-window-set-width 45)
(evil-window-left)))
(add-hook 'undo-tree-visualizer-mode-hook 'undo-tree-hook)
正如 Drew 所说,我需要将参数传递给 evil-window-left
函数,并且在执行命令之前我还使用 save-excursion
将我所在的点保存在当前缓冲区中切换到 *undo-tree*
缓冲区并调整其大小。
(defun undo-tree-hook ()
"Hook to make the undo-tree-visualizer window to automatically resize to become smaller"
(interactive)
(unless (not (get-buffer-window " *undo-tree*"))
(save-excursion
(select-window (get-buffer-window " *undo-tree*"))
(evil-window-set-width 45)
(evil-window-left 1))))
(add-hook 'undo-tree-visualizer-mode-hook 'undo-tree-hook)
我一直在尝试在 emacs 中打开时自动调整 undo-tree-visualizer window 的大小。为了解决这个问题,我做了一个钩子,这个钩子确实调整了 window 的大小,但是一旦钩子是 运行,光标就会停在 *undo-tree*
window 上,为了解决这个问题,我必须使用 (save-selected-window)
命令,但它不起作用。然后我决定尝试使用 (evil-window-left)
函数(我使用的是邪恶模式)强制 emacs 返回到之前的 window 但是它只会给我这个错误:
错误:
Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 0)
evil-window-left()
(if (not (get-buffer-window " *undo-tree*")) nil (select-window (get-buffer-window " *undo-tree*")) (evil-window-set-width 45) (evil-window-left))
undo-tree-hook()
run-hooks(change-major-mode-after-body-hook special-mode-hook undo-tree-visualizer-mode-hook)
apply(run-hooks (change-major-mode-after-body-hook special-mode-hook undo-tree-visualizer-mode-hook))
run-mode-hooks(undo-tree-visualizer-mode-hook)
undo-tree-visualizer-mode()
代码:
(defun undo-tree-hook ()
"Hook to make the undo-tree-visualizer window to automatically resize to become smaller"
(interactive)
(unless (not (get-buffer-window undo-tree-visualizer-buffer-name))
(select-window (get-buffer-window undo-tree-visualizer-buffer-name))
(evil-window-set-width 45)
(evil-window-left)))
(add-hook 'undo-tree-visualizer-mode-hook 'undo-tree-hook)
正如 Drew 所说,我需要将参数传递给 evil-window-left
函数,并且在执行命令之前我还使用 save-excursion
将我所在的点保存在当前缓冲区中切换到 *undo-tree*
缓冲区并调整其大小。
(defun undo-tree-hook ()
"Hook to make the undo-tree-visualizer window to automatically resize to become smaller"
(interactive)
(unless (not (get-buffer-window " *undo-tree*"))
(save-excursion
(select-window (get-buffer-window " *undo-tree*"))
(evil-window-set-width 45)
(evil-window-left 1))))
(add-hook 'undo-tree-visualizer-mode-hook 'undo-tree-hook)