Maxx
Maxx

Reputation: 13

maintaining emacs buffer history

How do I configure Emacs to keep track of the files visited and then allow me to navigate the chain back and forth? I'm not talking about mini-buffer or the cursor positions within the buffer, but rather the files themselves. I hope I got the terminology right of buffer vs file vs window.

ie if I visit

foo.c -> dired home -> readme.txt -> buffer-list

then by pressing some "back key" 3 times, file foo.c should open in the same (current) buffer I was in. Another way to think of it, is how navigation history works in Firefox - I want to browse files within the buffer like the webpages within a Firefox tab.

Upvotes: 1

Views: 410

Answers (1)

Drew
Drew

Reputation: 30718

Use command previous-buffer which is bound by default to C-x <C-left> and C-x <left> (or nakedly, as I prefer to write them, C-x C-left and C-x left).

Similarly, to move in the other direction, there is command next-buffer, bound by default to C-x C-right and C-x right.


If you use library misc-cmds.el then you can remap the keys bound to these vanilla commands to repeatable versions previous-buffer-repeat and next-buffer-repeat.

(global-set-key [remap previous-buffer] 'previous-buffer-repeat)
(global-set-key [remap next-buffer]     'next-buffer-repeat)

Then you can just hold down right or left after hitting C-x, to quickly cycle through the buffers.

Upvotes: 1

Related Questions