I essentially want to bring up the helm buffers list and hit RET. This goes to the previous buffer in an alt-tab-like manner.

Thought this would do the trick but stops short of actually exiting the minibuffer:

(defun helm-alt-tab ()
  "Acts as a buffer alt-tab using helm."
  • 2
    Could you please clarify what exactly you want to achieve? Spawning a helm interface is one thing, you hitting RET however is unclear (since RET should already exit helm just fine). helm-buffers-list already gives me the last buffer as preselected choice, so you get that, too. What exactly is the problem you want to solve? – wasamasa Feb 6 '15 at 7:08
  • @wasamasa I'd like to store that action sequence in a function so I can bind it to a key such that I reduce my keystrokes. – deadghost Feb 6 '15 at 7:34
  • It doesn't make any sense to involve helm in that if you're not going to use its facilities and will just get a brief flash. – wasamasa Feb 6 '15 at 9:29
  • 1
    IMHO it's useful to have the short version that just switches and the long version that preselects the alternate but lets you see the full list. I have the two different versions bound to different keys, I find them both indispensable. – Ted Zlatanov Feb 6 '15 at 13:02
(defun my-switch-to-last-buffer ()
  (switch-to-buffer nil))

No need to involve helm to have a command for switching to the last buffer interactively at all.

  • Instead of (switch-to-buffer nil) I use (switch-to-buffer (other-buffer (current-buffer)))) because the latter is better about excluding some buffers (I forget the details, but it annoyed me a while back). – Ted Zlatanov Feb 6 '15 at 12:52

I use helm like so, to do what you describe. Source unknown, but I didn't write it originally :)

(defun helm-buffers-list ()
  "Preconfigured `helm' to list buffers."
  (helm :sources '(helm-source-buffers-list
        :buffer "*helm buffers*"
        :keymap helm-buffer-map
        :truncate-lines t
        :preselect (buffer-name (other-buffer (current-buffer) 1))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.