unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch: perform autoloading when docs is missing from autoload object
@ 2021-09-15 13:51 Arthur Miller
  2021-09-15 18:14 ` Stefan Monnier
  2021-09-16 12:51 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 23+ messages in thread
From: Arthur Miller @ 2021-09-15 13:51 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1389 bytes --]

I would like help functions to autoload files when help on symbols is
requestd. Built-in help do that only in limited cases, while helpful dutifully
loads libraries when symbol is not loaded. I would actually prefer to just load
documentation not the entire library, and I think I can do that, but it is a
little bit more involved (have to find source and read the docs), unlike just
performing autoloading.

About the patch: there is already an help-enable-autoload option for built-in
help, probably meant to do exactly what I want, but it is much more savvy what
it loads (only kemaps I think?).

I have introduced new variable, help-enable-symbol-autoload, and more aggressive
autoloading will be performed only when this one is set to 't, so it is an
opt-in option. I would gladly skip that extra variable and use original one, but
that would turn it into opt-out option which might not be desired by everyone.

I am not sure if understand exact usage of built-in help functions, but the
main entry should be describe-* functions, and this should only affect those? I
am little bit unsecure here.

I have two versions, I prefer the first, help-fns.el only one, but as said,
I am a bit unsure how help functions are used, so I have attached an alternative
too. To note: this is only for functions, I am not sure if it is needed for
variables?

It is just a proposal.

Best regards
/a


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-only-help-fns.patch --]
[-- Type: text/x-patch, Size: 1351 bytes --]

From 45e387e15166c5194fe4b78ec01bb65f0db9bcb4 Mon Sep 17 00:00:00 2001
From: Arthur Miller <arthur.miller@live.com>
Date: Wed, 15 Sep 2021 15:15:30 +0200
Subject: [PATCH] Do autoload if docs are not present in autoloads

* lisp/help-fns.el ('help-enable-symbol-autoload'): New option.
(help-fns--analyze-function): Perform autoloading when docs are
missing from autoload objects.
---
 lisp/help-fns.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index a7219ede94..575c69638d 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -132,6 +132,12 @@ help-enable-completion-autoload
   :group 'help
   :version "26.3")
 
+(defcustom help-enable-symbol-autoload nil
+  "Perform autoload if docs are missing from autoload objects."
+  :type 'boolean
+  :group 'help
+  :version "28.1")
+
 (defun help--symbol-class (s)
   "Return symbol class characters for symbol S."
   (when (stringp s)
@@ -823,6 +829,11 @@ help-fns--analyze-function
                        f))
 		    ((subrp def) (intern (subr-name def)))
                     (t def))))
+
+    (and (autoloadp real-def) (not (nth 2 real-def))
+         help-enable-symbol-autoload
+         (autoload-do-load real-def))
+
     (list real-function def aliased real-def)))
 
 (defun help-fns-function-description-header (function)
-- 
2.33.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-with-help.el.patch --]
[-- Type: text/x-patch, Size: 1788 bytes --]

From 1f6fd7ee99b3807e012d366d71679ae917cac096 Mon Sep 17 00:00:00 2001
From: Arthur Miller <arthur.miller@live.com>
Date: Wed, 15 Sep 2021 12:40:34 +0200
Subject: [PATCH] Load symbols when docs are not present in autoloads

* lisp/help-fns.el ('help-enable-symbol-autoload'): New option.
* lisp/help.el (help-function-arglist): Check if docs are present in
autoload object, and perform autoload if they are not.
---
 lisp/help-fns.el | 6 ++++++
 lisp/help.el     | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index a7219ede94..842bcb39fe 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -132,6 +132,12 @@ help-enable-completion-autoload
   :group 'help
   :version "26.3")
 
+(defcustom help-enable-symbol-autoload nil
+  "Perform autoload when documentation is not present in autoload object."
+  :type 'boolean
+  :group 'help
+  :version "28.1")
+
 (defun help--symbol-class (s)
   "Return symbol class characters for symbol S."
   (when (stringp s)
diff --git a/lisp/help.el b/lisp/help.el
index 29ae340481..9b6ae0c821 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1883,6 +1883,10 @@ help-function-arglist
   "Return a formal argument list for the function DEF.
 If PRESERVE-NAMES is non-nil, return a formal arglist that uses
 the same names as used in the original source code, when possible."
+  ;; Load docs for autoloads when doc is missing.
+  (if (and (autoloadp def) (not (nth 2 def)) help-enable-symbol-autoload
+           (not (and (nth 4 def) (eq (nth 4 def) 'keymap))))
+      (autoload-do-load def))
   ;; Handle symbols aliased to other symbols.
   (if (and (symbolp def) (fboundp def)) (setq def (indirect-function def)))
   ;; Advice wrappers have "catch all" args, so fetch the actual underlying
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-09-22 16:18 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15 13:51 Patch: perform autoloading when docs is missing from autoload object Arthur Miller
2021-09-15 18:14 ` Stefan Monnier
2021-09-15 22:29   ` Arthur Miller
2021-09-17 16:38     ` Stefan Monnier
2021-09-17 16:56       ` Generic autoloading? [Was Patch: perform autoloading when docs is missing from autoload object] Qiantan Hong
2021-09-17 19:36         ` Stefan Monnier
2021-09-17 19:51           ` Qiantan Hong
2021-09-17 21:25         ` Arthur Miller
2021-09-17 21:09       ` Patch: perform autoloading when docs is missing from autoload object Arthur Miller
2021-09-18 13:37         ` Stefan Monnier
2021-09-18 18:25           ` Arthur Miller
2021-09-20 17:02             ` Stefan Monnier
2021-09-22 16:18               ` Arthur Miller
2021-09-16 12:51 ` Lars Ingebrigtsen
2021-09-17  6:49   ` Arthur Miller
2021-09-17 14:01     ` Lars Ingebrigtsen
2021-09-17 15:04       ` Arthur Miller
2021-09-18 13:21         ` Lars Ingebrigtsen
2021-09-18 16:03           ` [External] : " Drew Adams
2021-09-18 17:34             ` Arthur Miller
2021-09-18 17:31           ` Arthur Miller
2021-09-18 17:53             ` Lars Ingebrigtsen
2021-09-18 18:38               ` Arthur Miller

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).