summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2002-09-27 22:59:41 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2002-09-27 22:59:41 +0000
commitbbb7041afb98ae8361992177d451eb714d9c163a (patch)
tree400600a58f0c07f6af9afa08ec376a74eb585bb6 /lisp
parentabfb2fe607a22b4b5964191185bc2f84c578e69b (diff)
downloademacs-bbb7041afb98ae8361992177d451eb714d9c163a.tar.gz
(help-with-tutorial): Use minibuffer-completion-help.
(help-split-fundoc): Don't support old syntax any more. (help-add-fundoc-usage): New fun.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/help-fns.el54
1 files changed, 22 insertions, 32 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 8f5510c01a9..245bbd0e8d0 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -42,30 +42,13 @@
If there is a tutorial version written in the language
of the selected language environment, that version is used.
If there's no tutorial in that language, `TUTORIAL' is selected.
-With arg, you are asked to choose which language."
+With ARG, you are asked to choose which language."
(interactive "P")
(let ((lang (if arg
- (let (completion-buffer)
- ;; Display a completion list right away
- ;; to guide the user.
- (with-output-to-temp-buffer "*Completions*"
- (display-completion-list
- (all-completions "" language-info-alist
- (lambda (elm)
- (and (listp elm) (assq 'tutorial elm)))))
- (setq completion-buffer standard-output))
- ;; Arrange to set completion-reference-buffer
- ;; in *Completions* to point to the minibuffer,
- ;; after entering the minibuffer.
(let ((minibuffer-setup-hook minibuffer-setup-hook))
(add-hook 'minibuffer-setup-hook
- (lambda ()
- (let ((mini (current-buffer)))
- (with-current-buffer completion-buffer
- (make-local-variable 'completion-reference-buffer)
- (setq completion-reference-buffer
- mini)))))
- (read-language-name 'tutorial "Language: " "English")))
+ 'minibuffer-completion-help)
+ (read-language-name 'tutorial "Language: " "English"))
(if (get-language-info current-language-environment 'tutorial)
current-language-environment
"English")))
@@ -182,18 +165,25 @@ DEF is the function whose usage we're looking for in DOC."
;; In cases where `function' has been fset to a subr we can't search for
;; function's name in the doc string so we use `fn' as the anonymous
;; function name instead.
- (when doc
- (let* ((rep (prin1-to-string (indirect-function def)))
- (name (if (string-match " \\([^ ]+\\)>$" rep)
- (match-string 1 rep) (prin1-to-string def))))
- (if (string-match (format "\n\n(\\(fn\\|%s\\)\\(\\( .*\\)?)\\)\\'"
- (regexp-quote name))
- doc)
- (cons (format "(%s%s"
- ;; Replace `fn' with the actual function name.
- (if (consp def) "anonymous" def)
- (match-string 2 doc))
- (substring doc 0 (match-beginning 0)))))))
+ (when (and doc (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc))
+ (cons (format "(%s%s"
+ ;; Replace `fn' with the actual function name.
+ (if (consp def) "anonymous" def)
+ (match-string 1 doc))
+ (substring doc 0 (match-beginning 0)))))
+
+(defun help-add-fundoc-usage (doc arglist)
+ "Add the usage info to the docstring DOC.
+If DOC already has a usage info, then just return DOC unchanged.
+The usage info is built from ARGLIST. DOC can be nil."
+ (unless (stringp doc) (setq doc "Not documented"))
+ (if (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc)
+ doc
+ (format "%s%s%s" doc
+ (if (string-match "\n?\n\\'" doc)
+ (if (< (- (match-end 0) (match-beginning 0)) 2) "\n")
+ "\n\n")
+ (help-make-usage 'fn arglist))))
(defun help-function-arglist (def)
;; Handle symbols aliased to other symbols.