diff options
| author | Stefan Monnier | 2010-12-15 12:46:59 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2010-12-15 12:46:59 -0500 |
| commit | a0ee6f2751acba71df443d4d795bb350eb6421dd (patch) | |
| tree | e4f47d66877b1b00b9ce00a304b509dee840868a /lisp | |
| parent | defb141157dfa37c33cdcbfa4b29c702a8fc9edf (diff) | |
| download | emacs-a0ee6f2751acba71df443d4d795bb350eb6421dd.tar.gz emacs-a0ee6f2751acba71df443d4d795bb350eb6421dd.zip | |
Obey lexical-binding in interactive evaluation commands.
* lisp/emacs-lisp/edebug.el (edebug-eval-defun, edebug-eval):
* lisp/emacs-lisp/lisp-mode.el (eval-last-sexp-1, eval-defun-1):
* lisp/ielm.el (ielm-eval-input):
* lisp/simple.el (eval-expression): Use new eval arg to obey lexical-binding.
* src/eval.c (Feval): Add `lexical' argument. Adjust callers.
(Ffuncall, eval_sub): Avoid goto.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 17 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 26 | ||||
| -rw-r--r-- | lisp/ielm.el | 3 | ||||
| -rw-r--r-- | lisp/simple.el | 4 |
5 files changed, 32 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 053eb95329c..87794ceb5d2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2010-12-15 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/edebug.el (edebug-eval-defun, edebug-eval): | ||
| 4 | * emacs-lisp/lisp-mode.el (eval-last-sexp-1, eval-defun-1): | ||
| 5 | * ielm.el (ielm-eval-input): | ||
| 6 | * simple.el (eval-expression): Use new eval arg to obey lexical-binding. | ||
| 7 | |||
| 1 | 2010-12-14 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2010-12-14 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-condition-case): Use push. | 10 | * emacs-lisp/bytecomp.el (byte-compile-condition-case): Use push. |
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 77953b37021..4dfccb4c5b4 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -521,7 +521,7 @@ the minibuffer." | |||
| 521 | ((and (eq (car form) 'defcustom) | 521 | ((and (eq (car form) 'defcustom) |
| 522 | (default-boundp (nth 1 form))) | 522 | (default-boundp (nth 1 form))) |
| 523 | ;; Force variable to be bound. | 523 | ;; Force variable to be bound. |
| 524 | (set-default (nth 1 form) (eval (nth 2 form)))) | 524 | (set-default (nth 1 form) (eval (nth 2 form) lexical-binding))) |
| 525 | ((eq (car form) 'defface) | 525 | ((eq (car form) 'defface) |
| 526 | ;; Reset the face. | 526 | ;; Reset the face. |
| 527 | (setq face-new-frame-defaults | 527 | (setq face-new-frame-defaults |
| @@ -534,7 +534,7 @@ the minibuffer." | |||
| 534 | (put ',(nth 1 form) 'customized-face | 534 | (put ',(nth 1 form) 'customized-face |
| 535 | ,(nth 2 form))) | 535 | ,(nth 2 form))) |
| 536 | (put (nth 1 form) 'saved-face nil))))) | 536 | (put (nth 1 form) 'saved-face nil))))) |
| 537 | (setq edebug-result (eval form)) | 537 | (setq edebug-result (eval form lexical-binding)) |
| 538 | (if (not edebugging) | 538 | (if (not edebugging) |
| 539 | (princ edebug-result) | 539 | (princ edebug-result) |
| 540 | edebug-result))) | 540 | edebug-result))) |
| @@ -2466,6 +2466,7 @@ MSG is printed after `::::} '." | |||
| 2466 | (if edebug-global-break-condition | 2466 | (if edebug-global-break-condition |
| 2467 | (condition-case nil | 2467 | (condition-case nil |
| 2468 | (setq edebug-global-break-result | 2468 | (setq edebug-global-break-result |
| 2469 | ;; FIXME: lexbind. | ||
| 2469 | (eval edebug-global-break-condition)) | 2470 | (eval edebug-global-break-condition)) |
| 2470 | (error nil)))) | 2471 | (error nil)))) |
| 2471 | (edebug-break)) | 2472 | (edebug-break)) |
| @@ -2477,6 +2478,7 @@ MSG is printed after `::::} '." | |||
| 2477 | (and edebug-break-data | 2478 | (and edebug-break-data |
| 2478 | (or (not edebug-break-condition) | 2479 | (or (not edebug-break-condition) |
| 2479 | (setq edebug-break-result | 2480 | (setq edebug-break-result |
| 2481 | ;; FIXME: lexbind. | ||
| 2480 | (eval edebug-break-condition)))))) | 2482 | (eval edebug-break-condition)))))) |
| 2481 | (if (and edebug-break | 2483 | (if (and edebug-break |
| 2482 | (nth 2 edebug-break-data)) ; is it temporary? | 2484 | (nth 2 edebug-break-data)) ; is it temporary? |
| @@ -3637,9 +3639,10 @@ Return the result of the last expression." | |||
| 3637 | 3639 | ||
| 3638 | (defun edebug-eval (edebug-expr) | 3640 | (defun edebug-eval (edebug-expr) |
| 3639 | ;; Are there cl lexical variables active? | 3641 | ;; Are there cl lexical variables active? |
| 3640 | (if (bound-and-true-p cl-debug-env) | 3642 | (eval (if (bound-and-true-p cl-debug-env) |
| 3641 | (eval (cl-macroexpand-all edebug-expr cl-debug-env)) | 3643 | (cl-macroexpand-all edebug-expr cl-debug-env) |
| 3642 | (eval edebug-expr))) | 3644 | edebug-expr) |
| 3645 | lexical-binding)) ;; FIXME: lexbind. | ||
| 3643 | 3646 | ||
| 3644 | (defun edebug-safe-eval (edebug-expr) | 3647 | (defun edebug-safe-eval (edebug-expr) |
| 3645 | ;; Evaluate EXPR safely. | 3648 | ;; Evaluate EXPR safely. |
| @@ -4241,8 +4244,8 @@ It is removed when you hit any char." | |||
| 4241 | ;;; Menus | 4244 | ;;; Menus |
| 4242 | 4245 | ||
| 4243 | (defun edebug-toggle (variable) | 4246 | (defun edebug-toggle (variable) |
| 4244 | (set variable (not (eval variable))) | 4247 | (set variable (not (symbol-value variable))) |
| 4245 | (message "%s: %s" variable (eval variable))) | 4248 | (message "%s: %s" variable (symbol-value variable))) |
| 4246 | 4249 | ||
| 4247 | ;; We have to require easymenu (even for Emacs 18) just so | 4250 | ;; We have to require easymenu (even for Emacs 18) just so |
| 4248 | ;; the easy-menu-define macro call is compiled correctly. | 4251 | ;; the easy-menu-define macro call is compiled correctly. |
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index c90d1394978..2cdbd115928 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -699,16 +699,9 @@ If CHAR is not a character, return nil." | |||
| 699 | (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) | 699 | (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) |
| 700 | "Evaluate sexp before point; print value in minibuffer. | 700 | "Evaluate sexp before point; print value in minibuffer. |
| 701 | With argument, print output into current buffer." | 701 | With argument, print output into current buffer." |
| 702 | (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t)) | 702 | (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) |
| 703 | ;; preserve the current lexical environment | ||
| 704 | (internal-interpreter-environment internal-interpreter-environment)) | ||
| 705 | ;; Setup the lexical environment if lexical-binding is enabled. | 703 | ;; Setup the lexical environment if lexical-binding is enabled. |
| 706 | ;; Note that `internal-interpreter-environment' _can't_ be both | 704 | (eval-last-sexp-print-value (eval (preceding-sexp) lexical-binding)))) |
| 707 | ;; assigned and let-bound above -- it's treated specially (and | ||
| 708 | ;; oddly) by the interpreter! | ||
| 709 | (when lexical-binding | ||
| 710 | (setq internal-interpreter-environment '(t))) | ||
| 711 | (eval-last-sexp-print-value (eval (preceding-sexp))))) | ||
| 712 | 705 | ||
| 713 | 706 | ||
| 714 | (defun eval-last-sexp-print-value (value) | 707 | (defun eval-last-sexp-print-value (value) |
| @@ -772,16 +765,18 @@ Reinitialize the face according to the `defface' specification." | |||
| 772 | ;; `defcustom' is now macroexpanded to | 765 | ;; `defcustom' is now macroexpanded to |
| 773 | ;; `custom-declare-variable' with a quoted value arg. | 766 | ;; `custom-declare-variable' with a quoted value arg. |
| 774 | ((and (eq (car form) 'custom-declare-variable) | 767 | ((and (eq (car form) 'custom-declare-variable) |
| 775 | (default-boundp (eval (nth 1 form)))) | 768 | (default-boundp (eval (nth 1 form) lexical-binding))) |
| 776 | ;; Force variable to be bound. | 769 | ;; Force variable to be bound. |
| 777 | (set-default (eval (nth 1 form)) (eval (nth 1 (nth 2 form)))) | 770 | (set-default (eval (nth 1 form) lexical-binding) |
| 771 | (eval (nth 1 (nth 2 form)) lexical-binding)) | ||
| 778 | form) | 772 | form) |
| 779 | ;; `defface' is macroexpanded to `custom-declare-face'. | 773 | ;; `defface' is macroexpanded to `custom-declare-face'. |
| 780 | ((eq (car form) 'custom-declare-face) | 774 | ((eq (car form) 'custom-declare-face) |
| 781 | ;; Reset the face. | 775 | ;; Reset the face. |
| 782 | (setq face-new-frame-defaults | 776 | (setq face-new-frame-defaults |
| 783 | (assq-delete-all (eval (nth 1 form)) face-new-frame-defaults)) | 777 | (assq-delete-all (eval (nth 1 form) lexical-binding) |
| 784 | (put (eval (nth 1 form)) 'face-defface-spec nil) | 778 | face-new-frame-defaults)) |
| 779 | (put (eval (nth 1 form) lexical-binding) 'face-defface-spec nil) | ||
| 785 | ;; Setting `customized-face' to the new spec after calling | 780 | ;; Setting `customized-face' to the new spec after calling |
| 786 | ;; the form, but preserving the old saved spec in `saved-face', | 781 | ;; the form, but preserving the old saved spec in `saved-face', |
| 787 | ;; imitates the situation when the new face spec is set | 782 | ;; imitates the situation when the new face spec is set |
| @@ -792,10 +787,11 @@ Reinitialize the face according to the `defface' specification." | |||
| 792 | ;; `defface' change the spec, regardless of a saved spec. | 787 | ;; `defface' change the spec, regardless of a saved spec. |
| 793 | (prog1 `(prog1 ,form | 788 | (prog1 `(prog1 ,form |
| 794 | (put ,(nth 1 form) 'saved-face | 789 | (put ,(nth 1 form) 'saved-face |
| 795 | ',(get (eval (nth 1 form)) 'saved-face)) | 790 | ',(get (eval (nth 1 form) lexical-binding) |
| 791 | 'saved-face)) | ||
| 796 | (put ,(nth 1 form) 'customized-face | 792 | (put ,(nth 1 form) 'customized-face |
| 797 | ,(nth 2 form))) | 793 | ,(nth 2 form))) |
| 798 | (put (eval (nth 1 form)) 'saved-face nil))) | 794 | (put (eval (nth 1 form) lexical-binding) 'saved-face nil))) |
| 799 | ((eq (car form) 'progn) | 795 | ((eq (car form) 'progn) |
| 800 | (cons 'progn (mapcar 'eval-defun-1 (cdr form)))) | 796 | (cons 'progn (mapcar 'eval-defun-1 (cdr form)))) |
| 801 | (t form))) | 797 | (t form))) |
diff --git a/lisp/ielm.el b/lisp/ielm.el index 40e87cd6709..e1f8dc78d32 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el | |||
| @@ -372,7 +372,8 @@ simply inserts a newline." | |||
| 372 | (*** *3)) | 372 | (*** *3)) |
| 373 | (kill-buffer (current-buffer)) | 373 | (kill-buffer (current-buffer)) |
| 374 | (set-buffer ielm-wbuf) | 374 | (set-buffer ielm-wbuf) |
| 375 | (setq ielm-result (eval ielm-form)) | 375 | (setq ielm-result |
| 376 | (eval ielm-form lexical-binding)) | ||
| 376 | (setq ielm-wbuf (current-buffer)) | 377 | (setq ielm-wbuf (current-buffer)) |
| 377 | (setq | 378 | (setq |
| 378 | ielm-temp-buffer | 379 | ielm-temp-buffer |
diff --git a/lisp/simple.el b/lisp/simple.el index da8ac55c01d..a977be7cf8e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1212,12 +1212,12 @@ this command arranges for all errors to enter the debugger." | |||
| 1212 | current-prefix-arg)) | 1212 | current-prefix-arg)) |
| 1213 | 1213 | ||
| 1214 | (if (null eval-expression-debug-on-error) | 1214 | (if (null eval-expression-debug-on-error) |
| 1215 | (setq values (cons (eval eval-expression-arg) values)) | 1215 | (push (eval eval-expression-arg lexical-binding) values) |
| 1216 | (let ((old-value (make-symbol "t")) new-value) | 1216 | (let ((old-value (make-symbol "t")) new-value) |
| 1217 | ;; Bind debug-on-error to something unique so that we can | 1217 | ;; Bind debug-on-error to something unique so that we can |
| 1218 | ;; detect when evaled code changes it. | 1218 | ;; detect when evaled code changes it. |
| 1219 | (let ((debug-on-error old-value)) | 1219 | (let ((debug-on-error old-value)) |
| 1220 | (setq values (cons (eval eval-expression-arg) values)) | 1220 | (push (eval eval-expression-arg lexical-binding) values) |
| 1221 | (setq new-value debug-on-error)) | 1221 | (setq new-value debug-on-error)) |
| 1222 | ;; If evaled code has changed the value of debug-on-error, | 1222 | ;; If evaled code has changed the value of debug-on-error, |
| 1223 | ;; propagate that change to the global binding. | 1223 | ;; propagate that change to the global binding. |