Monday, June 23, 2008

Emacs #1 - saving your state after exit , and tabbar use

Often you need to restore your emacs session, but it's not a good way to load all buffer per start, just keep it.
Also, there are useful addition to emacs called tabbar.el it can keeps your buffers without its creating.
I don't want to write where you can find this file - if you are using debian you can find it out in emacs-goodies-el package.
So, the first step is to enable tabbar mode by default:

(tabbar-mode t)

After this I recommend to bind a keys for switch between tabs:

(global-set-key [(control shift w)] 'tabbar-forward)
(global-set-key [(control shift q)] 'tabbar-backward)
(global-set-key [(control shift e)] 'tabbar-forward-group)
(global-set-key [(control shift d)] 'tabbar-backward-group)

You can use your own key bindings depending on your choice and feel.
The second step is to use a desktop addition (that comes with emacs22):

(when (fboundp 'desktop-load-default)
(desktop-load-default)
(mapcar
(lambda (symbol)
(add-to-list 'desktop-globals-to-save symbol))
'((buffer-name-history . 100)
(dired-regexp-history . 20)
(extended-command-history . 100)
(file-name-history . 500)
(grep-history . 50)
(minibuffer-history . 100)
(query-replace-history . 60)
(read-expression-history . 60)
(regexp-history . 60)
(regexp-search-ring . 20)
(search-ring . 20)
(shell-command-history . 50)))
;;; (desktop-read)
)

(add-to-list 'desktop-locals-to-save 'buffer-file-coding-system)
(add-to-list 'desktop-locals-to-save 'tab-width)

(setq-default desktop-missing-file-warning nil)
(setq-default desktop-path (quote ("~")))
(setq-default desktop-save t)
(setq-default desktop-save-mode t)

(setq-default save-place t)

And this all, this code snippets from my ~/.emacs file.

2 comments:

vyazovoi.info said...

Also winsav.el may be intresting. Winsav can save your layout to file and restore them.

Supervisor said...

hm, I don't heard anything about this, could you show you emacs code for this extension ?

and ... what the basics principles of this extension ?