diff options
| author | Stefan Monnier | 2022-01-31 11:07:06 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2022-01-31 11:07:26 -0500 |
| commit | 1d1b664fbb9232aa40d8daa54a689cfd63d38aa9 (patch) | |
| tree | 164ad10242c8566c3c8fa1d0c12c50804f82d791 /src/eval.c | |
| parent | 90bbf27f02b1e7bf9cc0f0206313795c210c565b (diff) | |
| download | emacs-1d1b664fbb9232aa40d8daa54a689cfd63d38aa9.tar.gz emacs-1d1b664fbb9232aa40d8daa54a689cfd63d38aa9.zip | |
(function-history): New symbol property (bug#53632)
Rework the code we have in Fdefalias that tries to keep track
of definitions so as to be able to undo them later.
We used to store in `load-history` when an autoload is redefined as
a non-autoload and in the `autoload` symbol property we used to store
the autoload data that used to be used before it got overriden.
Instead, store the history of the function definition of
a symbol in its `function-history` symbol property.
To make this list cheap in the default case, the latest value is not stored
in the list (since it's in the `symbol-function`) and neither is the first
file. So if there's only been a single definition (the most common case),
the list is empty and the property is just not present at all.
The patch also gets rid of the `autoload` vs `defun` distinction in
`load-history` which seems unnecessary (a significant part of the
motivation for this patch was to get rid of the special handling of
autoloads in this part of the code).
* src/data.c (add_to_function_history): New function.
(defalias): Use it. Don't add the `t` entries for autoloads and always
use `defun` regardless of the kind of definition.
Change `Vautoload_queue` to only hold the function
symbols since the rest is now available from `function-history`.
* src/eval.c (un_autoload): Adjust accordingly.
* src/lread.c (load-history): Udate docstring.
* lisp/loadhist.el (loadhist-unload-filename): New var.
(unload-feature): Bind it.
(loadhist-unload-element): Document its availability.
(loadhist--restore-autoload): Delete var.
(loadhist--unload-function): Delete function.
(loadhist-unload-element): Delete the `t` and `autoload` methods.
Rewrite the `defun` method using `function-history`.
* lisp/help-fns.el: Require `seq`.
(help-fns--autoloaded-p): Rewrite.
(help-fns-function-description-header): Adjust call accordingly.
* doc/lispref/loading.texi (Where Defined): Remove `autoload` and `t`
entries from `load-history` since we don't generate them any more.
Document the `function-history` which replaces the `autoload` property.
(Unloading): Adjust symbol property name accordingly.
* test/lisp/loadhist-resources/loadhist--bar.el:
* test/lisp/loadhist-resources/loadhist--foo.el: New files.
* test/lisp/loadhist-tests.el (loadhist-tests-unload-feature-nested)
(loadhist-tests-unload-feature-notnested): New tests.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/eval.c b/src/eval.c index b083a00a791..1076985d097 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -2250,21 +2250,17 @@ this does nothing and returns nil. */) | |||
| 2250 | static void | 2250 | static void |
| 2251 | un_autoload (Lisp_Object oldqueue) | 2251 | un_autoload (Lisp_Object oldqueue) |
| 2252 | { | 2252 | { |
| 2253 | Lisp_Object queue, first, second; | ||
| 2254 | |||
| 2255 | /* Queue to unwind is current value of Vautoload_queue. | 2253 | /* Queue to unwind is current value of Vautoload_queue. |
| 2256 | oldqueue is the shadowed value to leave in Vautoload_queue. */ | 2254 | oldqueue is the shadowed value to leave in Vautoload_queue. */ |
| 2257 | queue = Vautoload_queue; | 2255 | Lisp_Object queue = Vautoload_queue; |
| 2258 | Vautoload_queue = oldqueue; | 2256 | Vautoload_queue = oldqueue; |
| 2259 | while (CONSP (queue)) | 2257 | while (CONSP (queue)) |
| 2260 | { | 2258 | { |
| 2261 | first = XCAR (queue); | 2259 | Lisp_Object first = XCAR (queue); |
| 2262 | second = Fcdr (first); | 2260 | if (CONSP (first) && EQ (XCAR (first), make_fixnum (0))) |
| 2263 | first = Fcar (first); | 2261 | Vfeatures = XCDR (first); |
| 2264 | if (EQ (first, make_fixnum (0))) | ||
| 2265 | Vfeatures = second; | ||
| 2266 | else | 2262 | else |
| 2267 | Ffset (first, second); | 2263 | Ffset (first, Fcar (Fcdr (Fget (first, Qfunction_history)))); |
| 2268 | queue = XCDR (queue); | 2264 | queue = XCDR (queue); |
| 2269 | } | 2265 | } |
| 2270 | } | 2266 | } |