Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/oantolin/epithet

Emacs package to rename buffers with descriptive names
https://github.com/oantolin/epithet

Last synced: 30 days ago
JSON representation

Emacs package to rename buffers with descriptive names

Awesome Lists containing this project

README

        

/epithet (noun) ep⸱i⸱thet |ˈe-pə-ˌthet also -thət/

1. a characterizing word or phrase accompanying or occurring in place
of the name of a person or thing.

* Overview

This package provides a function =epithet-rename-buffer= to rename
the current buffer with a descriptive name. The name suggestion is
governed by the =epithet-suggesters= hook variable: each hook
should return either a name suggestion or nil, they are called in
turn and the first non-nil suggestion is taken.

A cute trick is too add =buffer-file-name= to =epithet-suggesters=: this
has the effect of suggesting the full path for buffers associated with
files.

There are currently suggestion functions for eww, info, help and occur
buffers. For eww there are two, in fact, one that suggests the page
title and one that suggests the URL (the title is the default).

The =epithet-rename-buffer= function can be called interactively or
added to appropriate hooks to rename automatically. If called
interactively you can use the universal prefix argument to get a
prompt where you can choose a different name, and the suggested
name is available as the default value.

If you want to always rename info, eww, help or occur buffers without
manual intervention, use:

#+begin_src emacs-lisp
(add-hook 'Info-selection-hook #'epithet-rename-buffer)
(add-hook 'eww-after-render-hook #'epithet-rename-buffer)
(add-hook 'help-mode-hook #'epithet-rename-buffer)
(add-hook 'occur-hook #'epithet-rename-buffer) ; not occur-mode-hook
(add-hook 'shell-mode-hook #'epithet-rename-buffer)
(add-hook 'compilation-start-hook #'epithet-rename-buffer-ignoring-arguments)
(add-hook 'compilation-finish-functions #'epithet-rename-buffer-ignoring-arguments)
#+end_src

Due to a quirk in =describe-bindings=, even though it produces a help
mode buffer, having =epithet-rename-buffer= in the =help-mode-hook= will
not rename the buffer it creates. If you want those buffers renamed
automatically too, you should also add this to your configuration:

#+begin_src emacs-lisp
(defun rename-describe-bindings (&rest _)
(with-current-buffer (help-buffer)
(epithet-rename-buffer)))

(advice-add 'describe-bindings :after #'rename-describe-bindings)
#+end_src