diff options
| author | Stefan Monnier | 2012-07-25 21:27:33 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-07-25 21:27:33 -0400 |
| commit | 7abaf5ccc9f11e657b6671e7a6d5a7533bba5f31 (patch) | |
| tree | 26a250aef4c762d2128fb99c7442d01cedbd208b /src/eval.c | |
| parent | b1364986cb927ca113b0447a66a5274221ad9100 (diff) | |
| download | emacs-7abaf5ccc9f11e657b6671e7a6d5a7533bba5f31.tar.gz emacs-7abaf5ccc9f11e657b6671e7a6d5a7533bba5f31.zip | |
Autoload more carefully from Lisp. Follow aliases for function properties.
* lisp/subr.el (autoloadp): New function.
(symbol-file): Use it.
(function-get): New function.
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Use function-get and
autoload-do-load.
* lisp/emacs-lisp/lisp-mode.el (lisp-font-lock-syntactic-face-function)
(lisp-indent-function):
* lisp/emacs-lisp/gv.el (gv-get):
* lisp/emacs-lisp/edebug.el (get-edebug-spec, edebug-basic-spec):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form):
* lisp/emacs-lisp/bytecomp.el (byte-compile-arglist-warn):
* lisp/emacs-lisp/autoload.el (make-autoload, autoload-print-form):
Use function-get.
* lisp/emacs-lisp/cl.el: Don't propagate function properties any more.
* src/eval.c (Fautoload_do_load): Rename from do_autoload, export to Lisp,
add argument, tune behavior, and adjust all callers.
* lisp/speedbar.el (speedbar-add-localized-speedbar-support):
* lisp/emacs-lisp/disass.el (disassemble-internal):
* lisp/desktop.el (desktop-load-file):
* lisp/help-fns.el (help-function-arglist, find-lisp-object-file-name)
(describe-function-1):
* lisp/emacs-lisp/find-func.el (find-function-noselect):
* lisp/emacs-lisp/elp.el (elp-instrument-function):
* lisp/emacs-lisp/advice.el (ad-has-proper-definition):
* lisp/apropos.el (apropos-safe-documentation, apropos-macrop):
* lisp/emacs-lisp/debug.el (debug-on-entry):
* lisp/emacs-lisp/cl-macs.el (cl-compiler-macroexpand):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand):
* lisp/calc/calc.el (name): Use autoloadp & autoload-do-load.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/src/eval.c b/src/eval.c index a0143c372de..a0a05ebf0dc 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -988,26 +988,14 @@ definitions to shadow the loaded ones for use in file byte-compilation. */) | |||
| 988 | { | 988 | { |
| 989 | /* SYM is not mentioned in ENVIRONMENT. | 989 | /* SYM is not mentioned in ENVIRONMENT. |
| 990 | Look at its function definition. */ | 990 | Look at its function definition. */ |
| 991 | struct gcpro gcpro1; | ||
| 992 | GCPRO1 (form); | ||
| 993 | def = Fautoload_do_load (def, sym, Qmacro); | ||
| 994 | UNGCPRO; | ||
| 991 | if (EQ (def, Qunbound) || !CONSP (def)) | 995 | if (EQ (def, Qunbound) || !CONSP (def)) |
| 992 | /* Not defined or definition not suitable. */ | 996 | /* Not defined or definition not suitable. */ |
| 993 | break; | 997 | break; |
| 994 | if (EQ (XCAR (def), Qautoload)) | 998 | if (!EQ (XCAR (def), Qmacro)) |
| 995 | { | ||
| 996 | /* Autoloading function: will it be a macro when loaded? */ | ||
| 997 | tem = Fnth (make_number (4), def); | ||
| 998 | if (EQ (tem, Qt) || EQ (tem, Qmacro)) | ||
| 999 | /* Yes, load it and try again. */ | ||
| 1000 | { | ||
| 1001 | struct gcpro gcpro1; | ||
| 1002 | GCPRO1 (form); | ||
| 1003 | do_autoload (def, sym); | ||
| 1004 | UNGCPRO; | ||
| 1005 | continue; | ||
| 1006 | } | ||
| 1007 | else | ||
| 1008 | break; | ||
| 1009 | } | ||
| 1010 | else if (!EQ (XCAR (def), Qmacro)) | ||
| 1011 | break; | 999 | break; |
| 1012 | else expander = XCDR (def); | 1000 | else expander = XCDR (def); |
| 1013 | } | 1001 | } |
| @@ -1952,22 +1940,35 @@ un_autoload (Lisp_Object oldqueue) | |||
| 1952 | FUNNAME is the symbol which is the function's name. | 1940 | FUNNAME is the symbol which is the function's name. |
| 1953 | FUNDEF is the autoload definition (a list). */ | 1941 | FUNDEF is the autoload definition (a list). */ |
| 1954 | 1942 | ||
| 1955 | void | 1943 | DEFUN ("autoload-do-load", Fautoload_do_load, Sautoload_do_load, 1, 3, 0, |
| 1956 | do_autoload (Lisp_Object fundef, Lisp_Object funname) | 1944 | doc: /* Load FUNDEF which should be an autoload. |
| 1945 | If non-nil, FUNNAME should be the symbol whose function value is FUNDEF, | ||
| 1946 | in which case the function returns the new autoloaded function value. | ||
| 1947 | If equal to `macro', MACRO-ONLY specifies that FUNDEF should only be loaded if | ||
| 1948 | it is defines a macro. */) | ||
| 1949 | (Lisp_Object fundef, Lisp_Object funname, Lisp_Object macro_only) | ||
| 1957 | { | 1950 | { |
| 1958 | ptrdiff_t count = SPECPDL_INDEX (); | 1951 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1959 | Lisp_Object fun; | ||
| 1960 | struct gcpro gcpro1, gcpro2, gcpro3; | 1952 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 1961 | 1953 | ||
| 1954 | if (!CONSP (fundef) || !EQ (Qautoload, XCAR (fundef))) | ||
| 1955 | return fundef; | ||
| 1956 | |||
| 1957 | if (EQ (macro_only, Qmacro)) | ||
| 1958 | { | ||
| 1959 | Lisp_Object kind = Fnth (make_number (4), fundef); | ||
| 1960 | if (! (EQ (kind, Qt) || EQ (kind, Qmacro))) | ||
| 1961 | return fundef; | ||
| 1962 | } | ||
| 1963 | |||
| 1962 | /* This is to make sure that loadup.el gives a clear picture | 1964 | /* This is to make sure that loadup.el gives a clear picture |
| 1963 | of what files are preloaded and when. */ | 1965 | of what files are preloaded and when. */ |
| 1964 | if (! NILP (Vpurify_flag)) | 1966 | if (! NILP (Vpurify_flag)) |
| 1965 | error ("Attempt to autoload %s while preparing to dump", | 1967 | error ("Attempt to autoload %s while preparing to dump", |
| 1966 | SDATA (SYMBOL_NAME (funname))); | 1968 | SDATA (SYMBOL_NAME (funname))); |
| 1967 | 1969 | ||
| 1968 | fun = funname; | ||
| 1969 | CHECK_SYMBOL (funname); | 1970 | CHECK_SYMBOL (funname); |
| 1970 | GCPRO3 (fun, funname, fundef); | 1971 | GCPRO3 (funname, fundef, macro_only); |
| 1971 | 1972 | ||
| 1972 | /* Preserve the match data. */ | 1973 | /* Preserve the match data. */ |
| 1973 | record_unwind_save_match_data (); | 1974 | record_unwind_save_match_data (); |
| @@ -1982,18 +1983,28 @@ do_autoload (Lisp_Object fundef, Lisp_Object funname) | |||
| 1982 | The value saved here is to be restored into Vautoload_queue. */ | 1983 | The value saved here is to be restored into Vautoload_queue. */ |
| 1983 | record_unwind_protect (un_autoload, Vautoload_queue); | 1984 | record_unwind_protect (un_autoload, Vautoload_queue); |
| 1984 | Vautoload_queue = Qt; | 1985 | Vautoload_queue = Qt; |
| 1985 | Fload (Fcar (Fcdr (fundef)), Qnil, Qt, Qnil, Qt); | 1986 | /* If `macro_only', assume this autoload to be a "best-effort", |
| 1987 | so don't signal an error if autoloading fails. */ | ||
| 1988 | Fload (Fcar (Fcdr (fundef)), macro_only, Qt, Qnil, Qt); | ||
| 1986 | 1989 | ||
| 1987 | /* Once loading finishes, don't undo it. */ | 1990 | /* Once loading finishes, don't undo it. */ |
| 1988 | Vautoload_queue = Qt; | 1991 | Vautoload_queue = Qt; |
| 1989 | unbind_to (count, Qnil); | 1992 | unbind_to (count, Qnil); |
| 1990 | 1993 | ||
| 1991 | fun = Findirect_function (fun, Qnil); | ||
| 1992 | |||
| 1993 | if (!NILP (Fequal (fun, fundef))) | ||
| 1994 | error ("Autoloading failed to define function %s", | ||
| 1995 | SDATA (SYMBOL_NAME (funname))); | ||
| 1996 | UNGCPRO; | 1994 | UNGCPRO; |
| 1995 | |||
| 1996 | if (NILP (funname)) | ||
| 1997 | return Qnil; | ||
| 1998 | else | ||
| 1999 | { | ||
| 2000 | Lisp_Object fun = Findirect_function (funname, Qnil); | ||
| 2001 | |||
| 2002 | if (!NILP (Fequal (fun, fundef))) | ||
| 2003 | error ("Autoloading failed to define function %s", | ||
| 2004 | SDATA (SYMBOL_NAME (funname))); | ||
| 2005 | else | ||
| 2006 | return fun; | ||
| 2007 | } | ||
| 1997 | } | 2008 | } |
| 1998 | 2009 | ||
| 1999 | 2010 | ||
| @@ -2200,7 +2211,7 @@ eval_sub (Lisp_Object form) | |||
| 2200 | xsignal1 (Qinvalid_function, original_fun); | 2211 | xsignal1 (Qinvalid_function, original_fun); |
| 2201 | if (EQ (funcar, Qautoload)) | 2212 | if (EQ (funcar, Qautoload)) |
| 2202 | { | 2213 | { |
| 2203 | do_autoload (fun, original_fun); | 2214 | Fautoload_do_load (fun, original_fun, Qnil); |
| 2204 | goto retry; | 2215 | goto retry; |
| 2205 | } | 2216 | } |
| 2206 | if (EQ (funcar, Qmacro)) | 2217 | if (EQ (funcar, Qmacro)) |
| @@ -2729,7 +2740,6 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2729 | ptrdiff_t i; | 2740 | ptrdiff_t i; |
| 2730 | 2741 | ||
| 2731 | QUIT; | 2742 | QUIT; |
| 2732 | maybe_gc (); | ||
| 2733 | 2743 | ||
| 2734 | if (++lisp_eval_depth > max_lisp_eval_depth) | 2744 | if (++lisp_eval_depth > max_lisp_eval_depth) |
| 2735 | { | 2745 | { |
| @@ -2742,10 +2752,13 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2742 | backtrace.next = backtrace_list; | 2752 | backtrace.next = backtrace_list; |
| 2743 | backtrace_list = &backtrace; | 2753 | backtrace_list = &backtrace; |
| 2744 | backtrace.function = &args[0]; | 2754 | backtrace.function = &args[0]; |
| 2745 | backtrace.args = &args[1]; | 2755 | backtrace.args = &args[1]; /* This also GCPROs them. */ |
| 2746 | backtrace.nargs = nargs - 1; | 2756 | backtrace.nargs = nargs - 1; |
| 2747 | backtrace.debug_on_exit = 0; | 2757 | backtrace.debug_on_exit = 0; |
| 2748 | 2758 | ||
| 2759 | /* Call GC after setting up the backtrace, so the latter GCPROs the args. */ | ||
| 2760 | maybe_gc (); | ||
| 2761 | |||
| 2749 | if (debug_on_next_call) | 2762 | if (debug_on_next_call) |
| 2750 | do_debug_on_call (Qlambda); | 2763 | do_debug_on_call (Qlambda); |
| 2751 | 2764 | ||
| @@ -2857,7 +2870,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2857 | val = funcall_lambda (fun, numargs, args + 1); | 2870 | val = funcall_lambda (fun, numargs, args + 1); |
| 2858 | else if (EQ (funcar, Qautoload)) | 2871 | else if (EQ (funcar, Qautoload)) |
| 2859 | { | 2872 | { |
| 2860 | do_autoload (fun, original_fun); | 2873 | Fautoload_do_load (fun, original_fun, Qnil); |
| 2861 | CHECK_CONS_LIST (); | 2874 | CHECK_CONS_LIST (); |
| 2862 | goto retry; | 2875 | goto retry; |
| 2863 | } | 2876 | } |
| @@ -3582,6 +3595,7 @@ alist of active lexical bindings. */); | |||
| 3582 | defsubr (&Scalled_interactively_p); | 3595 | defsubr (&Scalled_interactively_p); |
| 3583 | defsubr (&Scommandp); | 3596 | defsubr (&Scommandp); |
| 3584 | defsubr (&Sautoload); | 3597 | defsubr (&Sautoload); |
| 3598 | defsubr (&Sautoload_do_load); | ||
| 3585 | defsubr (&Seval); | 3599 | defsubr (&Seval); |
| 3586 | defsubr (&Sapply); | 3600 | defsubr (&Sapply); |
| 3587 | defsubr (&Sfuncall); | 3601 | defsubr (&Sfuncall); |