]> git.eshelyaron.com Git - emacs.git/commitdiff
(help-with-tutorial): Use minibuffer-completion-help.
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 27 Sep 2002 22:59:41 +0000 (22:59 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 27 Sep 2002 22:59:41 +0000 (22:59 +0000)
(help-split-fundoc): Don't support old syntax any more.
(help-add-fundoc-usage): New fun.

lisp/help-fns.el

index 8f5510c01a98bb8b90653869cb3fd3cba820351b..245bbd0e8d01dcd6cd5ea9c505efdedaac54e0c8 100644 (file)
 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.