comparison lisp/emacs-lisp/bytecomp.el @ 12823:c1fcd8660aba

(byte-compile-insert-header): Use 19.29, not 19.28.90 as limit for where dynamic docstrings are allowed. (byte-compile-insert-header): New args inbuffer and outbuffer. Test byte-compile-dynamic-docstrings in the initially current buffer. (byte-compile-from-buffer): Add new args to byte-compile-insert-header.
author Richard M. Stallman <rms@gnu.org>
date Thu, 10 Aug 1995 22:44:21 +0000
parents 913a19cf074a
children 5c76c36717cb
comparison
equal deleted inserted replaced
12822:6fb78108d62d 12823:c1fcd8660aba
1328 (setq outbuffer 1328 (setq outbuffer
1329 (set-buffer (get-buffer-create " *Compiler Output*"))) 1329 (set-buffer (get-buffer-create " *Compiler Output*")))
1330 (erase-buffer) 1330 (erase-buffer)
1331 ;; (emacs-lisp-mode) 1331 ;; (emacs-lisp-mode)
1332 (setq case-fold-search nil) 1332 (setq case-fold-search nil)
1333 (and filename (byte-compile-insert-header filename)) 1333 (and filename (byte-compile-insert-header filename inbuffer outbuffer))
1334 1334
1335 ;; This is a kludge. Some operating systems (OS/2, DOS) need to 1335 ;; This is a kludge. Some operating systems (OS/2, DOS) need to
1336 ;; write files containing binary information specially. 1336 ;; write files containing binary information specially.
1337 ;; Under most circumstances, such files will be in binary 1337 ;; Under most circumstances, such files will be in binary
1338 ;; overwrite mode, so those OS's use that flag to guess how 1338 ;; overwrite mode, so those OS's use that flag to guess how
1359 ;; would be useful to delay this warning until all have 1359 ;; would be useful to delay this warning until all have
1360 ;; been compiled. 1360 ;; been compiled.
1361 (setq byte-compile-unresolved-functions nil)))) 1361 (setq byte-compile-unresolved-functions nil))))
1362 outbuffer)) 1362 outbuffer))
1363 1363
1364 (defun byte-compile-insert-header (filename) 1364 (defun byte-compile-insert-header (filename inbuffer outbuffer)
1365 (set-buffer outbuffer) 1365 (set-buffer inbuffer)
1366 (goto-char 1) 1366 (let ((dynamic-docstrings byte-compile-dynamic-docstrings))
1367 ;; 1367 (set-buffer outbuffer)
1368 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After that is 1368 (goto-char 1)
1369 ;; the file-format version number (18 or 19) as a byte, followed by some 1369 ;;
1370 ;; nulls. The primary motivation for doing this is to get some binary 1370 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After that is
1371 ;; characters up in the first line of the file so that `diff' will simply 1371 ;; the file-format version number (18 or 19) as a byte, followed by some
1372 ;; say "Binary files differ" instead of actually doing a diff of two .elc 1372 ;; nulls. The primary motivation for doing this is to get some binary
1373 ;; files. An extra benefit is that you can add this to /etc/magic: 1373 ;; characters up in the first line of the file so that `diff' will simply
1374 ;; 1374 ;; say "Binary files differ" instead of actually doing a diff of two .elc
1375 ;; 0 string ;ELC GNU Emacs Lisp compiled file, 1375 ;; files. An extra benefit is that you can add this to /etc/magic:
1376 ;; >4 byte x version %d 1376 ;;
1377 ;; 1377 ;; 0 string ;ELC GNU Emacs Lisp compiled file,
1378 (insert 1378 ;; >4 byte x version %d
1379 ";ELC" 1379 ;;
1380 (if (byte-compile-version-cond byte-compile-compatibility) 18 19) 1380 (insert
1381 "\000\000\000\n" 1381 ";ELC"
1382 ) 1382 (if (byte-compile-version-cond byte-compile-compatibility) 18 19)
1383 (insert ";;; compiled by " 1383 "\000\000\000\n"
1384 (or (and (boundp 'user-mail-address) user-mail-address) 1384 )
1385 (concat (user-login-name) "@" (system-name))) 1385 (insert ";;; compiled by "
1386 " on " 1386 (or (and (boundp 'user-mail-address) user-mail-address)
1387 (current-time-string) "\n;;; from file " filename "\n") 1387 (concat (user-login-name) "@" (system-name)))
1388 (insert ";;; emacs version " emacs-version ".\n") 1388 " on "
1389 (insert ";;; bytecomp version " byte-compile-version "\n;;; " 1389 (current-time-string) "\n;;; from file " filename "\n")
1390 (cond 1390 (insert ";;; emacs version " emacs-version ".\n")
1391 ((eq byte-optimize 'source) "source-level optimization only") 1391 (insert ";;; bytecomp version " byte-compile-version "\n;;; "
1392 ((eq byte-optimize 'byte) "byte-level optimization only") 1392 (cond
1393 (byte-optimize "optimization is on") 1393 ((eq byte-optimize 'source) "source-level optimization only")
1394 (t "optimization is off")) 1394 ((eq byte-optimize 'byte) "byte-level optimization only")
1395 (if (byte-compile-version-cond byte-compile-compatibility) 1395 (byte-optimize "optimization is on")
1396 "; compiled with Emacs 18 compatibility.\n" 1396 (t "optimization is off"))
1397 ".\n")) 1397 (if (byte-compile-version-cond byte-compile-compatibility)
1398 (if (not (byte-compile-version-cond byte-compile-compatibility)) 1398 "; compiled with Emacs 18 compatibility.\n"
1399 (insert ";;; this file uses opcodes which do not exist in Emacs 18.\n" 1399 ".\n"))
1400 ;; Have to check if emacs-version is bound so that this works 1400 (if (not (byte-compile-version-cond byte-compile-compatibility))
1401 ;; in files loaded early in loadup.el. 1401 (insert ";;; this file uses opcodes which do not exist in Emacs 18.\n"
1402 "\n(if (and (boundp 'emacs-version)\n" 1402 ;; Have to check if emacs-version is bound so that this works
1403 "\t (or (and (boundp 'epoch::version) epoch::version)\n" 1403 ;; in files loaded early in loadup.el.
1404 (if byte-compile-dynamic-docstrings 1404 "\n(if (and (boundp 'emacs-version)\n"
1405 "\t (string-lessp emacs-version \"19.28.90\")))\n" 1405 "\t (or (and (boundp 'epoch::version) epoch::version)\n"
1406 "\t (string-lessp emacs-version \"19\")))\n") 1406 (if dynamic-docstrings
1407 " (error \"`" 1407 "\t (string-lessp emacs-version \"19.29\")))\n"
1408 ;; prin1-to-string is used to quote backslashes. 1408 "\t (string-lessp emacs-version \"19\")))\n")
1409 (substring (prin1-to-string (file-name-nondirectory filename)) 1409 " (error \"`"
1410 1 -1) 1410 ;; prin1-to-string is used to quote backslashes.
1411 (if byte-compile-dynamic-docstrings 1411 (substring (prin1-to-string (file-name-nondirectory filename))
1412 "' was compiled for Emacs 19.29 or later\"))\n\n" 1412 1 -1)
1413 "' was compiled for Emacs 19\"))\n\n")) 1413 (if dynamic-docstrings
1414 (insert "(or (boundp 'current-load-list) (setq current-load-list nil))\n" 1414 "' was compiled for Emacs 19.29 or later\"))\n\n"
1415 "\n") 1415 "' was compiled for Emacs 19\"))\n\n"))
1416 )) 1416 (insert "(or (boundp 'current-load-list) (setq current-load-list nil))\n"
1417 "\n")
1418 )))
1417 1419
1418 1420
1419 (defun byte-compile-output-file-form (form) 1421 (defun byte-compile-output-file-form (form)
1420 ;; writes the given form to the output buffer, being careful of docstrings 1422 ;; writes the given form to the output buffer, being careful of docstrings
1421 ;; in defun, defmacro, defvar, defconst and autoload because make-docfile is 1423 ;; in defun, defmacro, defvar, defconst and autoload because make-docfile is