From: Stefan Monnier Date: Tue, 2 Apr 2019 13:51:20 +0000 (-0400) Subject: * lisp/subr.el (prog2): Define as a macro X-Git-Tag: emacs-27.0.90~3275 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=84616144ca206ef9a92bd0cd2507376f42bfe3e6;p=emacs.git * lisp/subr.el (prog2): Define as a macro * src/eval.c (Fprog2): Delete function. (syms_of_eval): Don't register it. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): * lisp/emacs-lisp/generator.el (cps--transform-1): Remove `prog2` case. * lisp/emacs-lisp/bytecomp.el (prog2): Remove handlers. (byte-compile-prog2): Delete. * lisp/emacs-lisp/lisp-mode.el (prog2): Remove property. --- diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 4418c9a1bfc..33d49647638 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -436,11 +436,6 @@ (cons (byte-optimize-form (nth 1 form) for-effect) (byte-optimize-body (cdr (cdr form)) t))) (byte-optimize-form (nth 1 form) for-effect))) - ((eq fn 'prog2) - (cons 'prog2 - (cons (byte-optimize-form (nth 1 form) t) - (cons (byte-optimize-form (nth 2 form) for-effect) - (byte-optimize-body (cdr (cdr (cdr form))) t))))) ((memq fn '(save-excursion save-restriction save-current-buffer)) ;; those subrs which have an implicit progn; it's not quite good diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 9dd5151963b..8bbe6292d9d 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2501,9 +2501,8 @@ list that represents a doc string reference. (put 'progn 'byte-hunk-handler 'byte-compile-file-form-progn) (put 'prog1 'byte-hunk-handler 'byte-compile-file-form-progn) -(put 'prog2 'byte-hunk-handler 'byte-compile-file-form-progn) (defun byte-compile-file-form-progn (form) - (mapc 'byte-compile-file-form (cdr form)) + (mapc #'byte-compile-file-form (cdr form)) ;; Return nil so the forms are not output twice. nil) @@ -3971,7 +3970,6 @@ discarding." (byte-defop-compiler-1 inline byte-compile-progn) (byte-defop-compiler-1 progn) (byte-defop-compiler-1 prog1) -(byte-defop-compiler-1 prog2) (byte-defop-compiler-1 if) (byte-defop-compiler-1 cond) (byte-defop-compiler-1 and) @@ -3988,11 +3986,6 @@ discarding." (byte-compile-form-do-effect (car (cdr form))) (byte-compile-body (cdr (cdr form)) t)) -(defun byte-compile-prog2 (form) - (byte-compile-form (nth 1 form) t) - (byte-compile-form-do-effect (nth 2 form)) - (byte-compile-body (cdr (cdr (cdr form))) t)) - (defmacro byte-compile-goto-if (cond discard tag) `(byte-compile-goto (if ,cond diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index e658270cd5c..58ca9d5f57e 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el @@ -556,7 +556,7 @@ places where they originally did not directly appear." (`(,func . ,forms) ;; First element is function or whatever function-like forms are: or, and, - ;; if, catch, progn, prog1, prog2, while, until + ;; if, catch, progn, prog1, while, until `(,func . ,(mapcar (lambda (form) (cconv-convert form env extend)) forms))) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 3fd66bfa807..caf5fed154b 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -374,13 +374,6 @@ don't yield.") `(setf ,cps--value-symbol ,temp-var-symbol ,cps--state-symbol ,next-state)))))))) - ;; Process `prog2'. - - (`(prog2 ,form1 ,form2 . ,body) - (cps--transform-1 - `(progn ,form1 (prog1 ,form2 ,@body)) - next-state)) - ;; Process `unwind-protect': If we're inside an unwind-protect, we ;; have a block of code UNWINDFORMS which we would like to run ;; whenever control flows away from the main piece of code, diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 30a43d8827e..4c7a8bea3fb 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -1183,7 +1183,6 @@ Lisp function does not specify a special indentation." (put 'autoload 'lisp-indent-function 'defun) ;Elisp (put 'progn 'lisp-indent-function 0) (put 'prog1 'lisp-indent-function 1) -(put 'prog2 'lisp-indent-function 2) (put 'save-excursion 'lisp-indent-function 0) ;Elisp (put 'save-restriction 'lisp-indent-function 0) ;Elisp (put 'save-current-buffer 'lisp-indent-function 0) ;Elisp diff --git a/lisp/subr.el b/lisp/subr.el index 6a9492a3a7a..8d51474b0c9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -118,6 +118,13 @@ BODY should be a list of Lisp expressions. ;; depend on backquote.el. (list 'function (cons 'lambda cdr))) +(defmacro prog2 (form1 form2 &rest body) + "Eval FORM1, FORM2 and BODY sequentially; return value from FORM2. +The value of FORM2 is saved during the evaluation of the +remaining args, whose values are discarded." + (declare (indent 2) (debug t)) + `(progn ,form1 (prog1 ,form2 ,@body))) + (defmacro setq-default (&rest args) "Set the default value of variable VAR to VALUE. VAR, the variable name, is literal (not evaluated); diff --git a/src/eval.c b/src/eval.c index 49d6460e6e4..e9f118c5cb9 100644 --- a/src/eval.c +++ b/src/eval.c @@ -495,17 +495,6 @@ usage: (prog1 FIRST BODY...) */) return val; } -DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0, - doc: /* Eval FORM1, FORM2 and BODY sequentially; return value from FORM2. -The value of FORM2 is saved during the evaluation of the -remaining args, whose values are discarded. -usage: (prog2 FORM1 FORM2 BODY...) */) - (Lisp_Object args) -{ - eval_sub (XCAR (args)); - return Fprog1 (XCDR (args)); -} - DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0, doc: /* Set each SYM to the value of its VAL. The symbols SYM are variables; they are literal (not evaluated). @@ -4219,7 +4208,6 @@ alist of active lexical bindings. */); defsubr (&Scond); defsubr (&Sprogn); defsubr (&Sprog1); - defsubr (&Sprog2); defsubr (&Ssetq); defsubr (&Squote); defsubr (&Sfunction);