From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giuseppe Scrivano Newsgroups: gmane.emacs.devel Subject: force auto compile .el files Date: Sat, 25 Mar 2006 13:25:00 +0100 Message-ID: <87pskahftv.fsf@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1143295296 4762 80.91.229.2 (25 Mar 2006 14:01:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 25 Mar 2006 14:01:36 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 25 15:01:34 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FN9Kc-0002bT-QO for ged-emacs-devel@m.gmane.org; Sat, 25 Mar 2006 15:01:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FN9Kb-00044b-I3 for ged-emacs-devel@m.gmane.org; Sat, 25 Mar 2006 09:01:29 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FN7p9-0002Sr-Qf for emacs-devel@gnu.org; Sat, 25 Mar 2006 07:24:55 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FN7p7-0002Ro-83 for emacs-devel@gnu.org; Sat, 25 Mar 2006 07:24:55 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FN7p7-0002Rl-3d for emacs-devel@gnu.org; Sat, 25 Mar 2006 07:24:53 -0500 Original-Received: from [213.205.33.43] (helo=mail-relay-3.tiscali.it) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FN7q9-000577-JN for emacs-devel@gnu.org; Sat, 25 Mar 2006 07:25:57 -0500 Original-Received: from steel (84.222.167.252) by mail-relay-3.tiscali.it (7.2.069.1) id 438439FE00FB7C55 for emacs-devel@gnu.org; Sat, 25 Mar 2006 13:24:51 +0100 Original-Received: from gscrivano by steel with local (Exim 4.60) (envelope-from ) id 1FN7pF-00018J-1W; Sat, 25 Mar 2006 13:25:01 +0100 Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-Mailman-Approved-At: Sat, 25 Mar 2006 09:00:32 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:52046 Archived-At: 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. */