18

工作区,我的意思是 - 我需要保存我打开的缓冲区的状态(可能在用户指定的工作区文件中)并快速切换到另一组打开的缓冲区,例如继续处理与另一个项目相关的文件。

是否有允许这样做的 Emacs 插件?你会推荐哪一个?

4

6 回答 6

11

我使用save-visited-filesworkgroups的组合。事实上,工作组可能会自行完成大部分您想做的事情。

我的配置:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; workgroups for windows

(setq wg-prefix-key (kbd "C-c z")
      wg-no-confirm t
      wg-file (concat emacs-persistence-directory "workgroups")
      wg-use-faces nil
      wg-switch-on-load nil)

(defun wg-load-default ()
  "Run `wg-load' on `wg-file'."
  (interactive)
  (wg-load wg-file))

(defun wg-save-default ()
  "Run `wg-save' on `wg-file'."
  (interactive)
  (when wg-list
    (with-temp-message ""
      (wg-save wg-file))))

(with-library 'workgroups
  (define-key wg-map (kbd "C-l") 'wg-load-default)
  (define-key wg-map (kbd "C-s") 'wg-save-default)
  (workgroups-mode 1)
  (add-hook 'auto-save-hook 'wg-save-default)
  (add-hook 'kill-emacs-hook 'wg-save-default))
于 2012-06-29T21:17:42.990 回答
6

就个人而言,我一直在使用`persp-mode'

基于perspective-elNathan Weizenbaum 的 Emacs 观点。但是框架之间共享的观点+从/到文件保存/恢复的能力。

于 2013-12-16T19:05:15.067 回答
2

如果你使用 Linux/Gnome3,你可以试试这个扩展:https ://extensions.gnome.org/extension/361/emacs-manager/ 这个扩展允许你通过管理多个 emacs 守护进程同时处理不同的项目,并且保存/恢复缓冲区的状态。

于 2012-07-02T04:57:02.937 回答
2

desktop.el 将对您的情况有所帮助。

它可以(从它的介绍页面复制)来自 emacs 包缓冲区:

保存桌面,即 - 一些全局变量 - 带有关联文件的缓冲区列表。对于每个缓冲区还有 - 主要模式 - 默认目录 - 点 - 标记和标记活动 - 缓冲区只读 - 一些局部变量

于 2012-06-29T17:39:28.980 回答
2

HIROSE Yuuji's revive.el has worked nicely for me for quite some time. I use the standard configuration presented in the comments in revive.el. The documentation is well written and revive is very easy to use and configure. In particular, revive.el has better support than some for reviving configurations that are a bit more complex. It is particularly nice if you combine it with the HIROSE Yuuji's windows.el. They are made to work together. windows.el makes it possible to recall window splits, etc. revive.el is built with an eye toward extensibility toward deeper mode integration for particular setups. But for my uses, I have found it to be quite nice out of the box, though I think I'll next tweak it to revive w3m windows which I currently don't have setup (Update: I do now: see bottom).

Here is my revive config. I include some helpful comments, first for windows.el and then revive.el inline:

(provide 'my-revive-config)

(require 'windows) ; use this with revive so that window splits are recallable
                   ; too

(win:startup-with-window) ; start with window 1


;;;[Key Bindings]
;;;
;;;   The default prefix key stroke for Windows is `C-c C-w'.  If it
;;; causes  you some  troubles, see  the  section  `Customizations'.
;;; Here are the default key bindings.
;;;
;;;     C-c C-w 1       Switch to window 1 (Q)
;;;     C-c C-w 2       Switch to window 2 (Q)
;;;        :
;;;     C-c C-w 9       Switch to window 9 (Q)
;;;     C-c C-w 0       Swap windows with the buffer 0 (Q)
;;;                 (Select unallocated frame(Emacs 19))
;;;     C-c C-w SPC     Switch to window previously shown (Q)
;;;     C-c C-w C-n     Switch to next window
;;;     C-c C-w C-p     Switch to previous window
;;;     C-c C-w !       Delete current window (Q)
;;;     C-c C-w C-w     Window operation menu
;;;     C-c C-w C-r     Resume menu
;;;     C-c C-w C-l     Local resume menu
;;;     C-c C-w C-s     Switch task
;;;     C-c C-w =       Show window list (Q)
;;;
;;;   The  key strokes  to  select  windows from  1    to 9 must  be
;;; frequently used, so the alternative key strokes `C-c [Num.]' are
;;; available  by default  (And  any  function  with (Q)mark can  be
;;; invoked without  C-w).  To disable these  quick key strokes, set
;;; the variable win:quick-selection to `nil' in your ~/.emacs.

(autoload 'save-current-configuration "revive" "Save status" t)
(autoload 'resume "revive" "Resume Emacs" t)
(autoload 'wipe "revive" "Wipe Emacs" t)

(define-key ctl-x-map "S" 'save-current-configuration)
(define-key ctl-x-map "F" 'resume)
(define-key ctl-x-map "K" 'wipe)

;;;
;;;[How to use]
;;;
;;;  Call `save-current-configuration' (`C-x S' if you define key as
;;; above) when you want to save current editing status and call
;;; `resume' to restore it. Numerical prefix arg to them specifies
;;; the buffer number in which the editing status will be saved.
;;; Here the buffer refers to a revive s-exp in ~/.revive.el of
;;; which there can be n
;;;
;;;     [Sample Operations]
;;;     C-u 2 C-x S     ;save status into the buffer #2
;;;     C-u 3 C-x F     ;load status from the buffer #3

There are variants of this that others like revive-plus.el and a slightly modified clone on github, but I prefer the original.

Update Monday, January 12, 2015: Now I can restore w3m in revive (see revive.el docs for details and in particular look at examples in revive:major-mode-command-alist-default):

(setq revive:major-mode-command-alist-private
      '(("*w3m*"    . w3m)))

Notice you are telling revive the name of the w3m buffer. Even if you have multiple tabs, only the first one need be enumerated as above.

Here is the w3m variable I have set to restore all tabs from the previous session:

(setq w3m-session-load-last-sessions t)
于 2015-01-11T01:02:44.220 回答
0

弹丸模式可以实现你什么:

在项目中切换缓冲区:projectile-switch-to-buffer

切换项目: projectile-switch-to-project

我有这样的事情:

(global-set-key (kbd "C-x b") '(λ ()
                                (interactive)
                                (if (projectile-project-p) 
                                    (call-interactively 'projectile-switch-to-buffer)
                                (call-interactively 'ivy-switch-buffer))))

(global-set-key (kbd "C-x B") 'ivy-switch-buffer)
于 2020-02-08T15:56:48.457 回答