Function: byte-recompile-file

byte-recompile-file is an interactive and byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-recompile-file FILENAME &optional FORCE ARG)

Documentation

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 FILENAME. If the prefix argument FORCE is non-nil,
however, it compiles 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 FILENAME. If optional argument ARG is 0, it compiles the input file even if the .elc file does not exist. Any other non-nil value of ARG means to ask the user.

If compilation is needed, this functions returns the result of byte-compile-file; otherwise it returns no-byte-compile.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
\;; 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 (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 FILENAME.  If the prefix argument FORCE is non-nil,
however, it compiles 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 FILENAME.  If optional argument ARG is 0, it compiles
the input file even if the `.elc' file does not exist.
Any other non-nil value of ARG means to ask the user.

If compilation is needed, this functions returns the result of
`byte-compile-file'; otherwise it returns `no-byte-compile'."
  (declare (advertised-calling-convention (filename &optional force arg) "28.1"))
  (interactive
   (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: ")
			   file-dir file-name nil)
	   current-prefix-arg)))
  (let ((dest (byte-compile-dest-file filename))
        ;; Expand now so we get the current buffer's defaults
        (filename (expand-file-name filename)))
    (prog1
        (if (if (and dest (file-exists-p dest))
                ;; File was already compiled
                ;; Compile if forced to, or filename newer
                (or force
                    (file-newer-than-file-p filename dest))
              (and arg
                   (or (eq 0 arg)
                       (y-or-n-p (concat "Compile "
                                         filename "? ")))))
            (progn
              (if (and noninteractive (not byte-compile-verbose))
                  (message "Compiling %s..." filename))
              (byte-compile-file filename))
	  'no-byte-compile)
      (when load
        (load (if (and dest (file-exists-p dest)) dest filename))))))