运行M-x-git-gutter:打开或切换到缓冲区并保存缓冲区时清除

时间:2014-04-24 21:31:12

标签: emacs

我使用Emacs Live,其中包含git-gutter.el。问题是它与linum-mode的效果不佳。运行 M-x git-gutter:clear时,问题已解决。我希望在我的init.el函数中包含一个函数,只要我切换到现有缓冲区或打开一个新缓冲区,它就会执行git-gutter:clear。我还希望在保存缓冲区时运行(通过 C-x C-s )。感谢。

1 个答案:

答案 0 :(得分:1)

(defun user2475612-forward-window ()
  (interactive)
    (other-window 1)
    (git-gutter:clear) )

(defun user2475612-backward-window ()
  (interactive)
    (other-window -1)
    (git-gutter:clear) )

(add-hook 'window-configuration-change-hook (lambda ()
  (git-gutter:clear) ))

(add-hook 'change-major-mode-hook (lambda ()
  (git-gutter:clear) ))

(add-hook 'after-save-hook (lambda ()
  (git-gutter:clear) ))

以下是处理Emacs中包含的标准挂钩的文档的链接:

http://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html