Skip to content

Commit 9d0707c

Browse files
committed
Add support for describe-bindings (fixes #3)
1 parent 0953758 commit 9d0707c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

README.org

+13
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,16 @@ manual intervention, use:
3737
(add-hook 'compilation-start-hook #'epithet-rename-buffer-ignoring-arguments)
3838
(add-hook 'compilation-finish-functions #'epithet-rename-buffer-ignoring-arguments)
3939
#+end_src
40+
41+
Due to a quirk in =describe-bindings=, even though it produces a help
42+
mode buffer, having =epithet-rename-buffer= in the =help-mode-hook= will
43+
not rename the buffer it creates. If you want those buffers renamed
44+
automatically too, you should also add this to your configuration:
45+
46+
#+begin_src emacs-lisp
47+
(defun rename-describe-bindings (&rest _)
48+
(with-current-buffer (help-buffer)
49+
(epithet-rename-buffer)))
50+
51+
(advice-add 'describe-bindings :after #'rename-describe-bindings)
52+
#+end_src

epithet.el

+8-3
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,15 @@
6464

6565
(defun epithet-for-help ()
6666
"Suggest a name for a `help-mode' buffer."
67-
(when (and (derived-mode-p 'help-mode) (equal (buffer-name) "*Help*"))
67+
(when (and (derived-mode-p 'help-mode)
68+
(equal (buffer-name) "*Help*")
69+
(not (and (eq (car help-xref-stack-item) 'describe-bindings)
70+
(= (buffer-size) 0))))
6871
(format "*Help: %s*" (pcase help-xref-stack-item
69-
(`(describe-bindings nil ,buffer)
70-
(format "describe-bindings for %s" (with-current-buffer buffer major-mode)))
72+
((or `(,(and fn 'describe-bindings) ,_ ,buffer)
73+
`(,(and fn 'describe-mode) ,buffer))
74+
(format "%s for %s"
75+
fn (buffer-local-value 'major-mode buffer)))
7176
(`(,_ ,name ,_) name)))))
7277

7378
(defun epithet-for-occur ()

0 commit comments

Comments
 (0)