Emacs 会话/项目/窗口管理
我大部分时间都在处理 Ruby on Rails 项目,因此我需要一种方法来保存项目以及我正在处理的缓冲区/窗口的状态,主要是因为我经常发现自己切换到不同的项目几分钟,然后回到我正在做的项目。 Desktop.el 似乎非常接近,除了窗口配置保存之外。
对于那些熟悉 TextMate 的人,我正在寻找类似可以打开的 textmate 项目文件的内容,它们会打开编辑器的另一个实例,该实例仅打开该项目中的文件。
谢谢, 塞萨尔
I am working with Ruby on Rails projects most of the time so I need a way to save projects and the state of the buffers/windows I am working on, mostly because I often find myself switching to a different project for a few minutes and then going back to the project I was working on. Desktop.el seems to be very close except for the window configuration saving.
For those familiar with TextMate, I'm looking for something like the textmate project files that you can open and they open a different instance of the editor that only opens the files in that project.
Thanks,
Cezar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我试着设身处地为你着想,想出我最喜欢的 Emacs 解决方案。我能想到的最好办法是,我偶尔会进入一种模式,在这种模式下,我不希望我的窗口因处理 Emacs 中断而受到干扰,这种模式需要不同的 Emacs 资源(缓冲区/窗口)。比方说,我正在进行一个 ediff,我想转到暂存缓冲区来测试一个想法,而不用破坏我的 ediff 视角,借用 Eclipse 概念。在这种情况下,我通常会执行
Cx 5 2
来调出一个新框架。如果我已经在显示器上显示了多个帧,我将执行Cx 5 f
来选择一个命名帧。在您的情况下,您可能有一组带有“proj-x”前缀的框架和另一组带有“proj-y”前缀的框架。在这种情况下,
Cx f proj-x-foo
提供了一个快速切换来处理您的中断,Cx f proj-y-fee
将您切换回来。在大多数情况下,我认为您谈论的是两个框架,这甚至更容易:Cx f o
在两个框架之间切换。我认为最重要的一点是,使用 Emacs,人们可以“放弃”正在做的事情,而无需关闭任何东西,做其他事情,然后回到原来的环境,没有什么大惊小怪或混乱。这是使用 Emacs 可以同时打开数百个文件这一概念的必然结果,即您不需要关闭一个文件然后打开另一个文件。把它们全部打开,尽情享受吧。 :-) 当您接受这种风格时,
Cx s
就是您的朋友。I tried to put myself in your shoes and conjure up my preferred Emacs solution. Best I can come up with is that I do occasionally get into a mode where I don't want my windows mucked with by dealing with an Emacs interrupt, one that requires different Emacs resources (buffers/windows). Say for example I have an ediff going on and I want to go to the scratch buffer to test out an idea without mucking with my ediff perspective, to borrow the Eclipse notion. In such a case I generally do
C-x 5 2
to bring up a new frame. If I've already got multiple frames up on the monitor I will doC-x 5 f
to select a named frame.In your case, you might have one set of frames with a "proj-x" prefix and another with a "proj-y" prefix. In this case
C-x f proj-x-foo
provides a quick switch to handle your interruptC-x f proj-y-fee
switches you back. In most cases, I think you talking about two frames, which is even easier:C-x f o
to switch between the two frames.I think the take-home point is that with Emacs, one can "drop" what you're doing without the need to close anything, do something else and then come back to your original environment with little fuss or muss. This is a corollary to the notion that with Emacs you can have hundreds of files open simultaneously, i.e. you do not need to close a file and then open another. Open 'em all and have a ball. :-) And when you embrace this style,
C-x s
is your friend.对于与您所描述的情况类似的情况,我喜欢窗口配置注册(
Cx rw
)。将窗口配置保存到寄存器后,只需Cx rj
即可返回到已保存的配置。I like window-configuration-to-register (
C-x r w <register_name>
) for situations similar to what you're describing. Once you've save a window configuration to a register, it's justC-x r j <register_name>
to get back to your saved configuration.也许您试图让 emacs 像 IDE 一样工作,但事实并非如此。我经常在 emacs 中打开多个项目,但从不关闭 emacs,连续几周都不会。这是我几年前最终选择使用 emacs 的主要原因之一。在我当前的项目中,我在 java、ruby 和 Lisp 之间切换。我还需要编辑 jsp、erb、html 和 css 的功能,唯一我还没有解决的是 javascript。以及完全定制我的环境的能力,这就是 emacs 的力量。
我确实一直在使用 ECB,通常当我移动文件时,它会跟随我,我不是从“窗口”的角度工作,而是从“我在这里”的角度工作。特定缓冲区是否打开实际上并不重要。我还使用 IDO,因此切换缓冲区非常简单且直观。我通常最多显示两个缓冲区(但可能有很多打开的缓冲区)。 MX 对于确保您已保存也很有用,因为它会枚举所有未保存的缓冲区并提示您有关它们的信息。
当我确实必须关闭 emacs 时,我通常会通过 cd'ing 到该文件夹并输入 emacs app/controllers/my_controller.rb 很快回到原来的位置。从那里开始,轨道导航非常有帮助。 M-Shift-下箭头,我们就出发了...
Maybe you're trying to get emacs to work like an IDE, which it isn't. I often have multiple projects open in emacs and just never close emacs, not for weeks. This is one of the main reasons I ended up on emacs years ago. On my current project I switch between java, ruby and Lisp. I also need features to edit jsp, erb, html and css, the only thing I haven't sorted out yet is javascript. As well as the ability to completely customize my environment, this is the power of emacs.
I do use ECB all the time, and typically as I move around files, it follows me, I don't work from a 'windows' perspective, but from an 'Im here' perspective. A particular buffer being open or not is actually unimportant. I also use IDO, so switching buffers is really easy and intuitive. I generally have two buffers displayed max (but potentially lots open). M-X s is also useful to ensure you've saved as it will enumerate all the unsaved buffers and prompt you about them.
When I do have to close emacs, I generally get back to where I was very quickly by cd'ing to that folder and type emacs app/controllers/my_controller.rb. From there the rails navigation is very helpful. M-Shift-down arrow and we're off ...
http://www.emacswiki.org/emacs/WindowsMode - 保存和恢复 Window 配置。
http://www.emacswiki.org/emacs/WindowsMode - Saves and restores Window configuration.
eproject 具有
eproject-open-all-project-files
,其中确保当前项目中的所有文件都打开(或使用前缀 arg 调用它以选择任意项目)和 eproject-kill-project-buffers 关闭当前项目中的所有文件。这可以让您轻松开始项目,并在完成后进行清理。eproject has
eproject-open-all-project-files
, which ensures all files in the current project are opened (or invoke it with the prefix arg to choose an arbitrary project) andeproject-kill-project-buffers
which closes all the files in the current project. This lets you easily get started with a project and lets you clean up when you are done.Icicles 和 Bookmark+ 可以在多个方面为您提供帮助使用项目的方法。
Icicles and Bookmark+ can help you in several ways to use projects.