Commit 84616144 authored by Stefan Monnier's avatar Stefan Monnier

* 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.
parent 3e8f9482
Pipeline #1131 failed with stage
in 49 minutes and 26 seconds
......@@ -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
......
......@@ -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
......
......@@ -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)))
......
......@@ -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,
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment