diff options
author | Richard M. Stallman <[email protected]> | 1999-08-29 19:53:27 +0000 |
---|---|---|
committer | Richard M. Stallman <[email protected]> | 1999-08-29 19:53:27 +0000 |
commit | 151a410a5c60ddc081616b4af53d912bd813d434 (patch) | |
tree | f0ebd38f9c73eef4fa61068ae04c9ac97cc460d6 | |
parent | 3d8be0c9451e5c63a0a118969fd580751f0781a1 (diff) |
(eval-defun): Expand macros,
and specially handle defvar inside their expansions.
(eval-defun-1): New subroutine.
-rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index f7484c8e71..65fa9c1b7d 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -344,6 +344,22 @@ With argument, print output into current buffer." expr)) (set-syntax-table stab))))))) +;; Change defvar into defconst within FORM, +;; and likewise for other constructs as necessary. +(defun eval-defun-1 (form) + (cond ((and (eq (car form) 'defvar) + (cdr-safe (cdr-safe form))) + ;; Force variable to be bound. + (cons 'defconst (cdr form))) + ((and (eq (car form) 'defcustom) + (default-boundp (nth 1 form))) + ;; Force variable to be bound. + (set-default (nth 1 form) (eval (nth 2 form))) + form) + ((eq (car form) 'progn) + (cons 'progn (mapcar 'eval-defun-1 (cdr form)))) + (t form))) + (defun eval-defun (eval-defun-arg-internal) "Evaluate defun that point is in or before. The value is displayed in the minibuffer. @@ -372,15 +388,8 @@ Return the result of evaluation." (setq beg (point)) (setq form (read (current-buffer))) (setq end (point))) - ;; Alter the form if necessary. - (cond ((and (eq (car form) 'defvar) - (cdr-safe (cdr-safe form))) - ;; Force variable to be bound. - (setq form (cons 'defconst (cdr form)))) - ((and (eq (car form) 'defcustom) - (default-boundp (nth 1 form))) - ;; Force variable to be bound. - (set-default (nth 1 form) (eval (nth 2 form))))) + ;; Alter the form if necessary, changing defvar into defconst, etc. + (setq form (eval-defun-1 (macroexpand form))) (list beg end standard-output `(lambda (ignore) ;; Skipping to the end of the specified region |