Mercurial > emacs
comparison lisp/help-fns.el @ 50799:80f5ff945c90
(help-add-fundoc-usage): Allow arglist to be a string.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 04 May 2003 00:30:34 +0000 |
parents | 4975a5944969 |
children | e19ad6e42e63 |
comparison
equal
deleted
inserted
replaced
50798:2d72cdb7e9f8 | 50799:80f5ff945c90 |
---|---|
173 (substring doc 0 (match-beginning 0))))) | 173 (substring doc 0 (match-beginning 0))))) |
174 | 174 |
175 (defun help-add-fundoc-usage (doc arglist) | 175 (defun help-add-fundoc-usage (doc arglist) |
176 "Add the usage info to the docstring DOC. | 176 "Add the usage info to the docstring DOC. |
177 If DOC already has a usage info, then just return DOC unchanged. | 177 If DOC already has a usage info, then just return DOC unchanged. |
178 The usage info is built from ARGLIST. DOC can be nil." | 178 The usage info is built from ARGLIST. DOC can be nil. |
179 ARGLIST can also be nil or a string of the form \"(fun ARG1 ARG2 ...)\"." | |
179 (unless (stringp doc) (setq doc "Not documented")) | 180 (unless (stringp doc) (setq doc "Not documented")) |
180 (if (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc) | 181 (if (or (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc) (not arglist)) |
181 doc | 182 doc |
182 (format "%s%s%s" doc | 183 (format "%s%s%s" doc |
183 (if (string-match "\n?\n\\'" doc) | 184 (if (string-match "\n?\n\\'" doc) |
184 (if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "") | 185 (if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "") |
185 "\n\n") | 186 "\n\n") |
186 (help-make-usage 'fn arglist)))) | 187 (if (and (stringp arglist) |
188 (string-match "\\`([^ ]+\\(.*\\))\\'" arglist)) | |
189 (concat "(fn" (match-string 1 arglist) ")") | |
190 (help-make-usage 'fn arglist))))) | |
187 | 191 |
188 (defun help-function-arglist (def) | 192 (defun help-function-arglist (def) |
189 ;; Handle symbols aliased to other symbols. | 193 ;; Handle symbols aliased to other symbols. |
190 (if (and (symbolp def) (fboundp def)) (setq def (indirect-function def))) | 194 (if (and (symbolp def) (fboundp def)) (setq def (indirect-function def))) |
191 ;; If definition is a macro, find the function inside it. | 195 ;; If definition is a macro, find the function inside it. |