0

Does Emacs Prelude provide a key binding for bury-buffer, which I use very frequently?

2 Answers 2

2

No. Set it yourself, e.g. (global-set-key (kbd "C-c C-b") 'bury-buffer).

1

As Heikki correctly points out, Prelude does not bind bury-buffer for your convenience, so you should do it yourself. I would additionally like to offer a couple of suggestions which make un/burying buffers more convenient for me:

(defun my-bury-buffer (&optional buffer-or-name unbury)
  "Un/bury buffer.
With prefix argument UNBURY, call `unbury-buffer'. Otherwise pass
BUFFER-OR-NAME to `bury-buffer'."
  (interactive "i\nP")
  (if unbury
      (unbury-buffer)
    (bury-buffer buffer-or-name)))

;; Sample key binding
(global-set-key (kbd "C-x B") #'my-bury-buffer)

This allows me to bury and unbury buffers with a single global key binding.

A more general approach to unburying is to enable winner-mode.

Quoth (emacs) Window Convenience:

Winner mode is a global minor mode that records the changes in the
window configuration (i.e., how the frames are partitioned into
windows), so that you can undo them.  You can toggle Winner mode with
‘M-x winner-mode’, or by customizing the variable ‘winner-mode’.  When
the mode is enabled, ‘C-c left’ (‘winner-undo’) undoes the last window
configuration change.  If you change your mind while undoing, you can
redo the changes you had undone using ‘C-c right’ (‘M-x winner-redo’).

With winner-mode enabled, you can type C-c and C-c to bury, unbury, bury a bit deeper, unbury Kill Bill-style, etc. not just buffers but entire window configurations, too. It's basically window management for cats.

2
  • C-h k for C-x B says it's already bound. I'm guessing thats not a big problem. "C-x b (translated from C-x B) runs the command switch-to-buffer (found in global-map), which is an interactive compiled Lisp function in `window.el'." Commented Dec 8, 2017 at 16:39
  • @joshsverns Emacs defaults to folding lower- and upper-case letters to the same key binding. If you bind C-x B explicitly Emacs will distinguish it from C-x b, so there's no issue with using C-x B. This particular key just happens to be the one I use; you're free to pick any key that tickles your fancy.
    – Basil
    Commented Dec 8, 2017 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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