comparison lisp/help.el @ 4695:fee33ab25966

Add arglist info for autoloaded functions and macros. lisp/ChangeLog addition: 2009-09-20 Aidan Kehoe <kehoea@parhasard.net> Add arglist information to docstrings for autoloaded functions and macros. * hyper-apropos.el (hyper-apropos-get-doc): Treat autoload docstrings like subr docstrings; correct the regexp used. * help.el (describe-function-show-arglist): This no longer treats autoloads specially. (function-arglist): Treat autoload docstrings like subr docstrings. (function-documentation): Treat documentation strings that are zero-length after the arglist has been removed as indicating a lack of documentation. * cl-macs.el (case): (ecase): (typecase): (etypecase): (block): (return): (return-from): (progv): (lexical-let): (lexical-let*): (remf): (callf): (callf2): (define-modify-macro): (deftype): (define-compiler-macro): Rely on the autoload code to always show an arglist for these functions, don't supply an ad-hoc one in the docstring. These changes are for the most obvious functions; there are some missed that would require changing argument names in the docstring or in the function bodies. * autoload.el (make-autoload): Add arg list information to the doc string, using the same approach as for subrs.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 20 Sep 2009 23:50:05 +0100
parents 2ac296807b88
children 755ae5b97edb
comparison
equal deleted inserted replaced
4694:2ac296807b88 4695:fee33ab25966
1085 (function-at-point)))) 1085 (function-at-point))))
1086 1086
1087 ;; Default to nil for the non-hackers? Not until we find a way to 1087 ;; Default to nil for the non-hackers? Not until we find a way to
1088 ;; distinguish hackers from non-hackers automatically! 1088 ;; distinguish hackers from non-hackers automatically!
1089 (defcustom describe-function-show-arglist t 1089 (defcustom describe-function-show-arglist t
1090 "*If non-nil, describe-function will show its arglist, 1090 "*If non-nil, describe-function will show the function's arglist."
1091 unless the function is autoloaded."
1092 :type 'boolean 1091 :type 'boolean
1093 :group 'help-appearance) 1092 :group 'help-appearance)
1094 1093
1095 (define-obsolete-function-alias 1094 (define-obsolete-function-alias
1096 ;; Moved to using the version in loadhist.el 1095 ;; Moved to using the version in loadhist.el
1186 (arglist 1185 (arglist
1187 (cond ((compiled-function-p fndef) 1186 (cond ((compiled-function-p fndef)
1188 (compiled-function-arglist fndef)) 1187 (compiled-function-arglist fndef))
1189 ((eq (car-safe fndef) 'lambda) 1188 ((eq (car-safe fndef) 'lambda)
1190 (nth 1 fndef)) 1189 (nth 1 fndef))
1191 ((subrp fndef) 1190 ((or (subrp fndef) (eq 'autoload (car-safe fndef)))
1192 (let* ((doc (documentation function)) 1191 (let* ((doc (documentation function))
1193 (args (and doc 1192 (args (and doc
1194 (string-match 1193 (string-match
1195 "[\n\t ]*\narguments: ?(\\([^)]*\\))\n?\\'" 1194 "[\n\t ]*\narguments: ?(\\([^)]*\\))\n?\\'"
1196 doc) 1195 doc)
1225 (let ((doc (condition-case nil 1224 (let ((doc (condition-case nil
1226 (or (documentation function) 1225 (or (documentation function)
1227 (gettext "not documented")) 1226 (gettext "not documented"))
1228 (void-function "(alias for undefined function)") 1227 (void-function "(alias for undefined function)")
1229 (error "(unexpected error from `documention')")))) 1228 (error "(unexpected error from `documention')"))))
1230 (if (and strip-arglist 1229 (when (and strip-arglist
1231 (string-match "[\n\t ]*\narguments: ?(\\([^)]*\\))\n?\\'" doc)) 1230 (string-match "[\n\t ]*\narguments: ?(\\([^)]*\\))\n?\\'" doc))
1232 (setq doc (substring doc 0 (match-beginning 0)))) 1231 (setq doc (substring doc 0 (match-beginning 0)))
1232 (and (zerop (length doc)) (setq doc (gettext "not documented"))))
1233 doc)) 1233 doc))
1234 1234
1235 ;; replacement for `princ' that puts the text in the specified face, 1235 ;; replacement for `princ' that puts the text in the specified face,
1236 ;; if possible 1236 ;; if possible
1237 (defun Help-princ-face (object face) 1237 (defun Help-princ-face (object face)