* src/data.c (defalias): New function, extracted from `Fdefalias`.
(Fdefalias): Use it.
(Ffset): Don't handle `Vautoload_queue` here, handle it in
`defalias` instead.
* src/comp.c (comp--register-subr): Use `defalias` instead of
duplicating its code.
* src/eval.c (load_with_autoload_queue): New function, extracted from
`Fautoload_do_load`.
(Fautoload_do_load): Use it.
(un_autoload): Mark it as static.
* src/fns.c (Frequire): Use it as well.
* src/lisp.h (defalias, load_with_autoload_queue): New declarations.
(un_autoload): Remove declaration.
;;; cl-preloaded.el --- Preloaded part of the CL library -*- lexical-binding: t; -*-
-;; Copyright (C) 2015-2021 Free Software Foundation, Inc
+;; Copyright (C) 2015-2022 Free Software Foundation, Inc
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Package: emacs
make_subr (SYMBOL_NAME (name), minarg, maxarg, c_name, type, doc_idx,
intspec, comp_u);
- if (AUTOLOADP (XSYMBOL (name)->u.s.function))
- /* Remember that the function was already an autoload. */
- LOADHIST_ATTACH (Fcons (Qt, name));
- LOADHIST_ATTACH (Fcons (Qdefun, name));
-
- { /* Handle automatic advice activation (bug#42038).
- See `defalias'. */
- Lisp_Object hook = Fget (name, Qdefalias_fset_function);
- if (!NILP (hook))
- call2 (hook, name, tem);
- else
- Ffset (name, tem);
- }
+ defalias (name, tem);
return tem;
}
function = XSYMBOL (symbol)->u.s.function;
- if (!NILP (Vautoload_queue) && !NILP (function))
- Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
-
if (AUTOLOADP (function))
Fput (symbol, Qautoload, XCDR (function));
return definition;
}
-DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0,
- doc: /* Set SYMBOL's function definition to DEFINITION.
-Associates the function with the current load file, if any.
-The optional third argument DOCSTRING specifies the documentation string
-for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string
-determined by DEFINITION.
-
-Internally, this normally uses `fset', but if SYMBOL has a
-`defalias-fset-function' property, the associated value is used instead.
-
-The return value is undefined. */)
- (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring)
+void
+defalias (Lisp_Object symbol, Lisp_Object definition)
{
- CHECK_SYMBOL (symbol);
- if (!NILP (Vpurify_flag)
- /* If `definition' is a keymap, immutable (and copying) is wrong. */
- && !KEYMAPP (definition))
- definition = Fpurecopy (definition);
-
{
bool autoload = AUTOLOADP (definition);
if (!will_dump_p () || !autoload)
{ /* Only add autoload entries after dumping, because the ones before are
not useful and else we get loads of them from the loaddefs.el. */
+ Lisp_Object function = XSYMBOL (symbol)->u.s.function;
- if (AUTOLOADP (XSYMBOL (symbol)->u.s.function))
+ if (AUTOLOADP (function))
/* Remember that the function was already an autoload. */
LOADHIST_ATTACH (Fcons (Qt, symbol));
LOADHIST_ATTACH (Fcons (autoload ? Qautoload : Qdefun, symbol));
+
+ if (!NILP (Vautoload_queue) && !NILP (function))
+ Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
}
}
else
Ffset (symbol, definition);
}
+}
+
+DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0,
+ doc: /* Set SYMBOL's function definition to DEFINITION.
+Associates the function with the current load file, if any.
+The optional third argument DOCSTRING specifies the documentation string
+for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string
+determined by DEFINITION.
+
+Internally, this normally uses `fset', but if SYMBOL has a
+`defalias-fset-function' property, the associated value is used instead.
+
+The return value is undefined. */)
+ (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring)
+{
+ CHECK_SYMBOL (symbol);
+ if (!NILP (Vpurify_flag)
+ /* If `definition' is a keymap, immutable (and copying) is wrong. */
+ && !KEYMAPP (definition))
+ definition = Fpurecopy (definition);
+
+ defalias (symbol, definition);
maybe_defer_native_compilation (symbol, definition);
Qnil);
}
-void
+static void
un_autoload (Lisp_Object oldqueue)
{
Lisp_Object queue, first, second;
}
}
+Lisp_Object
+load_with_autoload_queue
+ (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage,
+ Lisp_Object nosuffix, Lisp_Object must_suffix)
+{
+ ptrdiff_t count = SPECPDL_INDEX ();
+
+ /* If autoloading gets an error (which includes the error of failing
+ to define the function being called), we use Vautoload_queue
+ to undo function definitions and `provide' calls made by
+ the function. We do this in the specific case of autoloading
+ because autoloading is not an explicit request "load this file",
+ but rather a request to "call this function".
+
+ The value saved here is to be restored into Vautoload_queue. */
+ record_unwind_protect (un_autoload, Vautoload_queue);
+ Vautoload_queue = Qt;
+ Lisp_Object tem
+ = save_match_data_load (file, noerror, nomessage, nosuffix, must_suffix);
+
+ /* Once loading finishes, don't undo it. */
+ Vautoload_queue = Qt;
+ unbind_to (count, Qnil);
+ return tem;
+}
+
/* Load an autoloaded function.
FUNNAME is the symbol which is the function's name.
FUNDEF is the autoload definition (a list). */
it defines a macro. */)
(Lisp_Object fundef, Lisp_Object funname, Lisp_Object macro_only)
{
- ptrdiff_t count = SPECPDL_INDEX ();
-
if (!CONSP (fundef) || !EQ (Qautoload, XCAR (fundef)))
return fundef;
CHECK_SYMBOL (funname);
- /* If autoloading gets an error (which includes the error of failing
- to define the function being called), we use Vautoload_queue
- to undo function definitions and `provide' calls made by
- the function. We do this in the specific case of autoloading
- because autoloading is not an explicit request "load this file",
- but rather a request to "call this function".
-
- The value saved here is to be restored into Vautoload_queue. */
- record_unwind_protect (un_autoload, Vautoload_queue);
- Vautoload_queue = Qt;
/* If `macro_only' is set and fundef isn't a macro, assume this autoload to
be a "best-effort" (e.g. to try and find a compiler macro),
so don't signal an error if autoloading fails. */
Lisp_Object ignore_errors
= (EQ (kind, Qt) || EQ (kind, Qmacro)) ? Qnil : macro_only;
- save_match_data_load (Fcar (Fcdr (fundef)), ignore_errors, Qt, Qnil, Qt);
-
- /* Once loading finishes, don't undo it. */
- Vautoload_queue = Qt;
- unbind_to (count, Qnil);
+ load_with_autoload_queue (Fcar (Fcdr (fundef)), ignore_errors, Qt, Qnil, Qt);
if (NILP (funname) || !NILP (ignore_errors))
return Qnil;
record_unwind_protect (require_unwind, require_nesting_list);
require_nesting_list = Fcons (feature, require_nesting_list);
- /* Value saved here is to be restored into Vautoload_queue */
- record_unwind_protect (un_autoload, Vautoload_queue);
- Vautoload_queue = Qt;
-
/* Load the file. */
- tem = save_match_data_load
+ tem = load_with_autoload_queue
(NILP (filename) ? Fsymbol_name (feature) : filename,
noerror, Qt, Qnil, (NILP (filename) ? Qt : Qnil));
SDATA (tem3), tem2);
}
- /* Once loading finishes, don't undo it. */
- Vautoload_queue = Qt;
feature = unbind_to (count, feature);
}
extern AVOID args_out_of_range_3 (Lisp_Object, Lisp_Object, Lisp_Object);
extern AVOID wrong_type_argument (Lisp_Object, Lisp_Object);
extern Lisp_Object default_value (Lisp_Object symbol);
+extern void defalias (Lisp_Object symbol, Lisp_Object definition);
/* Defined in emacs.c. */
ATTRIBUTE_FORMAT_PRINTF (1, 0);
extern Lisp_Object vformat_string (const char *, va_list)
ATTRIBUTE_FORMAT_PRINTF (1, 0);
-extern void un_autoload (Lisp_Object);
+extern Lisp_Object load_with_autoload_queue
+ (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage,
+ Lisp_Object nosuffix, Lisp_Object must_suffix);
extern Lisp_Object call_debugger (Lisp_Object arg);
extern void init_eval_once (void);
extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
;;; range-tests.el --- Tests for range.el -*- lexical-binding: t; -*-
-;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.