comparison lisp/emacs-lisp/bytecomp.el @ 83635:9c01792a3ce8

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 793-802) - Update from CVS - Remove RCS keywords - Merge from emacs--rel--22 * emacs--rel--22 (patch 42-50) - Update from CVS - Merge from gnus--rel--5.10 - Gnus ChangeLog tweaks * gnus--rel--5.10 (patch 229-232) - Merge from emacs--devo--0, emacs--rel--22 - ChangeLog tweak - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-23
author Miles Bader <miles@gnu.org>
date Sat, 16 Jun 2007 22:33:42 +0000
parents 9445d2ed7385
children 917d8d46f0bb 3619e7770f2e
comparison
equal deleted inserted replaced
83634:391cce03f832 83635:9c01792a3ce8
851 (when (and (symbolp s) (not (memq s old-autoloads))) 851 (when (and (symbolp s) (not (memq s old-autoloads)))
852 (push s byte-compile-noruntime-functions)) 852 (push s byte-compile-noruntime-functions))
853 (when (and (consp s) (eq t (car s))) 853 (when (and (consp s) (eq t (car s)))
854 (push (cdr s) old-autoloads))))))) 854 (push (cdr s) old-autoloads)))))))
855 (when (memq 'cl-functions byte-compile-warnings) 855 (when (memq 'cl-functions byte-compile-warnings)
856 (let ((hist-new load-history) 856 (let ((hist-new load-history))
857 (hist-nil-new current-load-list))
858 ;; Go through load-history, look for newly loaded files 857 ;; Go through load-history, look for newly loaded files
859 ;; and mark all the functions defined therein. 858 ;; and mark all the functions defined therein.
860 (while (and hist-new (not (eq hist-new hist-orig))) 859 (while (and hist-new (not (eq hist-new hist-orig)))
861 (let ((xs (pop hist-new)) 860 (let ((xs (pop hist-new)))
862 old-autoloads)
863 ;; Make sure the file was not already loaded before. 861 ;; Make sure the file was not already loaded before.
864 (when (and (equal (car xs) "cl") (not (assoc (car xs) hist-orig))) 862 (when (and (equal (car xs) "cl") (not (assoc (car xs) hist-orig)))
865 (byte-compile-find-cl-functions))))))))) 863 (byte-compile-find-cl-functions)))))))))
866 864
867 (defun byte-compile-eval-before-compile (form) 865 (defun byte-compile-eval-before-compile (form)
1263 (when (and (symbolp (car form)) 1261 (when (and (symbolp (car form))
1264 (stringp (nth 1 form)) 1262 (stringp (nth 1 form))
1265 (get (car form) 'byte-compile-format-like)) 1263 (get (car form) 'byte-compile-format-like))
1266 (let ((nfields (with-temp-buffer 1264 (let ((nfields (with-temp-buffer
1267 (insert (nth 1 form)) 1265 (insert (nth 1 form))
1268 (goto-char 1) 1266 (goto-char (point-min))
1269 (let ((n 0)) 1267 (let ((n 0))
1270 (while (re-search-forward "%." nil t) 1268 (while (re-search-forward "%." nil t)
1271 (unless (eq ?% (char-after (1+ (match-beginning 0)))) 1269 (unless (eq ?% (char-after (1+ (match-beginning 0))))
1272 (setq n (1+ n)))) 1270 (setq n (1+ n))))
1273 n))) 1271 n)))
1281 (put elt 'byte-compile-format-like t)) 1279 (put elt 'byte-compile-format-like t))
1282 1280
1283 ;; Warn if a custom definition fails to specify :group. 1281 ;; Warn if a custom definition fails to specify :group.
1284 (defun byte-compile-nogroup-warn (form) 1282 (defun byte-compile-nogroup-warn (form)
1285 (let ((keyword-args (cdr (cdr (cdr (cdr form))))) 1283 (let ((keyword-args (cdr (cdr (cdr (cdr form)))))
1286 (name (cadr form))) 1284 (name (cadr form)))
1287 (or (not (eq (car-safe name) 'quote)) 1285 (or (not (eq (car-safe name) 'quote))
1288 (and (eq (car form) 'custom-declare-group) 1286 (and (eq (car form) 'custom-declare-group)
1289 (equal name ''emacs)) 1287 (equal name ''emacs))
1290 (plist-get keyword-args :group) 1288 (plist-get keyword-args :group)
1291 (not (and (consp name) (eq (car name) 'quote))) 1289 (not (and (consp name) (eq (car name) 'quote)))
1292 (byte-compile-warn 1290 (byte-compile-warn
1293 "%s for `%s' fails to specify containing group" 1291 "%s for `%s' fails to specify containing group"
1294 (cdr (assq (car form) 1292 (cdr (assq (car form)
1295 '((custom-declare-group . defgroup) 1293 '((custom-declare-group . defgroup)
1296 (custom-declare-face . defface) 1294 (custom-declare-face . defface)
1297 (custom-declare-variable . defcustom)))) 1295 (custom-declare-variable . defcustom))))
1298 (cadr name))))) 1296 (cadr name)))))
1299 1297
1300 ;; Warn if the function or macro is being redefined with a different 1298 ;; Warn if the function or macro is being redefined with a different
1301 ;; number of arguments. 1299 ;; number of arguments.
1302 (defun byte-compile-arglist-warn (form macrop) 1300 (defun byte-compile-arglist-warn (form macrop)
1303 (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) 1301 (let ((old (byte-compile-fdefinition (nth 1 form) macrop)))
1832 ;; (byte-compile-warnings (if (eq byte-compile-warnings t) 1830 ;; (byte-compile-warnings (if (eq byte-compile-warnings t)
1833 ;; byte-compile-warning-types 1831 ;; byte-compile-warning-types
1834 ;; byte-compile-warnings)) 1832 ;; byte-compile-warnings))
1835 ) 1833 )
1836 (byte-compile-close-variables 1834 (byte-compile-close-variables
1837 (save-excursion 1835 (with-current-buffer
1838 (setq outbuffer 1836 (setq outbuffer (get-buffer-create " *Compiler Output*"))
1839 (set-buffer (get-buffer-create " *Compiler Output*")))
1840 (set-buffer-multibyte t) 1837 (set-buffer-multibyte t)
1841 (erase-buffer) 1838 (erase-buffer)
1842 ;; (emacs-lisp-mode) 1839 ;; (emacs-lisp-mode)
1843 (setq case-fold-search nil) 1840 (setq case-fold-search nil)
1844 ;; This is a kludge. Some operating systems (OS/2, DOS) need to 1841 ;; This is a kludge. Some operating systems (OS/2, DOS) need to
1848 ;; they should write their data. Advise them that .elc files 1845 ;; they should write their data. Advise them that .elc files
1849 ;; need to be written carefully. 1846 ;; need to be written carefully.
1850 (setq overwrite-mode 'overwrite-mode-binary)) 1847 (setq overwrite-mode 'overwrite-mode-binary))
1851 (displaying-byte-compile-warnings 1848 (displaying-byte-compile-warnings
1852 (and filename (byte-compile-insert-header filename inbuffer outbuffer)) 1849 (and filename (byte-compile-insert-header filename inbuffer outbuffer))
1853 (save-excursion 1850 (with-current-buffer inbuffer
1854 (set-buffer inbuffer) 1851 (goto-char (point-min))
1855 (goto-char 1)
1856 1852
1857 ;; Compile the forms from the input buffer. 1853 ;; Compile the forms from the input buffer.
1858 (while (progn 1854 (while (progn
1859 (while (progn (skip-chars-forward " \t\n\^l") 1855 (while (progn (skip-chars-forward " \t\n\^l")
1860 (looking-at ";")) 1856 (looking-at ";"))
1918 (defun byte-compile-insert-header (filename inbuffer outbuffer) 1914 (defun byte-compile-insert-header (filename inbuffer outbuffer)
1919 (set-buffer inbuffer) 1915 (set-buffer inbuffer)
1920 (let ((dynamic-docstrings byte-compile-dynamic-docstrings) 1916 (let ((dynamic-docstrings byte-compile-dynamic-docstrings)
1921 (dynamic byte-compile-dynamic)) 1917 (dynamic byte-compile-dynamic))
1922 (set-buffer outbuffer) 1918 (set-buffer outbuffer)
1923 (goto-char 1) 1919 (goto-char (point-min))
1924 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After 1920 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After
1925 ;; that is the file-format version number (18, 19 or 20) as a 1921 ;; that is the file-format version number (18, 19 or 20) as a
1926 ;; byte, followed by some nulls. The primary motivation for doing 1922 ;; byte, followed by some nulls. The primary motivation for doing
1927 ;; this is to get some binary characters up in the first line of 1923 ;; this is to get some binary characters up in the first line of
1928 ;; the file so that `diff' will simply say "Binary files differ" 1924 ;; the file so that `diff' will simply say "Binary files differ"
2239 (setq tail (cdr tail)))) 2235 (setq tail (cdr tail))))
2240 form) 2236 form)
2241 2237
2242 (put 'require 'byte-hunk-handler 'byte-compile-file-form-require) 2238 (put 'require 'byte-hunk-handler 'byte-compile-file-form-require)
2243 (defun byte-compile-file-form-require (form) 2239 (defun byte-compile-file-form-require (form)
2244 (let ((old-load-list current-load-list) 2240 (let ((args (mapcar 'eval (cdr form))))
2245 (args (mapcar 'eval (cdr form))))
2246 (apply 'require args) 2241 (apply 'require args)
2247 ;; Detect (require 'cl) in a way that works even if cl is already loaded. 2242 ;; Detect (require 'cl) in a way that works even if cl is already loaded.
2248 (if (member (car args) '("cl" cl)) 2243 (if (member (car args) '("cl" cl))
2249 (setq byte-compile-warnings 2244 (setq byte-compile-warnings
2250 (remq 'cl-functions byte-compile-warnings)))) 2245 (remq 'cl-functions byte-compile-warnings))))