emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111862: Avoid recursive byte-compile


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111862: Avoid recursive byte-compile-files fighting over input/output buffers
Date: Sat, 23 Feb 2013 13:14:36 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111862
fixes bug: http://debbugs.gnu.org/13787
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Sat 2013-02-23 13:14:36 -0800
message:
  Avoid recursive byte-compile-files fighting over input/output buffers
  
  * lisp/emacs-lisp/bytecomp.el (byte-compile-level): New.
  (byte-compile-file, byte-compile-from-buffer):
  Use separate input/output buffers for each level of recursive
  byte-compile-file calls.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/bytecomp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-02-23 12:40:14 +0000
+++ b/lisp/ChangeLog    2013-02-23 21:14:36 +0000
@@ -1,3 +1,10 @@
+2013-02-23  Glenn Morris  <address@hidden>
+
+       * emacs-lisp/bytecomp.el (byte-compile-level): New.
+       (byte-compile-file, byte-compile-from-buffer):
+       Use separate input/output buffers for each level of recursive
+       byte-compile-file calls.  (Bug#13787)
+
 2013-02-23  Michael Albinus  <address@hidden>
 
        * net/tramp.el (tramp-methods): Fix docstring.

=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- a/lisp/emacs-lisp/bytecomp.el       2013-02-09 12:52:01 +0000
+++ b/lisp/emacs-lisp/bytecomp.el       2013-02-23 21:14:36 +0000
@@ -1675,6 +1675,9 @@
        (load (if (file-exists-p dest) dest filename)))
       'no-byte-compile)))
 
+(defvar byte-compile-level 0           ; bug#13787
+  "Depth of a recursive byte compilation.")
+
 ;;;###autoload
 (defun byte-compile-file (filename &optional load)
   "Compile a file of Lisp code named FILENAME into a file of byte code.
@@ -1717,7 +1720,13 @@
     (setq target-file (byte-compile-dest-file filename))
     (setq byte-compile-dest-file target-file)
     (with-current-buffer
-        (setq input-buffer (get-buffer-create " *Compiler Input*"))
+       ;; It would be cleaner to use a temp buffer, but if there was
+       ;; an error, we leave this buffer around for diagnostics.
+       ;; Its name is documented in the lispref.
+       (setq input-buffer (get-buffer-create
+                           (concat " *Compiler Input*"
+                                   (if (zerop byte-compile-level) ""
+                                     (format "-%s" byte-compile-level)))))
       (erase-buffer)
       (setq buffer-file-coding-system nil)
       ;; Always compile an Emacs Lisp file as multibyte
@@ -1770,12 +1779,15 @@
       (when byte-compile-verbose
        (message "Compiling %s..." filename))
       (setq byte-compiler-error-flag nil)
+      (setq byte-compile-level (1+ byte-compile-level))
       ;; It is important that input-buffer not be current at this call,
       ;; so that the value of point set in input-buffer
       ;; within byte-compile-from-buffer lingers in that buffer.
       (setq output-buffer
            (save-current-buffer
-             (byte-compile-from-buffer input-buffer)))
+             (unwind-protect
+                 (byte-compile-from-buffer input-buffer)
+               (setq byte-compile-level (1- byte-compile-level)))))
       (if byte-compiler-error-flag
          nil
        (when byte-compile-verbose
@@ -1881,7 +1893,10 @@
     (byte-compile-close-variables
      (with-current-buffer
          (setq byte-compile--outbuffer
-               (get-buffer-create " *Compiler Output*"))
+               (get-buffer-create
+                (concat " *Compiler Output*"
+                        (if (<= byte-compile-level 1) ""
+                          (format "-%s" (1- byte-compile-level))))))
        (set-buffer-multibyte t)
        (erase-buffer)
        ;;       (emacs-lisp-mode)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]