unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* force auto compile .el files
@ 2006-03-25 12:25 Giuseppe Scrivano
  2006-03-26  0:20 ` Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Giuseppe Scrivano @ 2006-03-25 12:25 UTC (permalink / raw)


hello,

what do you think about the following patch?  Actually when
emacs tries to open an outdated .elc file it shows only a 
warning message, differently with this patch if the symbol 
`force-auto-compile' is not nil it automatically tries to 
compile the newer .el source file.  If the symbol is nil
it shows only the warning message.

Thanks,
Giuseppe


--- src/lread.c.old	2006-03-23 15:28:30.000000000 +0100
+++ src/lread.c	2006-03-25 12:33:00.000000000 +0100
@@ -724,6 +724,8 @@
   int newer = 0;
   /* 1 means we are loading a compiled file.  */
   int compiled = 0;
+	/* 1 means we forced the compilation of the .el file.  */
+	int force_compiled = 0;
   Lisp_Object handler;
   int safe_p = 1;
   char *fmode = "r";
@@ -887,9 +889,32 @@
 
 	  if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
 	    {
-	      /* Make the progress messages mention that source is newer.  */
-	      newer = 1;
-
+				/* If the symbol `force-auto-compile' is not NIL then try to
+					 automatically recompile the updated .el file.  If the value
+					 is NIL show only a warning.  */
+				if (!NILP (Fintern_soft (make_specified_string ("force-auto-compile", 
+																												-1, 18, 0), Qnil)))
+					{
+						Lisp_Object args[2];
+
+						args[0] = Fintern_soft (make_specified_string ("byte-compile-file",
+																													 -1, 17, 0), Qnil);
+
+						SSET (efound, SBYTES (efound) - 1, 0);
+						args[1] = Fsubstring (efound, make_number (0), make_number (-1));
+
+						if (args[0] != Qnil)
+							force_compiled = !NILP (Ffuncall (2, args));
+						else
+							newer = 1;
+
+						SSET (efound, SBYTES (efound) - 1, 'c');
+					}
+				else
+					{
+						/* Make the progress messages mention that source is newer.  */
+						newer = 1;
+					}
 	      /* If we won't print another message, mention this anyway.  */
 	      if (!NILP (nomessage))
 		{
@@ -941,9 +966,11 @@
       if (!safe_p)
 	message_with_string ("Loading %s (compiled; note unsafe, not compiled in Emacs)...",
 		 file, 1);
+			else if (force_compiled)
+	message_with_string ("Loading %s (force compiled)...", file, 1);
       else if (!compiled)
 	message_with_string ("Loading %s (source)...", file, 1);
-      else if (newer)
+			else if (newer)
 	message_with_string ("Loading %s (compiled; note, source file is newer)...",
 		 file, 1);
       else /* The typical case; compiled file newer than source file.  */

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

* Re: force auto compile .el files
  2006-03-25 12:25 force auto compile .el files Giuseppe Scrivano
@ 2006-03-26  0:20 ` Richard Stallman
  2006-03-26  0:59   ` Giuseppe Scrivano
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2006-03-26  0:20 UTC (permalink / raw)
  Cc: emacs-devel

I think it is a very bad idea to compile files automatically
when the user does not expect it.

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

* Re: force auto compile .el files
  2006-03-26  0:20 ` Richard Stallman
@ 2006-03-26  0:59   ` Giuseppe Scrivano
  2006-03-26  1:23     ` Thien-Thi Nguyen
  2006-03-27  8:35     ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Giuseppe Scrivano @ 2006-03-26  0:59 UTC (permalink / raw)
  Cc: emacs-devel

This works only if you set force-auto-compile to a non nil value.  
By default emacs will continue to don't compile files automatically.
Probably some users (me, for instance) will like the possibility to
have .elc files always updated without recompile them manually.

Regards,
Giuseppe


Richard Stallman <rms@gnu.org> writes:
> I think it is a very bad idea to compile files automatically
> when the user does not expect it.

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

* Re: force auto compile .el files
  2006-03-26  0:59   ` Giuseppe Scrivano
@ 2006-03-26  1:23     ` Thien-Thi Nguyen
  2006-03-27  8:35     ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Thien-Thi Nguyen @ 2006-03-26  1:23 UTC (permalink / raw)
  Cc: emacs-devel

Giuseppe Scrivano <gscrivano@gnu.org> writes:

> Probably some users (me, for instance) will like the possibility to
> have .elc files always updated without recompile them manually.

recompile on load becomes difficult when there are dependencies outside
the file (when it is not purely standalone), since there are many tricky
cases to consider when recursing.  to see what i mean, try (w/ your
patched emacs) munging some autoloaded gnus/*.el files while using gnus.
bonus points for surviving nontrivial changes to emacs-lisp/bytecomp.el.

instead, you can move the compile to `write-contents-hooks' or similar.
this can be arranged to be done automatically, as well.  it might even
already be a feature (if not in emacs proper, try emacswiki)...

thi

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

* Re: force auto compile .el files
  2006-03-26  0:59   ` Giuseppe Scrivano
  2006-03-26  1:23     ` Thien-Thi Nguyen
@ 2006-03-27  8:35     ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2006-03-27  8:35 UTC (permalink / raw)
  Cc: emacs-devel

    This works only if you set force-auto-compile to a non nil value.  
    By default emacs will continue to don't compile files automatically.

I understand that.  But it seems like such a dangerous way of doing
things that even offering it as an option seems like a bad idea.  This
is the kind of thing that can be a minor convenience 95% of the time,
and a real screw 50% of the time.  We should not invite people to do this.

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

end of thread, other threads:[~2006-03-27  8:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-25 12:25 force auto compile .el files Giuseppe Scrivano
2006-03-26  0:20 ` Richard Stallman
2006-03-26  0:59   ` Giuseppe Scrivano
2006-03-26  1:23     ` Thien-Thi Nguyen
2006-03-27  8:35     ` Richard Stallman

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).