emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 8461614: * lisp/subr.el (prog2): Define as a macro


From: Stefan Monnier
Subject: [Emacs-diffs] master 8461614: * lisp/subr.el (prog2): Define as a macro
Date: Tue, 2 Apr 2019 10:04:49 -0400 (EDT)

branch: master
commit 84616144ca206ef9a92bd0cd2507376f42bfe3e6
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * 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.
---
 lisp/emacs-lisp/byte-opt.el  |  5 -----
 lisp/emacs-lisp/bytecomp.el  |  9 +--------
 lisp/emacs-lisp/cconv.el     |  2 +-
 lisp/emacs-lisp/generator.el |  7 -------
 lisp/emacs-lisp/lisp-mode.el |  1 -
 lisp/subr.el                 |  7 +++++++
 src/eval.c                   | 12 ------------
 7 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 4418c9a..33d4964 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 9dd5151..8bbe629 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 e658270..58ca9d5 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 3fd66bf..caf5fed 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 30a43d8..4c7a8be 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 6a9492a..8d51474 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 49d6460..e9f118c 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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]