aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-10-11 12:57:18 +0000
committerGerd Moellmann2001-10-11 12:57:18 +0000
commitb8175fe659af7fa0b8edbe8d7756107ae92add7c (patch)
tree4bc4fbf86386252a32b08a671ed6d7f63315379d
parent13d95cc02b68115f94f8c2128f578b5b2f28e637 (diff)
downloademacs-b8175fe659af7fa0b8edbe8d7756107ae92add7c.tar.gz
emacs-b8175fe659af7fa0b8edbe8d7756107ae92add7c.zip
(byte-compile-display-log-head-p): New
function extracted from byte-compile-log-1. (byte-compile-log-1): Change output to be more in line with the output of other GNU tools. (byte-compile-warn): Emit `warning' instead of `**' for warnings. (byte-compile-report-error): Downcase error message. Use `error' instead of `!!' for error messages. (byte-compile-print-syms): Treat non-interactive case specially. (displaying-byte-compile-warnings): Use backquote. (byte-compile-from-buffer): Bind byte-compile-last-line. (batch-byte-compile): Remove `Done' message.
-rw-r--r--lisp/emacs-lisp/bytecomp.el199
1 files changed, 95 insertions, 104 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 07a26ca96dd..332a7c79504 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -10,7 +10,7 @@
10 10
11;;; This version incorporates changes up to version 2.10 of the 11;;; This version incorporates changes up to version 2.10 of the
12;;; Zawinski-Furuseth compiler. 12;;; Zawinski-Furuseth compiler.
13(defconst byte-compile-version "$Revision: 2.86 $") 13(defconst byte-compile-version "$Revision: 2.87 $")
14 14
15;; This file is part of GNU Emacs. 15;; This file is part of GNU Emacs.
16 16
@@ -813,59 +813,48 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
813(defconst byte-compile-last-warned-form nil) 813(defconst byte-compile-last-warned-form nil)
814(defconst byte-compile-last-logged-file nil) 814(defconst byte-compile-last-logged-file nil)
815 815
816(defvar byte-compile-last-line nil
817 "Last known line number in the input.")
818
819
820(defun byte-compile-display-log-head-p ()
821 (and (not (eq byte-compile-current-form :end))
822 (or (and byte-compile-current-file
823 (not (equal byte-compile-current-file
824 byte-compile-last-logged-file)))
825 (and byte-compile-last-warned-form
826 (not (eq byte-compile-current-form
827 byte-compile-last-warned-form))))))
828
829
816;; Log a message STRING in *Compile-Log*. 830;; Log a message STRING in *Compile-Log*.
817;; Also log the current function and file if not already done. 831;; Also log the current function and file if not already done.
818(defun byte-compile-log-1 (string &optional fill) 832(defun byte-compile-log-1 (string &optional fill)
819 (cond (noninteractive 833 (let* ((file (cond ((stringp byte-compile-current-file)
820 (if (or (and byte-compile-current-file 834 (format "%s:" byte-compile-current-file))
821 (not (equal byte-compile-current-file 835 ((bufferp byte-compile-current-file)
822 byte-compile-last-logged-file))) 836 (format "Buffer %s:"
823 (and byte-compile-last-warned-form 837 (buffer-name byte-compile-current-file)))
824 (not (eq byte-compile-current-form 838 (t "")))
825 byte-compile-last-warned-form)))) 839 (pos (if (and byte-compile-current-file
826 (message "While compiling %s%s:" 840 (integerp byte-compile-last-line))
827 (or byte-compile-current-form "toplevel forms") 841 (format "%d:" byte-compile-last-line)
828 (if byte-compile-current-file 842 ""))
829 (if (stringp byte-compile-current-file) 843 (form (or byte-compile-current-form "toplevel form")))
830 (concat " in file " byte-compile-current-file) 844 (cond (noninteractive
831 (concat " in buffer " 845 (when (byte-compile-display-log-head-p)
832 (buffer-name byte-compile-current-file))) 846 (message "%s In %s" file form))
833 ""))) 847 (message "%s%s %s" file pos string))
834 (message " %s" string)) 848 (t
835 (t 849 (save-excursion
836 (save-excursion 850 (set-buffer (get-buffer-create "*Compile-Log*"))
837 (set-buffer (get-buffer-create "*Compile-Log*")) 851 (goto-char (point-max))
838 (goto-char (point-max)) 852 (when (byte-compile-display-log-head-p)
839 (cond ((or (and byte-compile-current-file 853 (insert (format "\nIn %s" form)))
840 (not (equal byte-compile-current-file 854 (insert (format "\n%s%s\n%s\n" file pos string))
841 byte-compile-last-logged-file))) 855 (when (and fill (not (string-match "\n" string)))
842 (and byte-compile-last-warned-form 856 (let ((fill-prefix " ") (fill-column 78))
843 (not (eq byte-compile-current-form 857 (fill-paragraph nil)))))))
844 byte-compile-last-warned-form))))
845 ;; This is redundant, since it is given at the start of the
846 ;; file, and the extra clutter gets in the way -- rms.
847 ;; (if (and byte-compile-current-file
848 ;; (not (equal byte-compile-current-file
849 ;; byte-compile-last-logged-file)))
850 ;; (insert "\n\^L\n" (current-time-string) "\n"))
851 (insert "\nWhile compiling "
852 (if byte-compile-current-form
853 (format "%s" byte-compile-current-form)
854 "toplevel forms"))
855 ;; This is redundant, since it is given at the start of the file,
856 ;; and the extra clutter gets in the way -- rms.
857 ;; (if byte-compile-current-file
858 ;; (if (stringp byte-compile-current-file)
859 ;; (insert " in file " byte-compile-current-file)
860 ;; (insert " in buffer "
861 ;; (buffer-name byte-compile-current-file))))
862 (insert ":\n")))
863 (insert " " string "\n")
864 (if (and fill (not (string-match "\n" string)))
865 (let ((fill-prefix " ")
866 (fill-column 78))
867 (fill-paragraph nil)))
868 )))
869 (setq byte-compile-last-logged-file byte-compile-current-file 858 (setq byte-compile-last-logged-file byte-compile-current-file
870 byte-compile-last-warned-form byte-compile-current-form)) 859 byte-compile-last-warned-form byte-compile-current-form))
871 860
@@ -889,7 +878,7 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
889 (setq format (apply 'format format args)) 878 (setq format (apply 'format format args))
890 (if byte-compile-error-on-warn 879 (if byte-compile-error-on-warn
891 (error "%s" format) ; byte-compile-file catches and logs it 880 (error "%s" format) ; byte-compile-file catches and logs it
892 (byte-compile-log-1 (concat "** " format) t) 881 (byte-compile-log-1 (concat "warning: " format) t)
893 ;; It is useless to flash warnings too fast to be read. 882 ;; It is useless to flash warnings too fast to be read.
894 ;; Besides, they will all be shown at the end. 883 ;; Besides, they will all be shown at the end.
895 ;; (or noninteractive ; already written on stdout. 884 ;; (or noninteractive ; already written on stdout.
@@ -901,9 +890,9 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
901(defun byte-compile-report-error (error-info) 890(defun byte-compile-report-error (error-info)
902 (setq byte-compiler-error-flag t) 891 (setq byte-compiler-error-flag t)
903 (byte-compile-log-1 892 (byte-compile-log-1
904 (concat "!! " 893 (concat "error: "
905 (format (if (cdr error-info) "%s (%s)" "%s") 894 (format (if (cdr error-info) "%s (%s)" "%s")
906 (get (car error-info) 'error-message) 895 (downcase (get (car error-info) 'error-message))
907 (prin1-to-string (cdr error-info)))))) 896 (prin1-to-string (cdr error-info))))))
908 897
909;;; Used by make-obsolete. 898;;; Used by make-obsolete.
@@ -1127,28 +1116,32 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
1127 ))) 1116 )))
1128 1117
1129(defun byte-compile-print-syms (str1 strn syms) 1118(defun byte-compile-print-syms (str1 strn syms)
1130 (cond 1119 (cond ((and (cdr syms) (not noninteractive))
1131 ((cdr syms) 1120 (let* ((str strn)
1132 (let* ((str strn) 1121 (L (length str))
1133 (L (length str)) 1122 s)
1134 s) 1123 (while syms
1135 (while syms 1124 (setq s (symbol-name (pop syms))
1136 (setq s (symbol-name (pop syms)) 1125 L (+ L (length s) 2))
1137 L (+ L (length s) 2)) 1126 (if (< L (1- fill-column))
1138 (if (< L (1- fill-column)) 1127 (setq str (concat str " " s (and syms ",")))
1139 (setq str (concat str " " s (and syms ","))) 1128 (setq str (concat str "\n " s (and syms ","))
1140 (setq str (concat str "\n " s (and syms ",")) 1129 L (+ (length s) 4))))
1141 L (+ (length s) 4)))) 1130 (byte-compile-warn "%s" str)))
1142 (byte-compile-warn "%s" str))) 1131 ((cdr syms)
1143 (syms 1132 (byte-compile-warn "%s %s"
1144 (byte-compile-warn str1 (car syms))))) 1133 strn
1134 (mapconcat #'symbol-name syms ", ")))
1135
1136 (syms
1137 (byte-compile-warn str1 (car syms)))))
1145 1138
1146;; If we have compiled any calls to functions which are not known to be 1139;; If we have compiled any calls to functions which are not known to be
1147;; defined, issue a warning enumerating them. 1140;; defined, issue a warning enumerating them.
1148;; `unresolved' in the list `byte-compile-warnings' disables this. 1141;; `unresolved' in the list `byte-compile-warnings' disables this.
1149(defun byte-compile-warn-about-unresolved-functions () 1142(defun byte-compile-warn-about-unresolved-functions ()
1150 (when (memq 'unresolved byte-compile-warnings) 1143 (when (memq 'unresolved byte-compile-warnings)
1151 (let ((byte-compile-current-form "the end of the data") 1144 (let ((byte-compile-current-form :end)
1152 (noruntime nil) 1145 (noruntime nil)
1153 (unresolved nil)) 1146 (unresolved nil))
1154 ;; Separate the functions that will not be available at runtime 1147 ;; Separate the functions that will not be available at runtime
@@ -1158,13 +1151,13 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
1158 (if (fboundp f) (push f noruntime) (push f unresolved))) 1151 (if (fboundp f) (push f noruntime) (push f unresolved)))
1159 ;; Complain about the no-run-time functions 1152 ;; Complain about the no-run-time functions
1160 (byte-compile-print-syms 1153 (byte-compile-print-syms
1161 "The function `%s' might not be defined at runtime." 1154 "the function `%s' might not be defined at runtime."
1162 "The following functions might not be defined at runtime:" 1155 "the following functions might not be defined at runtime:"
1163 noruntime) 1156 noruntime)
1164 ;; Complain about the unresolved functions 1157 ;; Complain about the unresolved functions
1165 (byte-compile-print-syms 1158 (byte-compile-print-syms
1166 "The function `%s' is not known to be defined." 1159 "the function `%s' is not known to be defined."
1167 "The following functions are not known to be defined:" 1160 "the following functions are not known to be defined:"
1168 unresolved))) 1161 unresolved)))
1169 nil) 1162 nil)
1170 1163
@@ -1213,34 +1206,32 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property."
1213 1206
1214(defvar byte-compile-warnings-point-max nil) 1207(defvar byte-compile-warnings-point-max nil)
1215(defmacro displaying-byte-compile-warnings (&rest body) 1208(defmacro displaying-byte-compile-warnings (&rest body)
1216 (list 'let 1209 `(let ((byte-compile-warnings-point-max byte-compile-warnings-point-max))
1217 '((byte-compile-warnings-point-max byte-compile-warnings-point-max))
1218 ;; Log the file name. 1210 ;; Log the file name.
1219 '(byte-compile-log-file) 1211 (byte-compile-log-file)
1220 ;; Record how much is logged now. 1212 ;; Record how much is logged now.
1221 ;; We will display the log buffer if anything more is logged 1213 ;; We will display the log buffer if anything more is logged
1222 ;; before the end of BODY. 1214 ;; before the end of BODY.
1223 '(or byte-compile-warnings-point-max 1215 (unless byte-compile-warnings-point-max
1224 (save-excursion 1216 (save-excursion
1225 (set-buffer (get-buffer-create "*Compile-Log*")) 1217 (set-buffer (get-buffer-create "*Compile-Log*"))
1226 (setq byte-compile-warnings-point-max (point-max)))) 1218 (setq byte-compile-warnings-point-max (point-max))))
1227 (list 'unwind-protect 1219 (unwind-protect
1228 (list 'condition-case 'error-info 1220 (condition-case error-info
1229 (cons 'progn body) 1221 (progn ,@body)
1230 '(error 1222 (error (byte-compile-report-error error-info)))
1231 (byte-compile-report-error error-info))) 1223 (save-excursion
1232 '(save-excursion 1224 ;; If there were compilation warnings, display them.
1233 ;; If there were compilation warnings, display them. 1225 (set-buffer "*Compile-Log*")
1234 (set-buffer "*Compile-Log*") 1226 (if (= byte-compile-warnings-point-max (point-max))
1235 (if (= byte-compile-warnings-point-max (point-max)) 1227 nil
1236 nil 1228 (select-window
1237 (select-window 1229 (prog1 (selected-window)
1238 (prog1 (selected-window) 1230 (select-window (display-buffer (current-buffer)))
1239 (select-window (display-buffer (current-buffer))) 1231 (goto-char byte-compile-warnings-point-max)
1240 (goto-char byte-compile-warnings-point-max) 1232 (beginning-of-line)
1241 (beginning-of-line) 1233 (forward-line -1)
1242 (forward-line -1) 1234 (recenter 0))))))))
1243 (recenter 0))))))))
1244 1235
1245 1236
1246;;;###autoload 1237;;;###autoload
@@ -1537,7 +1528,8 @@ With argument, insert value in current buffer after the form."
1537 (looking-at ";")) 1528 (looking-at ";"))
1538 (forward-line 1)) 1529 (forward-line 1))
1539 (not (eobp))) 1530 (not (eobp)))
1540 (byte-compile-file-form (read inbuffer))) 1531 (let ((byte-compile-last-line (count-lines (point-min) (point))))
1532 (byte-compile-file-form (read inbuffer))))
1541 1533
1542 ;; Compile pending forms at end of file. 1534 ;; Compile pending forms at end of file.
1543 (byte-compile-flush-pending) 1535 (byte-compile-flush-pending)
@@ -1971,7 +1963,7 @@ list that represents a doc string reference.
1971 (symbolp (car-safe (cdr-safe body))) 1963 (symbolp (car-safe (cdr-safe body)))
1972 (car-safe (cdr-safe body)) 1964 (car-safe (cdr-safe body))
1973 (stringp (car-safe (cdr-safe (cdr-safe body))))) 1965 (stringp (car-safe (cdr-safe (cdr-safe body)))))
1974 (byte-compile-warn "Probable `\"' without `\\' in doc string of %s" 1966 (byte-compile-warn "probable `\"' without `\\' in doc string of %s"
1975 (nth 1 form)))) 1967 (nth 1 form))))
1976 (let* ((new-one (byte-compile-lambda (cons 'lambda (nthcdr 2 form)))) 1968 (let* ((new-one (byte-compile-lambda (cons 'lambda (nthcdr 2 form))))
1977 (code (byte-compile-byte-code-maker new-one))) 1969 (code (byte-compile-byte-code-maker new-one)))
@@ -2410,8 +2402,8 @@ If FORM is a lambda or a macro, byte-compile it as a function."
2410(defun byte-compile-variable-ref (base-op var) 2402(defun byte-compile-variable-ref (base-op var)
2411 (if (or (not (symbolp var)) (byte-compile-const-symbol-p var)) 2403 (if (or (not (symbolp var)) (byte-compile-const-symbol-p var))
2412 (byte-compile-warn (if (eq base-op 'byte-varbind) 2404 (byte-compile-warn (if (eq base-op 'byte-varbind)
2413 "Attempt to let-bind %s %s" 2405 "attempt to let-bind %s %s"
2414 "Variable reference to %s %s") 2406 "variable reference to %s %s")
2415 (if (symbolp var) "constant" "nonvariable") 2407 (if (symbolp var) "constant" "nonvariable")
2416 (prin1-to-string var)) 2408 (prin1-to-string var))
2417 (if (and (get var 'byte-obsolete-variable) 2409 (if (and (get var 'byte-obsolete-variable)
@@ -3264,7 +3256,7 @@ If FORM is a lambda or a macro, byte-compile it as a function."
3264 `(push ',var current-load-list)) 3256 `(push ',var current-load-list))
3265 (when (> (length form) 3) 3257 (when (> (length form) 3)
3266 (when (and string (not (stringp string))) 3258 (when (and string (not (stringp string)))
3267 (byte-compile-warn "Third arg to %s %s is not a string: %s" 3259 (byte-compile-warn "third arg to %s %s is not a string: %s"
3268 fun var string)) 3260 fun var string))
3269 `(put ',var 'variable-documentation ,string)) 3261 `(put ',var 'variable-documentation ,string))
3270 (if (cdr (cdr form)) ; `value' provided 3262 (if (cdr (cdr form)) ; `value' provided
@@ -3550,7 +3542,6 @@ For example, invoke \"emacs -batch -f batch-byte-compile $emacs/ ~/*.el\""
3550 (if (null (batch-byte-compile-file (car command-line-args-left))) 3542 (if (null (batch-byte-compile-file (car command-line-args-left)))
3551 (setq error t))) 3543 (setq error t)))
3552 (setq command-line-args-left (cdr command-line-args-left))) 3544 (setq command-line-args-left (cdr command-line-args-left)))
3553 (message "Done")
3554 (kill-emacs (if error 1 0)))) 3545 (kill-emacs (if error 1 0))))
3555 3546
3556(defun batch-byte-compile-file (file) 3547(defun batch-byte-compile-file (file)