aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2024-03-21 21:08:58 -0400
committerStefan Monnier2024-03-22 08:47:13 -0400
commitaccd79c93935b50dddfcd6fe7fb6912c80bcddb1 (patch)
tree37e71ac3698f7f0f658848f1626bfcb25e6725fd
parentc1530a2e4973005633ebe00d447f1f3aa1200301 (diff)
downloademacs-accd79c93935b50dddfcd6fe7fb6912c80bcddb1.tar.gz
emacs-accd79c93935b50dddfcd6fe7fb6912c80bcddb1.zip
(help-fns-function-description-header): Print functions' type
Instead of choosing English words to describe the kind of function, use the actual type of the function object (from `cl-type-of`) directly, and make it a button to display info about that type. * lisp/help-fns.el (help-fns-function-description-header): Use the function's type name in the description instead of "prose". Use `insert` instead of `princ`, so as to preserve the text-properties of the button. * lisp/emacs-lisp/cl-extra.el (cl-help-type): Move to `help-mode.el` and rename to `help-type`. (cl--describe-class): Adjust accordingly. * lisp/help-mode.el (help-type): New type, moved and renamed from `cl-extra.el`.
-rw-r--r--lisp/emacs-lisp/cl-extra.el11
-rw-r--r--lisp/help-fns.el31
-rw-r--r--lisp/help-mode.el5
3 files changed, 22 insertions, 25 deletions
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index d43c21d3eb9..437dea2d6a9 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -720,11 +720,6 @@ PROPLIST is a list of the sort returned by `symbol-plist'.
720 (add-to-list 'find-function-regexp-alist 720 (add-to-list 'find-function-regexp-alist
721 '(define-type . cl--typedef-regexp))) 721 '(define-type . cl--typedef-regexp)))
722 722
723(define-button-type 'cl-help-type
724 :supertype 'help-function-def
725 'help-function #'cl-describe-type
726 'help-echo (purecopy "mouse-2, RET: describe this type"))
727
728(define-button-type 'cl-type-definition 723(define-button-type 'cl-type-definition
729 :supertype 'help-function-def 724 :supertype 'help-function-def
730 'help-echo (purecopy "mouse-2, RET: find type definition")) 725 'help-echo (purecopy "mouse-2, RET: find type definition"))
@@ -777,7 +772,7 @@ Call `cl--find-class' to get TYPE's propname `cl--class'"
777 (insert (symbol-name type) 772 (insert (symbol-name type)
778 (substitute-command-keys " is a type (of kind `")) 773 (substitute-command-keys " is a type (of kind `"))
779 (help-insert-xref-button (symbol-name metatype) 774 (help-insert-xref-button (symbol-name metatype)
780 'cl-help-type metatype) 775 'help-type metatype)
781 (insert (substitute-command-keys "')")) 776 (insert (substitute-command-keys "')"))
782 (when location 777 (when location
783 (insert (substitute-command-keys " in `")) 778 (insert (substitute-command-keys " in `"))
@@ -796,7 +791,7 @@ Call `cl--find-class' to get TYPE's propname `cl--class'"
796 (setq cur (cl--class-name cur)) 791 (setq cur (cl--class-name cur))
797 (insert (substitute-quotes "`")) 792 (insert (substitute-quotes "`"))
798 (help-insert-xref-button (symbol-name cur) 793 (help-insert-xref-button (symbol-name cur)
799 'cl-help-type cur) 794 'help-type cur)
800 (insert (substitute-command-keys (if pl "', " "'")))) 795 (insert (substitute-command-keys (if pl "', " "'"))))
801 (insert ".\n"))) 796 (insert ".\n")))
802 797
@@ -808,7 +803,7 @@ Call `cl--find-class' to get TYPE's propname `cl--class'"
808 (while (setq cur (pop ch)) 803 (while (setq cur (pop ch))
809 (insert (substitute-quotes "`")) 804 (insert (substitute-quotes "`"))
810 (help-insert-xref-button (symbol-name cur) 805 (help-insert-xref-button (symbol-name cur)
811 'cl-help-type cur) 806 'help-type cur)
812 (insert (substitute-command-keys (if ch "', " "'")))) 807 (insert (substitute-command-keys (if ch "', " "'"))))
813 (insert ".\n"))) 808 (insert ".\n")))
814 809
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 638af81ded8..a291893e9a2 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1061,10 +1061,10 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
1061 (concat 1061 (concat
1062 "an autoloaded " (if (commandp def) 1062 "an autoloaded " (if (commandp def)
1063 "interactive ")) 1063 "interactive "))
1064 (if (commandp def) "an interactive " "a ")))) 1064 (if (commandp def) "an interactive " "a ")))
1065 1065 ;; Print what kind of function-like object FUNCTION is.
1066 ;; Print what kind of function-like object FUNCTION is. 1066 (description
1067 (princ (cond ((or (stringp def) (vectorp def)) 1067 (cond ((or (stringp def) (vectorp def))
1068 "a keyboard macro") 1068 "a keyboard macro")
1069 ((and (symbolp function) 1069 ((and (symbolp function)
1070 (get function 'reader-construct)) 1070 (get function 'reader-construct))
@@ -1073,12 +1073,6 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
1073 ;; aliases before functions. 1073 ;; aliases before functions.
1074 (aliased 1074 (aliased
1075 (format-message "an alias for `%s'" real-def)) 1075 (format-message "an alias for `%s'" real-def))
1076 ((subr-native-elisp-p def)
1077 (concat beg "native-compiled Lisp function"))
1078 ((subrp def)
1079 (concat beg (if (eq 'unevalled (cdr (subr-arity def)))
1080 "special form"
1081 "built-in function")))
1082 ((autoloadp def) 1076 ((autoloadp def)
1083 (format "an autoloaded %s" 1077 (format "an autoloaded %s"
1084 (cond 1078 (cond
@@ -1092,12 +1086,13 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
1092 ;; need to check macros before functions. 1086 ;; need to check macros before functions.
1093 (macrop function)) 1087 (macrop function))
1094 (concat beg "Lisp macro")) 1088 (concat beg "Lisp macro"))
1095 ((byte-code-function-p def) 1089 ((atom def)
1096 (concat beg "byte-compiled Lisp function")) 1090 (let ((type (or (oclosure-type def) (cl-type-of def))))
1097 ((module-function-p def) 1091 (concat beg (format "%s"
1098 (concat beg "module function")) 1092 (make-text-button
1099 ((memq (car-safe def) '(lambda closure)) 1093 (symbol-name type) nil
1100 (concat beg "Lisp function")) 1094 'type 'help-type
1095 'help-args (list type))))))
1101 ((keymapp def) 1096 ((keymapp def)
1102 (let ((is-full nil) 1097 (let ((is-full nil)
1103 (elts (cdr-safe def))) 1098 (elts (cdr-safe def)))
@@ -1107,7 +1102,9 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED REAL-DEF)."
1107 elts nil)) 1102 elts nil))
1108 (setq elts (cdr-safe elts))) 1103 (setq elts (cdr-safe elts)))
1109 (concat beg (if is-full "keymap" "sparse keymap")))) 1104 (concat beg (if is-full "keymap" "sparse keymap"))))
1110 (t ""))) 1105 (t ""))))
1106 (with-current-buffer standard-output
1107 (insert description))
1111 1108
1112 (if (and aliased (not (fboundp real-def))) 1109 (if (and aliased (not (fboundp real-def)))
1113 (princ ",\nwhich is not defined.") 1110 (princ ",\nwhich is not defined.")
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index dd78342ace7..48433d899ab 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -177,6 +177,11 @@ The format is (FUNCTION ARGS...).")
177 'help-function 'describe-variable 177 'help-function 'describe-variable
178 'help-echo (purecopy "mouse-2, RET: describe this variable")) 178 'help-echo (purecopy "mouse-2, RET: describe this variable"))
179 179
180(define-button-type 'help-type
181 :supertype 'help-xref
182 'help-function #'cl-describe-type
183 'help-echo (purecopy "mouse-2, RET: describe this type"))
184
180(define-button-type 'help-face 185(define-button-type 'help-face
181 :supertype 'help-xref 186 :supertype 'help-xref
182 'help-function 'describe-face 187 'help-function 'describe-face