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")))
;; 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.