Mercurial > emacs
comparison lisp/emacs-lisp/bytecomp.el @ 95642:1b0cbcea87b2
(byte-compile-current-group): New var.
(byte-compile-file): Initialize it.
(byte-compile-nogroup-warn): Keep track of the current group.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 08 Jun 2008 02:07:25 +0000 |
parents | 90a2847062be |
children | 2169bb17fe3d |
comparison
equal
deleted
inserted
replaced
95641:23bdf2b1013d | 95642:1b0cbcea87b2 |
---|---|
922 ;;; byte compiler messages | 922 ;;; byte compiler messages |
923 | 923 |
924 (defvar byte-compile-current-form nil) | 924 (defvar byte-compile-current-form nil) |
925 (defvar byte-compile-dest-file nil) | 925 (defvar byte-compile-dest-file nil) |
926 (defvar byte-compile-current-file nil) | 926 (defvar byte-compile-current-file nil) |
927 (defvar byte-compile-current-group nil) | |
927 (defvar byte-compile-current-buffer nil) | 928 (defvar byte-compile-current-buffer nil) |
928 | 929 |
929 ;; Log something that isn't a warning. | 930 ;; Log something that isn't a warning. |
930 (defmacro byte-compile-log (format-string &rest args) | 931 (defmacro byte-compile-log (format-string &rest args) |
931 `(and | 932 `(and |
1333 (dolist (elt '(format message error)) | 1334 (dolist (elt '(format message error)) |
1334 (put elt 'byte-compile-format-like t)) | 1335 (put elt 'byte-compile-format-like t)) |
1335 | 1336 |
1336 ;; Warn if a custom definition fails to specify :group. | 1337 ;; Warn if a custom definition fails to specify :group. |
1337 (defun byte-compile-nogroup-warn (form) | 1338 (defun byte-compile-nogroup-warn (form) |
1338 (let ((keyword-args (cdr (cdr (cdr (cdr form))))) | 1339 (if (and (memq (car form) '(custom-declare-face custom-declare-variable)) |
1339 (name (cadr form))) | 1340 byte-compile-current-group) |
1340 (or (not (eq (car-safe name) 'quote)) | 1341 ;; The group will be provided implicitly. |
1342 nil | |
1343 (let ((keyword-args (cdr (cdr (cdr (cdr form))))) | |
1344 (name (cadr form))) | |
1345 (or (not (eq (car-safe name) 'quote)) | |
1341 (and (eq (car form) 'custom-declare-group) | 1346 (and (eq (car form) 'custom-declare-group) |
1342 (equal name ''emacs)) | 1347 (equal name ''emacs)) |
1343 (plist-get keyword-args :group) | 1348 (plist-get keyword-args :group) |
1344 (not (and (consp name) (eq (car name) 'quote))) | 1349 (not (and (consp name) (eq (car name) 'quote))) |
1345 (byte-compile-warn | 1350 (byte-compile-warn |
1346 "%s for `%s' fails to specify containing group" | 1351 "%s for `%s' fails to specify containing group" |
1347 (cdr (assq (car form) | 1352 (cdr (assq (car form) |
1348 '((custom-declare-group . defgroup) | 1353 '((custom-declare-group . defgroup) |
1349 (custom-declare-face . defface) | 1354 (custom-declare-face . defface) |
1350 (custom-declare-variable . defcustom)))) | 1355 (custom-declare-variable . defcustom)))) |
1351 (cadr name))))) | 1356 (cadr name))) |
1357 ;; Update the current group, if needed. | |
1358 (if (and byte-compile-current-file ;Only when byte-compiling a whole file. | |
1359 (eq (car form) 'custom-declare-group) | |
1360 (eq (car-safe name) 'quote)) | |
1361 (setq byte-compile-current-group (cadr name)))))) | |
1352 | 1362 |
1353 ;; Warn if the function or macro is being redefined with a different | 1363 ;; Warn if the function or macro is being redefined with a different |
1354 ;; number of arguments. | 1364 ;; number of arguments. |
1355 (defun byte-compile-arglist-warn (form macrop) | 1365 (defun byte-compile-arglist-warn (form macrop) |
1356 (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) | 1366 (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) |
1711 (with-current-buffer b (save-buffer))))) | 1721 (with-current-buffer b (save-buffer))))) |
1712 | 1722 |
1713 ;; Force logging of the file name for each file compiled. | 1723 ;; Force logging of the file name for each file compiled. |
1714 (setq byte-compile-last-logged-file nil) | 1724 (setq byte-compile-last-logged-file nil) |
1715 (let ((byte-compile-current-file bytecomp-filename) | 1725 (let ((byte-compile-current-file bytecomp-filename) |
1726 (byte-compile-current-group nil) | |
1716 (set-auto-coding-for-load t) | 1727 (set-auto-coding-for-load t) |
1717 target-file input-buffer output-buffer | 1728 target-file input-buffer output-buffer |
1718 byte-compile-dest-file) | 1729 byte-compile-dest-file) |
1719 (setq target-file (byte-compile-dest-file bytecomp-filename)) | 1730 (setq target-file (byte-compile-dest-file bytecomp-filename)) |
1720 (setq byte-compile-dest-file target-file) | 1731 (setq byte-compile-dest-file target-file) |