Commit graph

454 commits

Author SHA1 Message Date
Stefan Monnier
43e67019df Make cconv-analyse understand the need for closures.
* lisp/emacs-lisp/byte-lexbind.el (byte-compile-lforminfo-analyze):
Understand the :fun-body case for catch, save-window-excursion, and
condition-case.
(byte-compile-maybe-push-heap-environment): No need when nclosures is
zero and byte-compile-current-num-closures is -1.

* lisp/emacs-lisp/bytecomp.el (byte-compile-lambda): Fix `fun' that was not
renamed to `bytecomp-fun'.

* lisp/emacs-lisp/cconv.el (cconv-not-lexical-var-p): New function.
(cconv-freevars): Use it.
(cconv-closure-convert-rec): Avoid `position'.
(cconv-analyse-function): New function.
(cconv-analyse-form): Use it.  `inclosure' can't be nil any more.
Check lexical vars at let-binding time rather than when referenced.
For defuns to be in an empty environment and lambdas to take lexical args.
Pay attention to the need to build closures in catch, unwind-protect,
save-window-excursion, condition-case, and track-mouse.
Fix defconst/defvar handling.
2011-02-11 14:48:54 -05:00
Stefan Monnier
d779e73c22 * lisp/emacs-lisp/bytecomp.el (byte-compile-catch)
(byte-compile-unwind-protect, byte-compile-track-mouse)
(byte-compile-condition-case, byte-compile-save-window-excursion):
Provide a :fun-body alternative, so that info can be propagated from the
surrounding context, as is the case for lexical scoping.

* lisp/emacs-lisp/cconv.el (cconv-mutated, cconv-captured)
(cconv-captured+mutated, cconv-lambda-candidates): Fix up declaration.
(cconv-freevars): Minor cleanup.  Fix handling of the error var in
condition-case.
2011-02-10 18:37:03 -05:00
Igor Kuzmin
94d11cb577 * lisp/emacs-lisp/cconv.el: New file.
* lisp/emacs-lisp/bytecomp.el: Use cconv.
(byte-compile-file-form, byte-compile):
Call cconv-closure-convert-toplevel when requested.
* lisp/server.el:
* lisp/mpc.el:
* lisp/emacs-lisp/pcase.el:
* lisp/doc-view.el:
* lisp/dired.el: Use lexical-binding.
2011-02-10 13:53:49 -05:00
Stefan Monnier
8f1d2ef658 Merge from trunk 2011-02-01 12:09:25 -05:00
Glenn Morris
73b0cd5003 Convert consecutive FSF copyright years to ranges. 2011-01-24 20:08:28 -08:00
Glenn Morris
e9bffc61f2 Refill some copyright headers. 2011-01-15 18:21:30 -08:00
Stefan Monnier
77ab81d054 Merge from emacs-23 2011-01-14 12:18:41 -05:00
Glenn Morris
5df4f04cd3 Add 2011 to FSF/AIST copyright years. 2011-01-02 15:50:46 -08:00
Stefan Monnier
590130fb19 * src/eval.c (Fdefvar): Record specialness before computing initial value.
* lisp/emacs-lisp/bytecomp.el (byte-compile-track-mouse): Don't use #'.
2010-12-27 12:55:38 -05:00
Stefan Monnier
17870c01f6 Fix up last change.
* lisp/emacs-lisp/bytecomp.el (byte-compile-output-docform): Fix up use of
print-number-table.
* src/print.c (PRINT_NUMBER_OBJECT, PRINT_NUMBER_STATUS): Remove.
(print_preprocess): Fix handling of uninterned symbols in last change.
2010-12-22 19:00:12 -05:00
Stefan Monnier
defb141157 Try and be more careful about propagation of lexical environment.
* src/eval.c (apply_lambda, funcall_lambda): Remove lexenv arg.
(Feval): Always eval in the empty environment.
(eval_sub): New function.  Use it for all calls to Feval that should
evaluate in the lexical environment of the caller.
Pass `closure's as is to apply_lambda.
(Ffuncall): Pass `closure's as is to funcall_lambda.
(funcall_lambda): Extract lexenv for `closure's, when applicable.
Also use lexical scoping for the &rest argument, if applicable.
* src/lisp.h (eval_sub): Declare.
* src/lread.c (readevalloop): Remove `evalfun' argument.
* src/print.c (Fwith_output_to_temp_buffer):
* src/data.c (Fsetq_default): Use eval_sub.
* lisp/emacs-lisp/bytecomp.el (byte-compile-condition-case): Use push.
2010-12-13 22:37:44 -05:00
Stefan Monnier
2c302df3a1 Merge from trunk 2010-12-10 19:13:08 -05:00
Stefan Monnier
4a47c27573 Merge from emacs-23 2010-11-17 22:54:14 -05:00
Glenn Morris
7847454adc bytecomp trivia.
* lisp/emacs-lisp/bytecomp.el (byte-compile-log-buffer): New constant.
Use it to replace all instances of "*Compile-Log*"
2010-11-11 19:21:38 -08:00
Stefan Monnier
acef0722fc * lisp/files.el (safe-local-variable-p): Gracefully handle errors.
* lisp/emacs-lisp/bytecomp.el (byte-compile-warnings): Simplify the
safety predicate.
2010-11-11 17:19:01 -05:00
Noah Friedman
fa14dc1800 (byte-recompile-file): If bytecomp-arg is nil, do not ask to recompile files that are not already compiled, and do not recompile them. 2010-11-02 15:51:25 -07:00
Glenn Morris
feb5e60ae7 * lisp/emacs-lisp/bytecomp.el (byte-recompile-file): Fix previous change. 2010-10-31 19:55:12 -07:00
Julien Danjou
430e7297cb * lisp/emacs-lisp/bytecomp.el (byte-recompile-file): New fun.
(byte-recompile-directory):
* lisp/emacs-lisp/lisp-mode.el (emacs-lisp-byte-compile-and-load):
* cedet/ede/proj-elisp.el (project-compile-target):
* cedet/semantic/ede-grammar.el (project-compile-target):
Use `byte-recompile-file'.

Fixes: debbugs:7297
2010-10-31 15:25:39 -04:00
Stefan Monnier
0c747cb143 Merge from trunk 2010-10-15 17:55:33 -04:00
Chong Yidong
96bcef2ec6 Remove obsolete use of binary-overwrite-mode in bytecomp (Bug#7001).
* emacs-lisp/bytecomp.el (byte-compile-from-buffer): Remove
obsolete use of binary-overwrite-mode (Bug#7001).
2010-10-03 00:31:59 -04:00
Chong Yidong
986d19df1f Add minor comment (Bug#7001). 2010-10-02 19:10:41 -04:00
Glenn Morris
9c524fcb89 Run kill-emacs-hook in batch mode, and on SIGINT in batch mode.
See thread http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg00795.html

* src/emacs.c (fatal_error_signal): Also run Fkill_emacs on SIGINT.
(main) [!WINDOWSNT]: Handle SIGINT with fatal_error_signal
in batch-mode.
(Fkill_emacs): Doc fix.  Also run the hook in batch mode.
(kill-emacs-hook): Doc fix.

* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Use kill-emacs-hook to
delete tempfile if interrupted during compilation.

* doc/lispref/os.texi (Killing Emacs): Hook now runs in batch mode.

* etc/NEWS: Mention these changes.
2010-10-01 19:30:11 -07:00
Stefan Monnier
a01a793208 Merge from trunk 2010-09-30 01:28:20 +02:00
Glenn Morris
7a16788be4 Trivial bytecomp.el change.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file-form-defvar):
(byte-compile-defvar, byte-compile-cl-warn):
Start warnings with lower-case, like the majority.
2010-09-23 00:55:01 -07:00
Stefan Monnier
3fe6ef4e36 * lisp/emacs-lisp/bytecomp.el (byte-compile-file-form-defvar)
(byte-compile-defvar): "foo/bar" does not lack a prefix.
2010-09-17 16:31:06 +02:00
Stefan Monnier
4f1e996048 * lisp/emacs-lisp/bytecomp.el (byte-compile-warning-types): New type
`lexical' for warnings related to lexical scoping.
(byte-compile-file-form-defvar, byte-compile-defvar): Warn about
global vars which don't have a prefix and could hence affect lexical
scoping in unrelated files.
2010-09-15 17:30:43 +02:00
Stefan Monnier
cc390e46c7 Merge from trunk 2010-09-13 16:40:48 +02:00
Glenn Morris
7eb662be2f * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Tweak previous change.
Write out the name of the .elc file, rather than the temp-file.
2010-09-11 12:33:52 -07:00
Glenn Morris
0f34ae289a Close bug#4196.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Create .elc files
atomically, to avoid parallel build errors.
2010-09-11 11:52:04 -07:00
Glenn Morris
5a972c365f Very minor bytecomp fix.
* lisp/emacs-lisp/bytecomp.el (byte-compile-report-ops):
Error if not compiled with -DBYTE_CODE_METER.
2010-09-08 09:02:38 -07:00
Glenn Morris
13639aab35 * emacs-lisp/bytecomp.el (byte-recompile-directory): Ignore dir-locals-file. 2010-09-08 08:59:10 -07:00
Chong Yidong
bd78fa1d54 Add "Package:" file headers to denote built-in packages. 2010-08-29 12:17:13 -04:00
Stefan Monnier
3c3ddb9833 * lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment):
Don't macroexpand before evaluating in eval-and-compile, in case
`body's macro expansion uses macros and functions defined in itself.

* src/bytecode.c (exec_byte_code):
* src/eval.c (Ffunctionp): Fix up int/Lisp_Object confusions.
2010-06-14 22:51:25 -04:00
Stefan Monnier
f43cb64908 * lisp/Makefile.in (.el.elc): Increase max-lisp-eval-depth.
* lisp/emacs-lisp/bytecomp.el (byte-compile-check-variable):
Update byte-compile-not-obsolete-var to byte-compile-not-obsolete-vars.
2010-06-13 23:27:16 -04:00
Stefan Monnier
b9598260f9 New branch for lexbind, losing all history.
This initial patch is based on 2002-06-27T22:39:10Z!storm@cua.dk of the original
lexbind branch.
2010-06-13 16:36:17 -04:00
Stefan Monnier
171eda5358 Merge from emacs-23 2010-05-24 20:54:13 -04:00
Stefan Monnier
dd9b52a693 * emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions):
Add delete-backward-char.
2010-05-24 17:01:10 -04:00
Stefan Monnier
9ae0c31028 Provide byte-compiler warnings when set-default a read-only var.
* emacs-lisp/bytecomp.el (byte-compile-set-default): New function.
(byte-compile-setq-default): Optimize for the
single-var case and don't call byte-compile-form in this case to avoid
inf-loop with byte-compile-set-default.
2010-04-23 12:26:11 -04:00
Glenn Morris
114f9c9679 Add 2010 to copyright years. 2010-01-13 00:35:10 -08:00
Glenn Morris
5fa9d1ecf4 Ulrich Mueller <ulm at gentoo.org>
(byte-compile-insert-header): Put the version number comment back on
its own line, for easier parsing by external tools.
2009-12-07 06:21:27 +00:00
Glenn Morris
3ab4308bab (byte-compile-save-excursion): Make message consistent with others (no
final period).
2009-12-01 03:14:02 +00:00
Stefan Monnier
62a258a71d (byte-compile-warning-types): New type `suspicious'.
(byte-compile-warnings): Use byte-compile-warning-types.
(byte-compile-save-excursion): Warn about use of set-buffer right
after save-excursion.
2009-11-27 22:03:04 +00:00
YAMAMOTO Mitsuharu
1e8571214b (byte-compile-output-file-form):
Quote doc string reference in defvaralias as it is not in special form.
(byte-compile-output-docform): Doc fix.
2009-11-16 04:06:12 +00:00
Glenn Morris
0028351d98 (byte-compile-single-version): Remove, unused.
(baud-rate, byte-code-function-p)
(byte-compile-generate-emacs19-bytecodes, byte-compile-overwrite-file)
(byte-compiler-valid-options, byte-compiler-options-handler)
(byte-compile-and-load-file, byte-compile-buffer):
Remove commented-out code.
2009-11-14 04:23:18 +00:00
Glenn Morris
775adc5143 (byte-compile-insert-header): Drop test for Emacs 19. (Bug#1531)
(byte-compile-fix-header): Update for the above change.
Drop test for epoch::version.
2009-11-05 03:25:41 +00:00
Dan Nicolaescu
f6195dfb58 * emacs-lisp/bytecomp.el (byte-compile-output-file-form): Handle defvaralias.
* make-docfile.c (scan_lisp_file): Also look for `defvaralias'.
2009-11-04 06:15:41 +00:00
Glenn Morris
eef899a997 (byte-defop-compiler19): Remove.
Without byte-compile-compatibility, the 'emacs19-opcode property is not
used by anything.  Replace all calls with byte-defop-compiler.
2009-11-04 03:17:15 +00:00
Glenn Morris
e5c89ce967 (byte-compile-version-cond): Remove macro.
(byte-compile-compatibility): Remove option.
(byte-compile-close-variables, byte-compile-fix-header)
(byte-compile-insert-header, byte-compile-output-docform)
(byte-compile-file-form-defmumble, byte-compile-byte-code-maker)
(byte-compile-lambda, byte-compile-form, byte-defop-compiler19)
(byte-compile-list, byte-compile-concat, byte-compile-function-form)
(byte-compile-insert, byte-compile-defun):
Remove support for byte-compile-compatibility and Emacs 18.  (Bug#4571)
2009-11-04 03:15:14 +00:00
Glenn Morris
2aea6521e3 (byte-compile-file-form-defvar)
(byte-compile-file-form-define-abbrev-table)
(byte-compile-file-form-custom-declare-variable)
(byte-compile-variable-ref, byte-compile-defvar):
Whether or not a warning is enabled should only affect whether we issue
the warning, not whether or not we collect the relevant data.
Eg warnings can be turned on and off throughout the course of a file.
2009-11-03 03:16:23 +00:00
Glenn Morris
416d35886f (byte-compile-warning-types, byte-compile-warnings): Add `constants'
as an option.
(byte-compile-callargs-warn, byte-compile-arglist-warn)
(display-call-tree): Update for byte-compile-fdefinition possibly
returning `(macro lambda ...)'.  (Bug#4778)
(byte-compile-variable-ref, byte-compile-setq-default):
Respect `constants' member of byte-compile-warnings.
2009-10-31 02:10:43 +00:00