Windows 配置到寄存器
我开始大量使用命令 Cx rw 和 Cx rj 将窗口配置存储到寄存器并在稍后调用它们,但我发现有点烦人的是,光标位置是根据窗口配置的时间存储的已保存。
基本上,我希望不存储光标位置(或自动更新),这样每当我“跳转”到存储的窗口配置时,我都会得到与上次访问它时相同的视图,而不是与创建它时相同的视图。
有什么想法吗? 天使
I'm starting to use quite heavily the commands C-x r w and C-x r j to store windows configuration to registers and recall them at a later point, but I find a bit annoying that the cursor positions are stored as per the time when the window configuration was saved.
Basically I would like that the cursor positions are not stored (or are updated automatically), so that whenever I "jump" to a stored window configuration I get the same view as when I last visited it, not as when I created it.
Any ideas?
Ángel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也发现这很烦人,只是编写了一个解决方案。使用正常功能(当前窗口配置或要注册的窗口配置)存储窗口配置。然后,在应用保存的窗口配置(或寄存器)之前,
下面的代码执行此操作。不过,您必须自己将恢复窗口配置连接到注册代码。
I also found this very annoying and just coded up a solution. Store the window config using the normal functionality (current-window-configuration or window-configuration-to-register). Then, before applying the saved window config (or register),
The code below does this. You'll have to hook up restore-window-configuration to the register code yourself though.
如果您查看源代码,
您会发现它将一个点存储为第二个参数。
只需重新定义它,
然后重新定义一个 Cx rw 快捷方式即可使用 my-window-configuration-to-register
或定义一个建议
唯一的问题是,当您跳转时它会显示错误消息到它。您可以重新定义
jump-to-register
来避免它If you take a look into a source code
you'll see that it stores a point as the second argument.
Just re-define it like
and redefine a C-x r w shortcut as well to use
my-window-configuration-to-register
Or define an advice
The only problem is that it brings up an error message when you jump to it. You may redefine
jump-to-register
to avoid it我将添加另一个使用不同方法的答案。
在跳转到另一个寄存器之前,您可以存储当前的窗口配置。这样它就会在你跳转之前存储你最新的缓冲区位置。
然而,这并非在所有情况下都有效。例如,如果您只是切换到另一个缓冲区或使用 Mx dired 或其他内容创建缓冲区,那么它将不会存储当前的窗口配置。
I'll add another answer which uses different approach.
Before you jump to another register you may store the current window configuration. This way it will store your latest buffers position just before you jump.
This will not work in all cases, however. For example if you just switch to another buffer or create a buffer with
M-x dired
or something then it will not store the current window config.作为对您问题的间接回答,您可以考虑使用
revive.el
来代替,它支持在 Emacs 重新启动时保存和恢复窗口配置,但(我相信)不会存储要点。As a indirect answer to your question, you might consider using
revive.el
instead, which supports saving and restoring window configurations across Emacs restart, but doesn't (I believe) store the point.