]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `C-h m' list unbound commands applicable for the mode
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 14 Feb 2021 13:07:48 +0000 (14:07 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 14 Feb 2021 13:07:48 +0000 (14:07 +0100)
* lisp/help-fns.el (help-fns--list-local-commands): New function.
(describe-mode): Use it.

lisp/help-fns.el

index b03a440412968df5d1766f791ece64246be6593a..0e2c68292c62c1be8fcb0346e1024c13c771b54d 100644 (file)
@@ -1827,9 +1827,30 @@ documentation for the major and minor modes of that buffer."
                                     nil t)
                (help-xref-button 1 'help-function-def mode file-name)))))
        (princ ":\n")
-       (princ (help-split-fundoc (documentation major-mode) nil 'doc)))))
+       (princ (help-split-fundoc (documentation major-mode) nil 'doc))
+        (princ (help-fns--list-local-commands)))))
   ;; For the sake of IELM and maybe others
   nil)
+
+(defun help-fns--list-local-commands ()
+  (let ((functions nil))
+    (mapatoms
+     (lambda (sym)
+       (when (and (commandp sym)
+                  ;; Ignore aliases.
+                  (not (symbolp (symbol-function sym)))
+                  ;; Ignore everything bound.
+                  (not (where-is-internal sym))
+                  (apply #'derived-mode-p (command-modes sym)))
+         (push sym functions))))
+    (with-temp-buffer
+      (when functions
+        (setq functions (sort functions #'string<))
+        (insert "\n\nOther commands for this mode, not bound to any keys:\n\n")
+        (dolist (function functions)
+          (insert (format "`%s'\n" function))))
+      (buffer-string))))
+
 \f
 ;; Widgets.