modulitos
modulitos

Reputation: 15844

emacs: control tab buffer cycling, or stack buffer cycling, similar to alt-tab between windows

I have consulted this resource: http://www.emacswiki.org/cgi-bin/wiki/ControlTABbufferCycling, and tried buffer-stack.el, which is useful, but I find the user experience slightly awkward without being able to visualize other buffers further down the stack. It is also outdated (2002), so I wonder if there is an improved version. Most other links on that page are broken or very old as well.

I am seeking a ctrl +tab stack-based buffer cycling, similar to the way alt + tab works with windows. Ideally it would include an indicator for my current location in the buffer list. I don't think my desired feature is too specific, since many IDE's already have this feature.

I would imagine a tool that is similar to how buffer cycling works in Eclipse. Pick below:

enter image description here

I have explored other options, but nothing seems to mimic the functionality that has already been implemented across other IDE's like Eclipse.

I am aware of ido-mode, although it does not suit my needs for rapid stack-based switching.

I am also aware of other non-stack solutions like the one below:

(global-set-key [C-tab] 'next-buffer)
(global-set-key [C-S-iso-lefttab] 'previous-buffer);Linux
(global-set-key [C-S-tab] 'previous-buffer);Windows/Linux

but I prefer a stack-based switch.

Any suggestions? Is this feature available somewhere, or even in development? Especially with an index indicator, as shown in Eclipse above. That would be awesome - I imagine it would be as a pop-up or in the mini-buffer.

Upvotes: 4

Views: 960

Answers (3)

event_jr
event_jr

Reputation: 17707

I have been maintaining a personal copy of buffer-stack. It works really well -- to the extent that I haven't thought about it for years until recently when I had to fix a legacy workaround which caused a bug.

I will put my fork up on github when time allows. I'm not averse to adding some sort of index display although it does not matter much in my use-case -- helm is great to choose from a list of buffers.

Upvotes: 0

Ehvince
Ehvince

Reputation: 18395

elscreen does a little bit what you seek: http://wikemacs.org/index.php/Elscreen
You have to create screens (tabs) on demand and you can call M-x elscreen-select-and-goto to select a screen from a list in the minibuffer.

Fortunately it is already coupled with helm: helm-elscreen. That gives a good looking and handy choice list:

  • fuzzy matching
  • scrollable list
  • choose actions (press TAB and choose "Change screen/Delete/Only").

However, you still have to create a screen manually (but I like it because I can organize sort of work areas -it is possible to isolate buffers per screen. A tab per buffer would be way too much + emacs creates many internal buffers so they can get on the way).

helm: https://github.com/emacs-helm/helm/wiki

ps: helm-buffers-list is close to the interface you want for switching buffers, without tabs…

enter image description here

Upvotes: 1

abo-abo
abo-abo

Reputation: 20352

Try out this snippet:

(defun ctrltab ()
  "List buffers and give it focus"
  (interactive)
  (if (string= "*Buffer List*" (buffer-name))
      ;; Go to next line. Go to first line if end is reached.
      (progn
        (revert-buffer)
        (if (>= (line-number-at-pos)
                (count-lines (point-min) (point-max)))
            (goto-char (point-min))
          (forward-line)))
    (list-buffers)
    (switch-to-buffer "*Buffer List*")
    (delete-other-windows)
    (forward-line)))

(global-set-key [C-tab] 'ctrltab)

It's often inferior to ido-switch-buffer, but it does its job anyway.

Upvotes: 1

Related Questions