Commit ca105506 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

Remove bytecomp- prefix, plus misc changes.

* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Make it work to
inline lexbind interpreted functions into lexbind code.
(bytedecomp-bytes): Not a dynamic var any more.
(disassemble-offset): Get the bytes via an argument instead.
(byte-decompile-bytecode-1): Use push.
* lisp/emacs-lisp/bytecomp.el: Remove the bytecomp- prefix now that we use
lexical-binding.
(byte-compile-outbuffer): Rename from bytecomp-outbuffer.
* lisp/emacs-lisp/cl-macs.el (load-time-value):
* lisp/emacs-lisp/cl.el (cl-compiling-file): Adjust to new name.
* lisp/emacs-lisp/pcase.el (pcase-mutually-exclusive-predicates):
Add byte-code-function-p.
(pcase--u1): Remove left-over code from early development.
Fix case of variable shadowing in guards and predicates.
(pcase--u1): Add a new `let' pattern.
* src/image.c (parse_image_spec): Use Ffunctionp.
* src/lisp.h: Declare Ffunctionp.
parent 2663659f
2011-03-16 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/pcase.el (pcase-mutually-exclusive-predicates):
Add byte-code-function-p.
(pcase--u1): Remove left-over code from early development.
Fix case of variable shadowing in guards and predicates.
(pcase--u1): Add a new `let' pattern.
* emacs-lisp/bytecomp.el: Remove the bytecomp- prefix now that we use
lexical-binding.
(byte-compile-outbuffer): Rename from bytecomp-outbuffer.
* emacs-lisp/cl-macs.el (load-time-value):
* emacs-lisp/cl.el (cl-compiling-file): Adjust to new name.
* emacs-lisp/byte-opt.el (byte-compile-inline-expand): Make it work to
inline lexbind interpreted functions into lexbind code.
(bytedecomp-bytes): Not a dynamic var any more.
(disassemble-offset): Get the bytes via an argument instead.
(byte-decompile-bytecode-1): Use push.
2011-03-15 Stefan Monnier <monnier@iro.umontreal.ca>
* makefile.w32-in (COMPILE_FIRST): Fix up last change.
......
......@@ -265,45 +265,72 @@
(defun byte-compile-inline-expand (form)
(let* ((name (car form))
(fn (or (cdr (assq name byte-compile-function-environment))
(and (fboundp name) (symbol-function name)))))
(if (null fn)
(progn
(byte-compile-warn "attempt to inline `%s' before it was defined"
name)
form)
;; else
(when (and (consp fn) (eq (car fn) 'autoload))
(load (nth 1 fn))
(setq fn (or (and (fboundp name) (symbol-function name))
(cdr (assq name byte-compile-function-environment)))))
(if (and (consp fn) (eq (car fn) 'autoload))
(error "File `%s' didn't define `%s'" (nth 1 fn) name))
(cond
((and (symbolp fn) (not (eq fn t))) ;A function alias.
(byte-compile-inline-expand (cons fn (cdr form))))
((and (byte-code-function-p fn)
;; FIXME: This works to inline old-style-byte-codes into
;; old-style-byte-codes, but not mixed cases (not sure
;; about new-style into new-style).
(not lexical-binding)
(not (integerp (aref fn 0)))) ;New lexical byte-code.
;; (message "Inlining %S byte-code" name)
(fetch-bytecode fn)
(let ((string (aref fn 1)))
;; Isn't it an error for `string' not to be unibyte?? --stef
(if (fboundp 'string-as-unibyte)
(setq string (string-as-unibyte string)))
;; `byte-compile-splice-in-already-compiled-code'
;; takes care of inlining the body.
(cons `(lambda ,(aref fn 0)
(byte-code ,string ,(aref fn 2) ,(aref fn 3)))
(cdr form))))
((eq (car-safe fn) 'lambda)
(macroexpand-all (cons fn (cdr form))
byte-compile-macro-environment))
(t ;; Give up on inlining.
form)))))
(localfn (cdr (assq name byte-compile-function-environment)))
(fn (or localfn (and (fboundp name) (symbol-function name)))))
(when (and (consp fn) (eq (car fn) 'autoload))
(load (nth 1 fn))
(setq fn (or (and (fboundp name) (symbol-function name))
(cdr (assq name byte-compile-function-environment)))))
(pcase fn
(`nil
(byte-compile-warn "attempt to inline `%s' before it was defined"
name)
form)
(`(autoload . ,_)
(error "File `%s' didn't define `%s'" (nth 1 fn) name))
((and (pred symbolp) (guard (not (eq fn t)))) ;A function alias.
(byte-compile-inline-expand (cons fn (cdr form))))
((and (pred byte-code-function-p)
;; FIXME: This only works to inline old-style-byte-codes into
;; old-style-byte-codes.
(guard (not (or lexical-binding
(integerp (aref fn 0))))))
;; (message "Inlining %S byte-code" name)
(fetch-bytecode fn)
(let ((string (aref fn 1)))
(assert (not (multibyte-string-p string)))
;; `byte-compile-splice-in-already-compiled-code'
;; takes care of inlining the body.
(cons `(lambda ,(aref fn 0)
(byte-code ,string ,(aref fn 2) ,(aref fn 3)))
(cdr form))))
((and `(lambda . ,_)
;; With lexical-binding we have several problems:
;; - if `fn' comes from byte-compile-function-environment, we
;; need to preprocess `fn', so we handle it below.
;; - else, it means that `fn' is dyn-bound (otherwise it would
;; start with `closure') so copying the code here would cause
;; it to be mis-interpreted.
(guard (not lexical-binding)))
(macroexpand-all (cons fn (cdr form))
byte-compile-macro-environment))
((and (or (and `(lambda ,args . ,body)
(let env nil)
(guard (eq fn localfn)))
`(closure ,env ,args . ,body))
(guard lexical-binding))
(let ((renv ()))
(dolist (binding env)
(cond
((consp binding)
;; We check shadowing by the args, so that the `let' can be
;; moved within the lambda, which can then be unfolded.
;; FIXME: Some of those bindings might be unused in `body'.
(unless (memq (car binding) args) ;Shadowed.
(push `(,(car binding) ',(cdr binding)) renv)))
((eq binding t))
(t (push `(defvar ,binding) body))))
;; (message "Inlining closure %S" (car form))
(let ((newfn (byte-compile-preprocess
`(lambda ,args (let ,(nreverse renv) ,@body)))))
(if (eq (car-safe newfn) 'function)
(byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form)))
(byte-compile-log-warning
(format "Inlining closure %S failed" name))
form))))
(t ;; Give up on inlining.
form))))
;; ((lambda ...) ...)
(defun byte-compile-unfold-lambda (form &optional name)
......@@ -1095,7 +1122,7 @@
(let ((fn (nth 1 form)))
(if (memq (car-safe fn) '(quote function))
(cons (nth 1 fn) (cdr (cdr form)))
form)))
form)))
(defun byte-optimize-apply (form)
;; If the last arg is a literal constant, turn this into a funcall.
......@@ -1318,43 +1345,42 @@
;; Used and set dynamically in byte-decompile-bytecode-1.
(defvar bytedecomp-op)
(defvar bytedecomp-ptr)
(defvar bytedecomp-bytes)
;; This function extracts the bitfields from variable-length opcodes.
;; Originally defined in disass.el (which no longer uses it.)
(defun disassemble-offset ()
(defun disassemble-offset (bytes)
"Don't call this!"
;; fetch and return the offset for the current opcode.
;; return nil if this opcode has no offset
;; Fetch and return the offset for the current opcode.
;; Return nil if this opcode has no offset.
(cond ((< bytedecomp-op byte-nth)
(let ((tem (logand bytedecomp-op 7)))
(setq bytedecomp-op (logand bytedecomp-op 248))
(cond ((eq tem 6)
;; Offset in next byte.
(setq bytedecomp-ptr (1+ bytedecomp-ptr))
(aref bytedecomp-bytes bytedecomp-ptr))
(aref bytes bytedecomp-ptr))
((eq tem 7)
;; Offset in next 2 bytes.
(setq bytedecomp-ptr (1+ bytedecomp-ptr))
(+ (aref bytedecomp-bytes bytedecomp-ptr)
(+ (aref bytes bytedecomp-ptr)
(progn (setq bytedecomp-ptr (1+ bytedecomp-ptr))
(lsh (aref bytedecomp-bytes bytedecomp-ptr) 8))))
(t tem)))) ;offset was in opcode
(lsh (aref bytes bytedecomp-ptr) 8))))
(t tem)))) ;Offset was in opcode.
((>= bytedecomp-op byte-constant)
(prog1 (- bytedecomp-op byte-constant) ;offset in opcode
(prog1 (- bytedecomp-op byte-constant) ;Offset in opcode.
(setq bytedecomp-op byte-constant)))
((or (and (>= bytedecomp-op byte-constant2)
(<= bytedecomp-op byte-goto-if-not-nil-else-pop))
(= bytedecomp-op byte-stack-set2))
;; Offset in next 2 bytes.
(setq bytedecomp-ptr (1+ bytedecomp-ptr))
(+ (aref bytedecomp-bytes bytedecomp-ptr)
(+ (aref bytes bytedecomp-ptr)
(progn (setq bytedecomp-ptr (1+ bytedecomp-ptr))
(lsh (aref bytedecomp-bytes bytedecomp-ptr) 8))))
(lsh (aref bytes bytedecomp-ptr) 8))))
((and (>= bytedecomp-op byte-listN)
(<= bytedecomp-op byte-discardN))
(setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;offset in next byte
(aref bytedecomp-bytes bytedecomp-ptr))))
(setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;Offset in next byte.
(aref bytes bytedecomp-ptr))))
(defvar byte-compile-tag-number)
......@@ -1381,24 +1407,24 @@
(defun byte-decompile-bytecode-1 (bytes constvec &optional make-spliceable)
(let ((bytedecomp-bytes bytes)
(length (length bytes))
(bytedecomp-ptr 0) optr tags bytedecomp-op offset
(bytedecomp-ptr 0) optr tags bytedecomp-op offset
lap tmp
endtag)
(while (not (= bytedecomp-ptr length))
(or make-spliceable
(setq lap (cons bytedecomp-ptr lap)))
(push bytedecomp-ptr lap))
(setq bytedecomp-op (aref bytedecomp-bytes bytedecomp-ptr)
optr bytedecomp-ptr
offset (disassemble-offset)) ; this does dynamic-scope magic
;; This uses dynamic-scope magic.
offset (disassemble-offset bytedecomp-bytes))
(setq bytedecomp-op (aref byte-code-vector bytedecomp-op))
(cond ((memq bytedecomp-op byte-goto-ops)
;; it's a pc
;; It's a pc.
(setq offset
(cdr (or (assq offset tags)
(car (setq tags
(cons (cons offset
(byte-compile-make-tag))
tags)))))))
(let ((new (cons offset (byte-compile-make-tag))))
(push new tags)
new)))))
((cond ((eq bytedecomp-op 'byte-constant2)
(setq bytedecomp-op 'byte-constant) t)
((memq bytedecomp-op byte-constref-ops)))
......@@ -1408,9 +1434,9 @@
offset (if (eq bytedecomp-op 'byte-constant)
(byte-compile-get-constant tmp)
(or (assq tmp byte-compile-variables)
(car (setq byte-compile-variables
(cons (list tmp)
byte-compile-variables)))))))
(let ((new (list tmp)))
(push new byte-compile-variables)
new)))))
((and make-spliceable
(eq bytedecomp-op 'byte-return))
(if (= bytedecomp-ptr (1- length))
......@@ -1427,26 +1453,26 @@
(setq bytedecomp-op 'byte-discardN-preserve-tos)
(setq offset (- offset #x80))))
;; lap = ( [ (pc . (op . arg)) ]* )
(setq lap (cons (cons optr (cons bytedecomp-op (or offset 0)))
lap))
(push (cons optr (cons bytedecomp-op (or offset 0)))
lap)
(setq bytedecomp-ptr (1+ bytedecomp-ptr)))
;; take off the dummy nil op that we replaced a trailing "return" with.
(let ((rest lap))
(while rest
(cond ((numberp (car rest)))
((setq tmp (assq (car (car rest)) tags))
;; this addr is jumped to
;; This addr is jumped to.
(setcdr rest (cons (cons nil (cdr tmp))
(cdr rest)))
(setq tags (delq tmp tags))
(setq rest (cdr rest))))
(setq rest (cdr rest))))
(if tags (error "optimizer error: missed tags %s" tags))
;; Take off the dummy nil op that we replaced a trailing "return" with.
(if (null (car (cdr (car lap))))
(setq lap (cdr lap)))
(if endtag
(setq lap (cons (cons nil endtag) lap)))
;; remove addrs, lap = ( [ (op . arg) | (TAG tagno) ]* )
;; Remove addrs, lap = ( [ (op . arg) | (TAG tagno) ]* )
(mapcar (function (lambda (elt)
(if (numberp elt)
elt
......
......@@ -33,8 +33,6 @@
;;; Code:
;; FIXME: get rid of the atrocious "bytecomp-" variable prefix.
;; ========================================================================
;; Entry points:
;; byte-recompile-directory, byte-compile-file,
......@@ -1563,41 +1561,33 @@ Files in subdirectories of DIRECTORY are processed also."
(interactive "DByte force recompile (directory): ")
(byte-recompile-directory directory nil t))
;; The `bytecomp-' prefix is applied to all local variables with
;; otherwise common names in this and similar functions for the sake
;; of the boundp test in byte-compile-variable-ref.
;; http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg00237.html
;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2008-02/msg00134.html
;; Note that similar considerations apply to command-line-1 in startup.el.
;;;###autoload
(defun byte-recompile-directory (bytecomp-directory &optional bytecomp-arg
bytecomp-force)
"Recompile every `.el' file in BYTECOMP-DIRECTORY that needs recompilation.
(defun byte-recompile-directory (directory &optional arg force)
"Recompile every `.el' file in DIRECTORY that needs recompilation.
This happens when a `.elc' file exists but is older than the `.el' file.
Files in subdirectories of BYTECOMP-DIRECTORY are processed also.
Files in subdirectories of DIRECTORY are processed also.
If the `.elc' file does not exist, normally this function *does not*
compile the corresponding `.el' file. However, if the prefix argument
BYTECOMP-ARG is 0, that means do compile all those files. A nonzero
BYTECOMP-ARG means ask the user, for each such `.el' file, whether to
compile it. A nonzero BYTECOMP-ARG also means ask about each subdirectory
ARG is 0, that means do compile all those files. A nonzero
ARG means ask the user, for each such `.el' file, whether to
compile it. A nonzero ARG also means ask about each subdirectory
before scanning it.
If the third argument BYTECOMP-FORCE is non-nil, recompile every `.el' file
If the third argument FORCE is non-nil, recompile every `.el' file
that already has a `.elc' file."
(interactive "DByte recompile directory: \nP")
(if bytecomp-arg
(setq bytecomp-arg (prefix-numeric-value bytecomp-arg)))
(if arg (setq arg (prefix-numeric-value arg)))
(if noninteractive
nil
(save-some-buffers)
(force-mode-line-update))
(with-current-buffer (get-buffer-create byte-compile-log-buffer)
(setq default-directory (expand-file-name bytecomp-directory))
(setq default-directory (expand-file-name directory))
;; compilation-mode copies value of default-directory.
(unless (eq major-mode 'compilation-mode)
(compilation-mode))
(let ((bytecomp-directories (list default-directory))
(let ((directories (list default-directory))
(default-directory default-directory)
(skip-count 0)
(fail-count 0)
......@@ -1605,47 +1595,36 @@ that already has a `.elc' file."
(dir-count 0)
last-dir)
(displaying-byte-compile-warnings
(while bytecomp-directories
(setq bytecomp-directory (car bytecomp-directories))
(message "Checking %s..." bytecomp-directory)
(let ((bytecomp-files (directory-files bytecomp-directory))
bytecomp-source)
(dolist (bytecomp-file bytecomp-files)
(setq bytecomp-source
(expand-file-name bytecomp-file bytecomp-directory))
(if (and (not (member bytecomp-file '("RCS" "CVS")))
(not (eq ?\. (aref bytecomp-file 0)))
(file-directory-p bytecomp-source)
(not (file-symlink-p bytecomp-source)))
;; This file is a subdirectory. Handle them differently.
(when (or (null bytecomp-arg)
(eq 0 bytecomp-arg)
(y-or-n-p (concat "Check " bytecomp-source "? ")))
(setq bytecomp-directories
(nconc bytecomp-directories (list bytecomp-source))))
;; It is an ordinary file. Decide whether to compile it.
(if (and (string-match emacs-lisp-file-regexp bytecomp-source)
(file-readable-p bytecomp-source)
(not (auto-save-file-name-p bytecomp-source))
(not (string-equal dir-locals-file
(file-name-nondirectory
bytecomp-source))))
(progn (let ((bytecomp-res (byte-recompile-file
bytecomp-source
bytecomp-force bytecomp-arg)))
(cond ((eq bytecomp-res 'no-byte-compile)
(setq skip-count (1+ skip-count)))
((eq bytecomp-res t)
(setq file-count (1+ file-count)))
((eq bytecomp-res nil)
(setq fail-count (1+ fail-count)))))
(or noninteractive
(message "Checking %s..." bytecomp-directory))
(if (not (eq last-dir bytecomp-directory))
(setq last-dir bytecomp-directory
dir-count (1+ dir-count)))
)))))
(setq bytecomp-directories (cdr bytecomp-directories))))
(while directories
(setq directory (car directories))
(message "Checking %s..." directory)
(dolist (file (directory-files directory))
(let ((source (expand-file-name file directory)))
(if (and (not (member file '("RCS" "CVS")))
(not (eq ?\. (aref file 0)))
(file-directory-p source)
(not (file-symlink-p source)))
;; This file is a subdirectory. Handle them differently.
(when (or (null arg) (eq 0 arg)
(y-or-n-p (concat "Check " source "? ")))
(setq directories (nconc directories (list source))))
;; It is an ordinary file. Decide whether to compile it.
(if (and (string-match emacs-lisp-file-regexp source)
(file-readable-p source)
(not (auto-save-file-name-p source))
(not (string-equal dir-locals-file
(file-name-nondirectory source))))
(progn (case (byte-recompile-file source force arg)
(no-byte-compile (setq skip-count (1+ skip-count)))
((t) (setq file-count (1+ file-count)))
((nil) (setq fail-count (1+ fail-count))))
(or noninteractive
(message "Checking %s..." directory))
(if (not (eq last-dir directory))
(setq last-dir directory
dir-count (1+ dir-count)))
)))))
(setq directories (cdr directories))))
(message "Done (Total of %d file%s compiled%s%s%s)"
file-count (if (= file-count 1) "" "s")
(if (> fail-count 0) (format ", %d failed" fail-count) "")
......@@ -1660,100 +1639,97 @@ This is normally set in local file variables at the end of the elisp file:
\;; Local Variables:\n;; no-byte-compile: t\n;; End: ") ;Backslash for compile-main.
;;;###autoload(put 'no-byte-compile 'safe-local-variable 'booleanp)
(defun byte-recompile-file (bytecomp-filename &optional bytecomp-force bytecomp-arg load)
"Recompile BYTECOMP-FILENAME file if it needs recompilation.
(defun byte-recompile-file (filename &optional force arg load)
"Recompile FILENAME file if it needs recompilation.
This happens when its `.elc' file is older than itself.
If the `.elc' file exists and is up-to-date, normally this
function *does not* compile BYTECOMP-FILENAME. However, if the
prefix argument BYTECOMP-FORCE is set, that means do compile
BYTECOMP-FILENAME even if the destination already exists and is
function *does not* compile FILENAME. However, if the
prefix argument FORCE is set, that means do compile
FILENAME even if the destination already exists and is
up-to-date.
If the `.elc' file does not exist, normally this function *does
not* compile BYTECOMP-FILENAME. If BYTECOMP-ARG is 0, that means
not* compile FILENAME. If ARG is 0, that means
compile the file even if it has never been compiled before.
A nonzero BYTECOMP-ARG means ask the user.
A nonzero ARG means ask the user.
If LOAD is set, `load' the file after compiling.
The value returned is the value returned by `byte-compile-file',
or 'no-byte-compile if the file did not need recompilation."
(interactive
(let ((bytecomp-file buffer-file-name)
(bytecomp-file-name nil)
(bytecomp-file-dir nil))
(and bytecomp-file
(eq (cdr (assq 'major-mode (buffer-local-variables)))
'emacs-lisp-mode)
(setq bytecomp-file-name (file-name-nondirectory bytecomp-file)
bytecomp-file-dir (file-name-directory bytecomp-file)))
(let ((file buffer-file-name)
(file-name nil)
(file-dir nil))
(and file
(derived-mode-p 'emacs-lisp-mode)
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name (if current-prefix-arg
"Byte compile file: "
"Byte recompile file: ")
bytecomp-file-dir bytecomp-file-name nil)
file-dir file-name nil)
current-prefix-arg)))
(let ((bytecomp-dest
(byte-compile-dest-file bytecomp-filename))
(let ((dest (byte-compile-dest-file filename))
;; Expand now so we get the current buffer's defaults
(bytecomp-filename (expand-file-name bytecomp-filename)))
(if (if (file-exists-p bytecomp-dest)
(filename (expand-file-name filename)))
(if (if (file-exists-p dest)
;; File was already compiled
;; Compile if forced to, or filename newer
(or bytecomp-force
(file-newer-than-file-p bytecomp-filename
bytecomp-dest))
(and bytecomp-arg
(or (eq 0 bytecomp-arg)
(or force
(file-newer-than-file-p filename dest))
(and arg
(or (eq 0 arg)
(y-or-n-p (concat "Compile "
bytecomp-filename "? ")))))
filename "? ")))))
(progn
(if (and noninteractive (not byte-compile-verbose))
(message "Compiling %s..." bytecomp-filename))
(byte-compile-file bytecomp-filename load))
(when load (load bytecomp-filename))
(message "Compiling %s..." filename))
(byte-compile-file filename load))
(when load (load filename))
'no-byte-compile)))
;;;###autoload
(defun byte-compile-file (bytecomp-filename &optional load)
"Compile a file of Lisp code named BYTECOMP-FILENAME into a file of byte code.
The output file's name is generated by passing BYTECOMP-FILENAME to the
(defun byte-compile-file (filename &optional load)
"Compile a file of Lisp code named FILENAME into a file of byte code.
The output file's name is generated by passing FILENAME to the
function `byte-compile-dest-file' (which see).
With prefix arg (noninteractively: 2nd arg), LOAD the file after compiling.
The value is non-nil if there were no errors, nil if errors."
;; (interactive "fByte compile file: \nP")
(interactive
(let ((bytecomp-file buffer-file-name)
(bytecomp-file-name nil)
(bytecomp-file-dir nil))
(and bytecomp-file
(let ((file buffer-file-name)
(file-name nil)
(file-dir nil))
(and file
(derived-mode-p 'emacs-lisp-mode)
(setq bytecomp-file-name (file-name-nondirectory bytecomp-file)
bytecomp-file-dir (file-name-directory bytecomp-file)))
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name (if current-prefix-arg
"Byte compile and load file: "
"Byte compile file: ")
bytecomp-file-dir bytecomp-file-name nil)
file-dir file-name nil)
current-prefix-arg)))
;; Expand now so we get the current buffer's defaults
(setq bytecomp-filename (expand-file-name bytecomp-filename))
(setq filename (expand-file-name filename))
;; If we're compiling a file that's in a buffer and is modified, offer
;; to save it first.
(or noninteractive
(let ((b (get-file-buffer (expand-file-name bytecomp-filename))))
(let ((b (get-file-buffer (expand-file-name filename))))
(if (and b (buffer-modified-p b)
(y-or-n-p (format "Save buffer %s first? " (buffer-name b))))
(with-current-buffer b (save-buffer)))))
;; Force logging of the file name for each file compiled.
(setq byte-compile-last-logged-file nil)
(let ((byte-compile-current-file bytecomp-filename)
(let ((byte-compile-current-file filename)
(byte-compile-current-group nil)
(set-auto-coding-for-load t)
target-file input-buffer output-buffer
byte-compile-dest-file)
(setq target-file (byte-compile-dest-file bytecomp-filename))
(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*"))
......@@ -1762,7 +1738,7 @@ The value is non-nil if there were no errors, nil if errors."
;; Always compile an Emacs Lisp file as multibyte
;; unless the file itself forces unibyte with -*-coding: raw-text;-*-
(set-buffer-multibyte t)
(insert-file-contents bytecomp-filename)
(insert-file-contents filename)
;; Mimic the way after-insert-file-set-coding can make the
;; buffer unibyte when visiting this file.
(when (or (eq last-coding-system-used 'no-conversion)
......@@ -1772,7 +1748,7 @@ The value is non-nil if there were no errors, nil if errors."
(set-buffer-multibyte nil))
;; Run hooks including the uncompression hook.
;; If they change the file name, then change it for the output also.
(letf ((buffer-file-name bytecomp-filename)
(letf ((buffer-file-name filename)
((default-value 'major-mode) 'emacs-lisp-mode)
;; Ignore unsafe local variables.
;; We only care about a few of them for our purposes.
......@@ -1780,15 +1756,15 @@ The value is non-nil if there were no errors, nil if errors."
(enable-local-eval nil))
;; Arg of t means don't alter enable-local-variables.
(normal-mode t)
(setq bytecomp-filename buffer-file-name))
(setq filename buffer-file-name))
;; Set the default directory, in case an eval-when-compile uses it.
(setq default-directory (file-name-directory bytecomp-filename)))
(setq default-directory (file-name-directory filename)))
;; Check if the file's local variables explicitly specify not to
;; compile this file.
(if (with-current-buffer input-buffer no-byte-compile)
(progn
;; (message "%s not compiled because of `no-byte-compile: %s'"
;; (file-relative-name bytecomp-filename)
;; (file-relative-name filename)
;; (with-current-buffer input-buffer no-byte-compile))
(when (file-exists-p target-file)
(message "%s deleted because of `no-byte-compile: %s'"
......@@ -1798,7 +1774,7 @@ The value is non-nil if there were no errors, nil if errors."
;; We successfully didn't compile this file.
'no-byte-compile)
(when byte-compile-verbose
(message "Compiling %s..." bytecomp-filename))
(message "Compiling %s..." filename))
(setq byte-compiler-error-flag nil)
;; It is important that input-buffer not be current at this call,
;; so that the value of point set in input-buffer