Emacs: bufferfile.el – Delete or rename buffer file names with their associated buffers

The bufferfile Emacs package provides helper functions to delete and rename buffer files:

  • bufferwizard-rename-file: Renames the file that the current buffer is visiting. This command renames the file name on disk, adjusts the buffer name, and updates any indirect buffers or other buffers associated with the old file.
  • bufferwizard-delete-file: Delete the file associated with a buffer and kill all buffers visiting the file, including indirect buffers.

Installation with straight (Emacs version < 30)

To install bufferfile with straight.el:

  1. It if hasn’t already been done, add the straight.el bootstrap code to your init file.
  2. Add the following code to the Emacs init file:
(use-package bufferfile
  :ensure t
  :straight (bufferfile
             :type git
             :host github
             :repo "jamescherti/bufferfile.el"))Code language: Lisp (lisp)

Alternative installation: Installation with use-package and :vc (Built-in feature in Emacs version >= 30)

To install bufferfile with use-package and :vc (Emacs >= 30):

(use-package bufferfile
  :ensure t
  :vc (:url "https://github.com/jamescherti/bufferfile.el"
       :rev :newest))Code language: Lisp (lisp)

Customization: Making bufferwizard use version control (VC), such as Git, when renaming or deleting files?

To make bufferwizard use version control (VC) when renaming or deleting files, you can set the variable bufferfile-use-vc to t. This ensures that file operations within bufferwizard interact with the version control system, preserving history and tracking changes properly.

(setq bufferfile-use-vc t)Code language: plaintext (plaintext)

Links

Leave a Reply

Your email address will not be published. Required fields are marked *