diff options
| author | Richard M. Stallman | 2004-01-29 17:58:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-01-29 17:58:16 +0000 |
| commit | ab43c85050514d20dff26eeec448a8970d3a0f53 (patch) | |
| tree | 773315eab70059005e892b7237b6048f66d1c108 | |
| parent | 750e563f99c53f42392134c78148ca61bbc968c7 (diff) | |
| download | emacs-ab43c85050514d20dff26eeec448a8970d3a0f53.tar.gz emacs-ab43c85050514d20dff26eeec448a8970d3a0f53.zip | |
(byte-compile-compatibility): Doc fix.
(byte-compile-format-warn): New.
(byte-compile-callargs-warn): Use it.
(Format, message, error): Add byte-compile-format-like property.
(byte-compile-maybe-guarded): New.
(byte-compile-if, byte-compile-cond): Use it.
(byte-compile-lambda): Compile interactive forms, just to make
warnings about them.
| -rw-r--r-- | lisp/ChangeLog | 28 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 148 |
2 files changed, 123 insertions, 53 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e12a9b4ee9c..c3e98e8cd11 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,31 @@ | |||
| 1 | 2004-01-29 Tue Jari Aalto <jari.aalto <AT> poboxes.com> | ||
| 2 | |||
| 3 | * progmodes/executable.el (executable-command-find-posix-p): | ||
| 4 | New. Check if find handles arguments Posix-style. | ||
| 5 | |||
| 6 | * progmodes/grep.el (grep-compute-defaults): | ||
| 7 | Use executable-command-find-posix-p. | ||
| 8 | (grep-find): Check `grep-find-command'. | ||
| 9 | |||
| 10 | * filecache.el (file-cache-find-posix-p): Deleted. | ||
| 11 | (file-cache-add-directory-using-find): | ||
| 12 | Use `executable-command-find-posix-p' | ||
| 13 | |||
| 14 | 2004-01-29 Dave Love <fx@gnu.org> | ||
| 15 | |||
| 16 | * emacs-lisp/lisp.el (beginning-of-defun-raw, end-of-defun): | ||
| 17 | Iterate the hook function if arg is given. | ||
| 18 | (mark-defun, narrow-to-defun): Change order of finding the limits. | ||
| 19 | |||
| 20 | * emacs-lisp/bytecomp.el (byte-compile-compatibility): Doc fix. | ||
| 21 | (byte-compile-format-warn): New. | ||
| 22 | (byte-compile-callargs-warn): Use it. | ||
| 23 | (Format, message, error): Add byte-compile-format-like property. | ||
| 24 | (byte-compile-maybe-guarded): New. | ||
| 25 | (byte-compile-if, byte-compile-cond): Use it. | ||
| 26 | (byte-compile-lambda): Compile interactive forms, | ||
| 27 | just to make warnings about them. | ||
| 28 | |||
| 1 | 2004-01-29 Jonathan Yavner <jyavner@member.fsf.org> | 29 | 2004-01-29 Jonathan Yavner <jyavner@member.fsf.org> |
| 2 | 30 | ||
| 3 | * ses.el (ses-initial-column-width): Increase to 14, so it will | 31 | * ses.el (ses-initial-column-width): Increase to 14, so it will |
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index d4949f94aa6..a1ce848d9d7 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.140 $") | 13 | (defconst byte-compile-version "$Revision: 2.141 $") |
| 14 | 14 | ||
| 15 | ;; This file is part of GNU Emacs. | 15 | ;; This file is part of GNU Emacs. |
| 16 | 16 | ||
| @@ -251,7 +251,9 @@ if you change this variable." | |||
| 251 | :type 'boolean) | 251 | :type 'boolean) |
| 252 | 252 | ||
| 253 | (defcustom byte-compile-compatibility nil | 253 | (defcustom byte-compile-compatibility nil |
| 254 | "*Non-nil means generate output that can run in Emacs 18." | 254 | "*Non-nil means generate output that can run in Emacs 18. |
| 255 | This only means that it can run in principle, if it doesn't require | ||
| 256 | facilities that have been added more recently." | ||
| 255 | :group 'bytecomp | 257 | :group 'bytecomp |
| 256 | :type 'boolean) | 258 | :type 'boolean) |
| 257 | 259 | ||
| @@ -444,6 +446,11 @@ Each element looks like (FUNCTIONNAME . DEFINITION). It is | |||
| 444 | Used for warnings when the function is not known to be defined or is later | 446 | Used for warnings when the function is not known to be defined or is later |
| 445 | defined with incorrect args.") | 447 | defined with incorrect args.") |
| 446 | 448 | ||
| 449 | (defvar byte-compile-noruntime-functions nil | ||
| 450 | "Alist of functions called that may not be defined when the compiled code is run. | ||
| 451 | Used for warnings about calling a function that is defined during compilation | ||
| 452 | but won't necessarily be defined when the compiled file is loaded.") | ||
| 453 | |||
| 447 | (defvar byte-compile-tag-number 0) | 454 | (defvar byte-compile-tag-number 0) |
| 448 | (defvar byte-compile-output nil | 455 | (defvar byte-compile-output nil |
| 449 | "Alist describing contents to put in byte code string. | 456 | "Alist describing contents to put in byte code string. |
| @@ -776,7 +783,7 @@ otherwise pop it") | |||
| 776 | 783 | ||
| 777 | (defun byte-compile-eval (form) | 784 | (defun byte-compile-eval (form) |
| 778 | "Eval FORM and mark the functions defined therein. | 785 | "Eval FORM and mark the functions defined therein. |
| 779 | Each function's symbol gets marked with the `byte-compile-noruntime' property." | 786 | Each function's symbol gets added to `byte-compile-noruntime-functions'." |
| 780 | (let ((hist-orig load-history) | 787 | (let ((hist-orig load-history) |
| 781 | (hist-nil-orig current-load-list)) | 788 | (hist-nil-orig current-load-list)) |
| 782 | (prog1 (eval form) | 789 | (prog1 (eval form) |
| @@ -794,17 +801,17 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property." | |||
| 794 | (cond | 801 | (cond |
| 795 | ((symbolp s) | 802 | ((symbolp s) |
| 796 | (unless (memq s old-autoloads) | 803 | (unless (memq s old-autoloads) |
| 797 | (put s 'byte-compile-noruntime t))) | 804 | (push s byte-compile-noruntime-functions))) |
| 798 | ((and (consp s) (eq t (car s))) | 805 | ((and (consp s) (eq t (car s))) |
| 799 | (push (cdr s) old-autoloads)) | 806 | (push (cdr s) old-autoloads)) |
| 800 | ((and (consp s) (eq 'autoload (car s))) | 807 | ((and (consp s) (eq 'autoload (car s))) |
| 801 | (put (cdr s) 'byte-compile-noruntime t))))))) | 808 | (push (cdr s) byte-compile-noruntime-functions))))))) |
| 802 | ;; Go through current-load-list for the locally defined funs. | 809 | ;; Go through current-load-list for the locally defined funs. |
| 803 | (let (old-autoloads) | 810 | (let (old-autoloads) |
| 804 | (while (and hist-nil-new (not (eq hist-nil-new hist-nil-orig))) | 811 | (while (and hist-nil-new (not (eq hist-nil-new hist-nil-orig))) |
| 805 | (let ((s (pop hist-nil-new))) | 812 | (let ((s (pop hist-nil-new))) |
| 806 | (when (and (symbolp s) (not (memq s old-autoloads))) | 813 | (when (and (symbolp s) (not (memq s old-autoloads))) |
| 807 | (put s 'byte-compile-noruntime t)) | 814 | (push s byte-compile-noruntime-functions)) |
| 808 | (when (and (consp s) (eq t (car s))) | 815 | (when (and (consp s) (eq t (car s))) |
| 809 | (push (cdr s) old-autoloads)))))))))) | 816 | (push (cdr s) old-autoloads)))))))))) |
| 810 | 817 | ||
| @@ -1170,10 +1177,11 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property." | |||
| 1170 | "requires" | 1177 | "requires" |
| 1171 | "accepts only") | 1178 | "accepts only") |
| 1172 | (byte-compile-arglist-signature-string sig)))) | 1179 | (byte-compile-arglist-signature-string sig)))) |
| 1180 | (byte-compile-format-warn form) | ||
| 1173 | ;; Check to see if the function will be available at runtime | 1181 | ;; Check to see if the function will be available at runtime |
| 1174 | ;; and/or remember its arity if it's unknown. | 1182 | ;; and/or remember its arity if it's unknown. |
| 1175 | (or (and (or sig (fboundp (car form))) ; might be a subr or autoload. | 1183 | (or (and (or sig (fboundp (car form))) ; might be a subr or autoload. |
| 1176 | (not (get (car form) 'byte-compile-noruntime))) | 1184 | (not (memq (car form) byte-compile-noruntime-functions))) |
| 1177 | (eq (car form) byte-compile-current-form) ; ## this doesn't work | 1185 | (eq (car form) byte-compile-current-form) ; ## this doesn't work |
| 1178 | ; with recursion. | 1186 | ; with recursion. |
| 1179 | ;; It's a currently-undefined function. | 1187 | ;; It's a currently-undefined function. |
| @@ -1187,6 +1195,32 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property." | |||
| 1187 | (cons (list (car form) n) | 1195 | (cons (list (car form) n) |
| 1188 | byte-compile-unresolved-functions))))))) | 1196 | byte-compile-unresolved-functions))))))) |
| 1189 | 1197 | ||
| 1198 | (defun byte-compile-format-warn (form) | ||
| 1199 | "Warn if FORM is `format'-like with inconsistent args. | ||
| 1200 | Applies if head of FORM is a symbol with non-nil property | ||
| 1201 | `byte-compile-format-like' and first arg is a constant string. | ||
| 1202 | Then check the number of format fields matches the number of | ||
| 1203 | extra args." | ||
| 1204 | (when (and (symbolp (car form)) | ||
| 1205 | (stringp (nth 1 form)) | ||
| 1206 | (get (car form) 'byte-compile-format-like)) | ||
| 1207 | (let ((nfields (with-temp-buffer | ||
| 1208 | (insert (nth 1 form)) | ||
| 1209 | (goto-char 1) | ||
| 1210 | (let ((n 0)) | ||
| 1211 | (while (re-search-forward "%." nil t) | ||
| 1212 | (unless (eq ?% (char-after (1+ (match-beginning 0)))) | ||
| 1213 | (setq n (1+ n)))) | ||
| 1214 | n))) | ||
| 1215 | (nargs (- (length form) 2))) | ||
| 1216 | (unless (= nargs nfields) | ||
| 1217 | (byte-compile-warn | ||
| 1218 | "`%s' called with %d args to fill %d format field(s)" (car form) | ||
| 1219 | nargs nfields))))) | ||
| 1220 | |||
| 1221 | (dolist (elt '(format message error)) | ||
| 1222 | (put elt 'byte-compile-format-like t)) | ||
| 1223 | |||
| 1190 | ;; Warn if the function or macro is being redefined with a different | 1224 | ;; Warn if the function or macro is being redefined with a different |
| 1191 | ;; number of arguments. | 1225 | ;; number of arguments. |
| 1192 | (defun byte-compile-arglist-warn (form macrop) | 1226 | (defun byte-compile-arglist-warn (form macrop) |
| @@ -1254,7 +1288,7 @@ Each function's symbol gets marked with the `byte-compile-noruntime' property." | |||
| 1254 | (let ((func (car-safe form))) | 1288 | (let ((func (car-safe form))) |
| 1255 | (if (and byte-compile-cl-functions | 1289 | (if (and byte-compile-cl-functions |
| 1256 | (memq func byte-compile-cl-functions) | 1290 | (memq func byte-compile-cl-functions) |
| 1257 | ;; Aliases which won't have been expended at this point. | 1291 | ;; Aliases which won't have been expanded at this point. |
| 1258 | ;; These aren't all aliases of subrs, so not trivial to | 1292 | ;; These aren't all aliases of subrs, so not trivial to |
| 1259 | ;; avoid hardwiring the list. | 1293 | ;; avoid hardwiring the list. |
| 1260 | (not (memq func | 1294 | (not (memq func |
| @@ -2453,17 +2487,19 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2453 | (if (cdr (cdr int)) | 2487 | (if (cdr (cdr int)) |
| 2454 | (byte-compile-warn "malformed interactive spec: %s" | 2488 | (byte-compile-warn "malformed interactive spec: %s" |
| 2455 | (prin1-to-string int))) | 2489 | (prin1-to-string int))) |
| 2456 | ;; If the interactive spec is a call to `list', | 2490 | ;; If the interactive spec is a call to `list', don't |
| 2457 | ;; don't compile it, because `call-interactively' | 2491 | ;; compile it, because `call-interactively' looks at the |
| 2458 | ;; looks at the args of `list'. | 2492 | ;; args of `list'. Actually, compile it to get warnings, |
| 2493 | ;; but don't use the result. | ||
| 2459 | (let ((form (nth 1 int))) | 2494 | (let ((form (nth 1 int))) |
| 2460 | (while (memq (car-safe form) '(let let* progn save-excursion)) | 2495 | (while (memq (car-safe form) '(let let* progn save-excursion)) |
| 2461 | (while (consp (cdr form)) | 2496 | (while (consp (cdr form)) |
| 2462 | (setq form (cdr form))) | 2497 | (setq form (cdr form))) |
| 2463 | (setq form (car form))) | 2498 | (setq form (car form))) |
| 2464 | (or (eq (car-safe form) 'list) | 2499 | (if (eq (car-safe form) 'list) |
| 2465 | (setq int (list 'interactive | 2500 | (byte-compile-top-level (nth 1 int)) |
| 2466 | (byte-compile-top-level (nth 1 int))))))) | 2501 | (setq int (list 'interactive |
| 2502 | (byte-compile-top-level (nth 1 int))))))) | ||
| 2467 | ((cdr int) | 2503 | ((cdr int) |
| 2468 | (byte-compile-warn "malformed interactive spec: %s" | 2504 | (byte-compile-warn "malformed interactive spec: %s" |
| 2469 | (prin1-to-string int))))) | 2505 | (prin1-to-string int))))) |
| @@ -3265,51 +3301,55 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 3265 | (if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop)) | 3301 | (if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop)) |
| 3266 | ,tag)) | 3302 | ,tag)) |
| 3267 | 3303 | ||
| 3304 | (defmacro byte-compile-maybe-guarded (condition &rest body) | ||
| 3305 | "Execute forms in BODY, potentially guarded by CONDITION. | ||
| 3306 | CONDITION is the test in an `if' form or in a `cond' clause. | ||
| 3307 | BODY is to compile the first arm of the if or the body of the | ||
| 3308 | cond clause. If CONDITION is of the form `(foundp 'foo)' | ||
| 3309 | or `(boundp 'foo)', the relevant warnings from BODY about foo | ||
| 3310 | being undefined will be suppressed." | ||
| 3311 | (declare (indent 1) (debug t)) | ||
| 3312 | `(let* ((fbound | ||
| 3313 | (if (eq 'fboundp (car-safe ,condition)) | ||
| 3314 | (and (eq 'quote (car-safe (nth 1 ,condition))) | ||
| 3315 | ;; Ignore if the symbol is already on the | ||
| 3316 | ;; unresolved list. | ||
| 3317 | (not (assq (nth 1 (nth 1 ,condition)) ; the relevant symbol | ||
| 3318 | byte-compile-unresolved-functions)) | ||
| 3319 | (nth 1 (nth 1 ,condition))))) | ||
| 3320 | (bound (if (or (eq 'boundp (car-safe ,condition)) | ||
| 3321 | (eq 'default-boundp (car-safe ,condition))) | ||
| 3322 | (and (eq 'quote (car-safe (nth 1 ,condition))) | ||
| 3323 | (nth 1 (nth 1 ,condition))))) | ||
| 3324 | ;; Maybe add to the bound list. | ||
| 3325 | (byte-compile-bound-variables | ||
| 3326 | (if bound | ||
| 3327 | (cons bound byte-compile-bound-variables) | ||
| 3328 | byte-compile-bound-variables))) | ||
| 3329 | (progn ,@body) | ||
| 3330 | ;; Maybe remove the function symbol from the unresolved list. | ||
| 3331 | (if fbound | ||
| 3332 | (setq byte-compile-unresolved-functions | ||
| 3333 | (delq (assq fbound byte-compile-unresolved-functions) | ||
| 3334 | byte-compile-unresolved-functions))))) | ||
| 3335 | |||
| 3268 | (defun byte-compile-if (form) | 3336 | (defun byte-compile-if (form) |
| 3269 | (byte-compile-form (car (cdr form))) | 3337 | (byte-compile-form (car (cdr form))) |
| 3270 | ;; Check whether we have `(if (fboundp ...' or `(if (boundp ...' | 3338 | ;; Check whether we have `(if (fboundp ...' or `(if (boundp ...' |
| 3271 | ;; and avoid warnings about the relevent symbols in the consequent. | 3339 | ;; and avoid warnings about the relevent symbols in the consequent. |
| 3272 | (let* ((clause (nth 1 form)) | 3340 | (let ((clause (nth 1 form)) |
| 3273 | (fbound (if (eq 'fboundp (car-safe clause)) | 3341 | (donetag (byte-compile-make-tag))) |
| 3274 | (and (eq 'quote (car-safe (nth 1 clause))) | ||
| 3275 | ;; Ignore if the symbol is already on the | ||
| 3276 | ;; unresolved list. | ||
| 3277 | (not (assq | ||
| 3278 | (nth 1 (nth 1 clause)) ; the relevant symbol | ||
| 3279 | byte-compile-unresolved-functions)) | ||
| 3280 | (nth 1 (nth 1 clause))))) | ||
| 3281 | (bound (if (eq 'boundp (car-safe clause)) | ||
| 3282 | (and (eq 'quote (car-safe (nth 1 clause))) | ||
| 3283 | (nth 1 (nth 1 clause))))) | ||
| 3284 | (donetag (byte-compile-make-tag))) | ||
| 3285 | (if (null (nthcdr 3 form)) | 3342 | (if (null (nthcdr 3 form)) |
| 3286 | ;; No else-forms | 3343 | ;; No else-forms |
| 3287 | (progn | 3344 | (progn |
| 3288 | (byte-compile-goto-if nil for-effect donetag) | 3345 | (byte-compile-goto-if nil for-effect donetag) |
| 3289 | ;; Maybe add to the bound list. | 3346 | (byte-compile-maybe-guarded clause |
| 3290 | (let ((byte-compile-bound-variables | ||
| 3291 | (if bound | ||
| 3292 | (cons bound byte-compile-bound-variables) | ||
| 3293 | byte-compile-bound-variables))) | ||
| 3294 | (byte-compile-form (nth 2 form) for-effect)) | 3347 | (byte-compile-form (nth 2 form) for-effect)) |
| 3295 | ;; Maybe remove the function symbol from the unresolved list. | ||
| 3296 | (if fbound | ||
| 3297 | (setq byte-compile-unresolved-functions | ||
| 3298 | (delq (assq fbound byte-compile-unresolved-functions) | ||
| 3299 | byte-compile-unresolved-functions))) | ||
| 3300 | (byte-compile-out-tag donetag)) | 3348 | (byte-compile-out-tag donetag)) |
| 3301 | (let ((elsetag (byte-compile-make-tag))) | 3349 | (let ((elsetag (byte-compile-make-tag))) |
| 3302 | (byte-compile-goto 'byte-goto-if-nil elsetag) | 3350 | (byte-compile-goto 'byte-goto-if-nil elsetag) |
| 3303 | ;; As above for the first form. | 3351 | (byte-compile-maybe-guarded clause |
| 3304 | (let ((byte-compile-bound-variables | 3352 | (byte-compile-form (nth 2 form) for-effect)) |
| 3305 | (if bound | ||
| 3306 | (cons bound byte-compile-bound-variables) | ||
| 3307 | byte-compile-bound-variables))) | ||
| 3308 | (byte-compile-form (nth 2 form) for-effect)) | ||
| 3309 | (if fbound | ||
| 3310 | (setq byte-compile-unresolved-functions | ||
| 3311 | (delq (assq fbound byte-compile-unresolved-functions) | ||
| 3312 | byte-compile-unresolved-functions))) | ||
| 3313 | (byte-compile-goto 'byte-goto donetag) | 3353 | (byte-compile-goto 'byte-goto donetag) |
| 3314 | (byte-compile-out-tag elsetag) | 3354 | (byte-compile-out-tag elsetag) |
| 3315 | (byte-compile-body (cdr (cdr (cdr form))) for-effect) | 3355 | (byte-compile-body (cdr (cdr (cdr form))) for-effect) |
| @@ -3332,14 +3372,16 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 3332 | (if (null (cdr clause)) | 3372 | (if (null (cdr clause)) |
| 3333 | ;; First clause is a singleton. | 3373 | ;; First clause is a singleton. |
| 3334 | (byte-compile-goto-if t for-effect donetag) | 3374 | (byte-compile-goto-if t for-effect donetag) |
| 3335 | (setq nexttag (byte-compile-make-tag)) | 3375 | (setq nexttag (byte-compile-make-tag)) |
| 3336 | (byte-compile-goto 'byte-goto-if-nil nexttag) | 3376 | (byte-compile-goto 'byte-goto-if-nil nexttag) |
| 3337 | (byte-compile-body (cdr clause) for-effect) | 3377 | (byte-compile-maybe-guarded (car clause) |
| 3338 | (byte-compile-goto 'byte-goto donetag) | 3378 | (byte-compile-body (cdr clause) for-effect)) |
| 3339 | (byte-compile-out-tag nexttag))))) | 3379 | (byte-compile-goto 'byte-goto donetag) |
| 3380 | (byte-compile-out-tag nexttag))))) | ||
| 3340 | ;; Last clause | 3381 | ;; Last clause |
| 3341 | (and (cdr clause) (not (eq (car clause) t)) | 3382 | (and (cdr clause) (not (eq (car clause) t)) |
| 3342 | (progn (byte-compile-form (car clause)) | 3383 | (progn (byte-compile-maybe-guarded (car clause) |
| 3384 | (byte-compile-form (car clause))) | ||
| 3343 | (byte-compile-goto-if nil for-effect donetag) | 3385 | (byte-compile-goto-if nil for-effect donetag) |
| 3344 | (setq clause (cdr clause)))) | 3386 | (setq clause (cdr clause)))) |
| 3345 | (byte-compile-body-do-effect clause) | 3387 | (byte-compile-body-do-effect clause) |