[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion: Let the help command load autoloaded functions etc

From: Lennart Borgman (gmail)
Subject: Re: Suggestion: Let the help command load autoloaded functions etc
Date: Wed, 16 Jul 2008 23:11:11 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

David Kastrup wrote:
"Stephen J. Turnbull" <address@hidden> writes:

Lennart Borgman writes:

 > > > I think that will be too long. How about this:
 > > >
 > > >   [To see Arg list, _click for loading library above_]
 > >
 > I think "_click for loading library_" is my favorite.

The file name probably has the full path, which is indeed too long.

I don't see why it should have the full path.  The autoload cookies
don't usually have this info in them, so there is no point in deriving
and displaying it before the time of the load.

I don't volunteer to do the work, but how about

    [To see Arg list, _click for loading LIBNAME_]

where LIBNAME is the library name (ie, basename without .el), and add
a tooltip with the full file name.

By the way, the English usage can be improved.  Here are some

_Show Arg list_ (loads LIBNAME).

I think in the context of the arg list, I find this text the most
straightforward suggestion yet.  It has a link for the point of interest
and mentions the side effect as a side effect.

To show Arg list, _click to load LIBNAME_.

Clearly inferior.  The other proposal is much more of an improvement
over my suggestion.

Thanks David and Stephen. I have attached a patch similar to Stephen's suggestion, but a little bit more verbose.

If this looks good then please install it.
Index: help-fns.el
RCS file: /sources/emacs/emacs/lisp/help-fns.el,v
retrieving revision 1.122
diff -u -r1.122 help-fns.el
--- help-fns.el 6 Jun 2008 20:02:42 -0000       1.122
+++ help-fns.el 16 Jul 2008 21:07:29 -0000
@@ -104,7 +104,7 @@
    ((byte-code-function-p def) (aref def 0))
    ((eq (car-safe def) 'lambda) (nth 1 def))
    ((and (eq (car-safe def) 'autoload) (not (eq (nth 4 def) 'keymap)))
-    "[Arg list not available until function definition is loaded.]")
+    "[Show arg list and full help (loads library LIBNAME).]")
    (t t)))
 (defun help-make-usage (function arglist)
@@ -417,7 +417,25 @@
                  (high (help-highlight-arguments use doc)))
             (let ((fill-begin (point)))
              (insert (car high) "\n")
-             (fill-region fill-begin (point)))
+             (fill-region fill-begin (point))
+              ;; Add load link for autoloaded functions.
+              (let ((here (point-marker))
+                    (load-marker
+                     (concat "\\(Show arg list and full help\\) "
+                             "(loads library \\(LIBNAME\\))\.")))
+                (goto-char fill-begin)
+                (save-match-data
+                  (when (re-search-forward load-marker here t)
+                    (make-text-button (match-beginning 1)
+                                      (match-end 1)
+                                      'action `(lambda (btn) (interactive)
+                                                 (load-library ,file-name)
+                                                 (describe-function 
+                    (replace-match
+                     (file-name-sans-extension
+                      (file-name-nondirectory file-name))
+                     t t nil 2)))
+                (goto-char here)))
             (setq doc (cdr high))))
         (let* ((obsolete (and
                          ;; function might be a lambda construct.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]