在 git 中切换分支时,如何让 Emacs 恢复所有未更改的缓冲区?

发布于 2024-12-05 06:37:17 字数 706 浏览 4 评论 0原文

通常,当我在git中切换分支时,如果文件是在Emacs中打开的,那么Emacs问我是否要还原它们(正如它认为它们在磁盘上更改了),即使内容是相同的。

首先,我想找到一种方法,让Emacs根本不问我,如果磁盘上的内容与缓冲区中的内容相同。

其次,我想要一个命令,它可以恢复(不查询)我所有没有未得救的更改的开放缓冲区,并向我询问那些确实没有保存的更改的命令。

另外,我可以尝试有关其他解决方案,工作方式等的建议。如果人们能给我开始从哪里开始,我很高兴写Emacs-Lisp。

PS我在OSX上使用Aquamac,如果很重要。

编辑:

嗯,我发现Revbuffs软件包几乎是我需要的。当然足以阻止我想尝试自己写东西。 (我将Revbuff映射到CMD-R,它可以很好地工作。类似于其他Mac应用程序中的CMD-R)。

全球 - 自动纠正模式将是一个非常好的解决方案,我希望我可以选择两个答案。我更喜欢Revbuff,仅仅是因为一种可能是不合理的,想控制发生的事情的感觉。

我有点猜测,如果我从emacs内访问了git,那么它可能会更容易处理,但是我目前更喜欢通过命令行访问git。 (我还没有足够长时间使用EMAC来使其成为我的操作系统)。不过,我会更彻底地调查玛格特。

EDIT2:

我已经使用Magit已有一年了,可以强烈推荐它来处理来自Emacs内部的GIT。但是,每当我在emacs之外进行重新检查时,我仍然会使用Revbuff。

Often, when I switch branches in git, if the files are open in emacs, then emacs asks if I want to revert them (as it thinks they've changed on disk) even though the contents are identical.

Firstly I'd like to find a way for emacs to not ask me about it at all if the contents on disk are identical to those in the buffer.

Secondly I'd like a command that reverted (without query) all my open buffers that have no unsaved changes, and queried me about those that do have unsaved changes.

Alternatively, I'd be open to suggestions about other solutions, ways of working, etc I could try. I'm fairly happy writing emacs-lisp if people can give me pointers on where to start.

PS I'm using Aquamacs on OSX if that matters.

Edit:

Well, I've found the revbuffs package to be pretty much what I need. Certainly enough to stop me wanting to try and write anything new myself. (I mapped revbuffs to Cmd-R which works quite nicely. Kind of similar to Cmd-R in other Mac apps).

Global-auto-revert mode would have been a perfectly fine solution, and I wish I could choose two answers. I prefer revbuffs simply because of a, possibly irrational, feeling of wanting to be in control of what happens.

I'd kind of guessed that if I accessed git from within emacs, then it could probably be handled easier, but I currently prefer accessing git through the commandline. (I haven't quite been using emacs long enough to make it my operating system). I will investigate magit a little more thoroughly though.

Edit2:

I've been using magit for a year now and can highly recommend it for dealing with git from within emacs. However I still use revbuffs whenever I do a rebase outside of emacs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半衾梦 2024-12-12 06:37:17

也许您想要全局自动纠正模式。尝试运行global-auto-reverver-mode,如果您喜欢的话,可以将(Global-Auto-Revert-Mode)添加到您的〜/.emacs文件中。

Perhaps you'd like the global auto-revert mode. Try running global-auto-revert-mode and if you like it you can add (global-auto-revert-mode) to your ~/.emacs file.

风铃鹿 2024-12-12 06:37:17

尝试 revbufs package

revbufs.el是一个微小的emacs软件包,当您在EMAC和外部工具中都进行了编辑时,可以安全地恢复缓冲区(例如,代码生成器,例如

Try the revbufs package:

revbufs.el is a tiny Emacs package that safely reverts your buffers when you have files being edited both in Emacs and via external tools (e.g., code generators such as Jomtool)...

梦里南柯 2024-12-12 06:37:17

Magit package do this automatically, when you activate magit-ionotify-mode (inotify need emacs 24.4 on linux). Its description you can find here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文