8

A buffer can be renamed with rename-buffer command.

Is it possible to rename buffers from IBuffer?

A use case is to rename a bunch of Term buffers from Ibuffer.
The default name for Term buffers is *terminal*.

2
  • 2
    I couldn't find any command in ibuffer to rename a buffer to a specified name (R tries to give buffer an unique name, and that's the closest thing to it.) However, % m allows to mark by a regexp that matches the mode name, and * M marks all buffers with a specified major mode. It seems that rename-buffer isn't bound to anyhting in ibuffer, and without binding it yourself, you'd have to call it with M-x rename-buffer.
    – user12563
    Commented May 24, 2017 at 15:15
  • 2
    See define-ibuffer-op and ibuffer-do-rename-uniquely.
    – politza
    Commented May 24, 2017 at 15:27

1 Answer 1

2

You could try the following:

(define-ibuffer-op ibuffer-do-rename ()
  "Prompt for a new name for the selected buffers."
  (:opstring "renamed")
  (let* ((buffer-name (buffer-name buf))
         (new-name    (read-from-minibuffer "Rename buffer: "
                                            buffer-name)))
   (with-current-buffer buf
     (rename-buffer new-name))))

(eval-after-load "ibuffer"
  '(progn
     (define-key ibuffer-mode-map [?Z]    'ibuffer-do-rename)))

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.