aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2012-07-25 21:27:33 -0400
committerStefan Monnier2012-07-25 21:27:33 -0400
commit7abaf5ccc9f11e657b6671e7a6d5a7533bba5f31 (patch)
tree26a250aef4c762d2128fb99c7442d01cedbd208b /src
parentb1364986cb927ca113b0447a66a5274221ad9100 (diff)
downloademacs-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')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/data.c4
-rw-r--r--src/eval.c78
-rw-r--r--src/keyboard.c10
-rw-r--r--src/keymap.c4
-rw-r--r--src/lisp.h7
6 files changed, 60 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 88c90dd84d8..eb74f458942 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12012-07-26 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * eval.c (Fautoload_do_load): Rename from do_autoload, export to Lisp,
4 add argument, tune behavior, and adjust all callers.
5
12012-07-25 Paul Eggert <eggert@cs.ucla.edu> 62012-07-25 Paul Eggert <eggert@cs.ucla.edu>
2 7
3 Use typedef for EMACS_INT, EMACS_UINT. 8 Use typedef for EMACS_INT, EMACS_UINT.
diff --git a/src/data.c b/src/data.c
index 110e8ae41ab..b23bcbe15b3 100644
--- a/src/data.c
+++ b/src/data.c
@@ -761,7 +761,7 @@ Value, if non-nil, is a list \(interactive SPEC). */)
761 { 761 {
762 struct gcpro gcpro1; 762 struct gcpro gcpro1;
763 GCPRO1 (cmd); 763 GCPRO1 (cmd);
764 do_autoload (fun, cmd); 764 Fautoload_do_load (fun, cmd, Qnil);
765 UNGCPRO; 765 UNGCPRO;
766 return Finteractive_form (cmd); 766 return Finteractive_form (cmd);
767 } 767 }
@@ -2059,7 +2059,7 @@ function chain of symbols. */)
2059 return Qnil; 2059 return Qnil;
2060} 2060}
2061 2061
2062/* Extract and set vector and string elements */ 2062/* Extract and set vector and string elements. */
2063 2063
2064DEFUN ("aref", Faref, Saref, 2, 2, 0, 2064DEFUN ("aref", Faref, Saref, 2, 2, 0,
2065 doc: /* Return the element of ARRAY at index IDX. 2065 doc: /* Return the element of ARRAY at index IDX.
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
1955void 1943DEFUN ("autoload-do-load", Fautoload_do_load, Sautoload_do_load, 1, 3, 0,
1956do_autoload (Lisp_Object fundef, Lisp_Object funname) 1944 doc: /* Load FUNDEF which should be an autoload.
1945If non-nil, FUNNAME should be the symbol whose function value is FUNDEF,
1946in which case the function returns the new autoloaded function value.
1947If equal to `macro', MACRO-ONLY specifies that FUNDEF should only be loaded if
1948it 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);
diff --git a/src/keyboard.c b/src/keyboard.c
index 0c03a2143d8..1f6c47eaf79 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8827,18 +8827,12 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
8827 8827
8828 next = access_keymap (map, key, 1, 0, 1); 8828 next = access_keymap (map, key, 1, 0, 1);
8829 8829
8830 /* Handle symbol with autoload definition. */
8831 if (SYMBOLP (next) && !NILP (Ffboundp (next))
8832 && CONSP (XSYMBOL (next)->function)
8833 && EQ (XCAR (XSYMBOL (next)->function), Qautoload))
8834 do_autoload (XSYMBOL (next)->function, next);
8835
8836 /* Handle a symbol whose function definition is a keymap 8830 /* Handle a symbol whose function definition is a keymap
8837 or an array. */ 8831 or an array. */
8838 if (SYMBOLP (next) && !NILP (Ffboundp (next)) 8832 if (SYMBOLP (next) && !NILP (Ffboundp (next))
8839 && (ARRAYP (XSYMBOL (next)->function) 8833 && (ARRAYP (XSYMBOL (next)->function)
8840 || KEYMAPP (XSYMBOL (next)->function))) 8834 || KEYMAPP (XSYMBOL (next)->function)))
8841 next = XSYMBOL (next)->function; 8835 next = Fautoload_do_load (XSYMBOL (next)->function, next, Qnil);
8842 8836
8843 /* If the keymap gives a function, not an 8837 /* If the keymap gives a function, not an
8844 array, then call the function with one arg and use 8838 array, then call the function with one arg and use
@@ -10282,7 +10276,7 @@ a special event, so ignore the prefix argument and don't clear it. */)
10282 struct gcpro gcpro1, gcpro2; 10276 struct gcpro gcpro1, gcpro2;
10283 10277
10284 GCPRO2 (cmd, prefixarg); 10278 GCPRO2 (cmd, prefixarg);
10285 do_autoload (final, cmd); 10279 Fautoload_do_load (final, cmd, Qnil);
10286 UNGCPRO; 10280 UNGCPRO;
10287 } 10281 }
10288 else 10282 else
diff --git a/src/keymap.c b/src/keymap.c
index 510c5ea7f3e..feaf0cfd961 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -225,7 +225,7 @@ when reading a key-sequence to be looked-up in this keymap. */)
225 Fdefine_key should cause keymaps to be autoloaded. 225 Fdefine_key should cause keymaps to be autoloaded.
226 226
227 This function can GC when AUTOLOAD is non-zero, because it calls 227 This function can GC when AUTOLOAD is non-zero, because it calls
228 do_autoload which can GC. */ 228 Fautoload_do_load which can GC. */
229 229
230Lisp_Object 230Lisp_Object
231get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) 231get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload)
@@ -259,7 +259,7 @@ get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload)
259 struct gcpro gcpro1, gcpro2; 259 struct gcpro gcpro1, gcpro2;
260 260
261 GCPRO2 (tem, object); 261 GCPRO2 (tem, object);
262 do_autoload (tem, object); 262 Fautoload_do_load (tem, object, Qnil);
263 UNGCPRO; 263 UNGCPRO;
264 264
265 goto autoload_retry; 265 goto autoload_retry;
diff --git a/src/lisp.h b/src/lisp.h
index e4eb8ce5084..d9305555778 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2822,7 +2822,6 @@ extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object);
2822extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); 2822extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
2823extern _Noreturn void verror (const char *, va_list) 2823extern _Noreturn void verror (const char *, va_list)
2824 ATTRIBUTE_FORMAT_PRINTF (1, 0); 2824 ATTRIBUTE_FORMAT_PRINTF (1, 0);
2825extern void do_autoload (Lisp_Object, Lisp_Object);
2826extern Lisp_Object un_autoload (Lisp_Object); 2825extern Lisp_Object un_autoload (Lisp_Object);
2827extern void init_eval_once (void); 2826extern void init_eval_once (void);
2828extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *); 2827extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *);
@@ -2834,7 +2833,7 @@ extern void mark_backtrace (void);
2834#endif 2833#endif
2835extern void syms_of_eval (void); 2834extern void syms_of_eval (void);
2836 2835
2837/* Defined in editfns.c */ 2836/* Defined in editfns.c. */
2838extern Lisp_Object Qfield; 2837extern Lisp_Object Qfield;
2839extern void insert1 (Lisp_Object); 2838extern void insert1 (Lisp_Object);
2840extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); 2839extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object);
@@ -2851,7 +2850,7 @@ const char *get_system_name (void);
2851extern void syms_of_editfns (void); 2850extern void syms_of_editfns (void);
2852extern void set_time_zone_rule (const char *); 2851extern void set_time_zone_rule (const char *);
2853 2852
2854/* Defined in buffer.c */ 2853/* Defined in buffer.c. */
2855extern int mouse_face_overlay_overlaps (Lisp_Object); 2854extern int mouse_face_overlay_overlaps (Lisp_Object);
2856extern _Noreturn void nsberror (Lisp_Object); 2855extern _Noreturn void nsberror (Lisp_Object);
2857extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t); 2856extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t);
@@ -2870,7 +2869,7 @@ extern void init_buffer (void);
2870extern void syms_of_buffer (void); 2869extern void syms_of_buffer (void);
2871extern void keys_of_buffer (void); 2870extern void keys_of_buffer (void);
2872 2871
2873/* Defined in marker.c */ 2872/* Defined in marker.c. */
2874 2873
2875extern ptrdiff_t marker_position (Lisp_Object); 2874extern ptrdiff_t marker_position (Lisp_Object);
2876extern ptrdiff_t marker_byte_position (Lisp_Object); 2875extern ptrdiff_t marker_byte_position (Lisp_Object);