aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-04-02 09:51:20 -0400
committerStefan Monnier2019-04-02 10:04:44 -0400
commit84616144ca206ef9a92bd0cd2507376f42bfe3e6 (patch)
treefebf9d92f37b18c6982c2a71ad225dc5c9154ae8
parent3e8f9482fe2288baedd9cc5026e25ffc543683ab (diff)
downloademacs-84616144ca206ef9a92bd0cd2507376f42bfe3e6.tar.gz
emacs-84616144ca206ef9a92bd0cd2507376f42bfe3e6.zip
* 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.
-rw-r--r--lisp/emacs-lisp/byte-opt.el5
-rw-r--r--lisp/emacs-lisp/bytecomp.el9
-rw-r--r--lisp/emacs-lisp/cconv.el2
-rw-r--r--lisp/emacs-lisp/generator.el7
-rw-r--r--lisp/emacs-lisp/lisp-mode.el1
-rw-r--r--lisp/subr.el7
-rw-r--r--src/eval.c12
7 files changed, 9 insertions, 34 deletions
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 @@
436 (cons (byte-optimize-form (nth 1 form) for-effect) 436 (cons (byte-optimize-form (nth 1 form) for-effect)
437 (byte-optimize-body (cdr (cdr form)) t))) 437 (byte-optimize-body (cdr (cdr form)) t)))
438 (byte-optimize-form (nth 1 form) for-effect))) 438 (byte-optimize-form (nth 1 form) for-effect)))
439 ((eq fn 'prog2)
440 (cons 'prog2
441 (cons (byte-optimize-form (nth 1 form) t)
442 (cons (byte-optimize-form (nth 2 form) for-effect)
443 (byte-optimize-body (cdr (cdr (cdr form))) t)))))
444 439
445 ((memq fn '(save-excursion save-restriction save-current-buffer)) 440 ((memq fn '(save-excursion save-restriction save-current-buffer))
446 ;; those subrs which have an implicit progn; it's not quite good 441 ;; 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.
2501 2501
2502(put 'progn 'byte-hunk-handler 'byte-compile-file-form-progn) 2502(put 'progn 'byte-hunk-handler 'byte-compile-file-form-progn)
2503(put 'prog1 'byte-hunk-handler 'byte-compile-file-form-progn) 2503(put 'prog1 'byte-hunk-handler 'byte-compile-file-form-progn)
2504(put 'prog2 'byte-hunk-handler 'byte-compile-file-form-progn)
2505(defun byte-compile-file-form-progn (form) 2504(defun byte-compile-file-form-progn (form)
2506 (mapc 'byte-compile-file-form (cdr form)) 2505 (mapc #'byte-compile-file-form (cdr form))
2507 ;; Return nil so the forms are not output twice. 2506 ;; Return nil so the forms are not output twice.
2508 nil) 2507 nil)
2509 2508
@@ -3971,7 +3970,6 @@ discarding."
3971(byte-defop-compiler-1 inline byte-compile-progn) 3970(byte-defop-compiler-1 inline byte-compile-progn)
3972(byte-defop-compiler-1 progn) 3971(byte-defop-compiler-1 progn)
3973(byte-defop-compiler-1 prog1) 3972(byte-defop-compiler-1 prog1)
3974(byte-defop-compiler-1 prog2)
3975(byte-defop-compiler-1 if) 3973(byte-defop-compiler-1 if)
3976(byte-defop-compiler-1 cond) 3974(byte-defop-compiler-1 cond)
3977(byte-defop-compiler-1 and) 3975(byte-defop-compiler-1 and)
@@ -3988,11 +3986,6 @@ discarding."
3988 (byte-compile-form-do-effect (car (cdr form))) 3986 (byte-compile-form-do-effect (car (cdr form)))
3989 (byte-compile-body (cdr (cdr form)) t)) 3987 (byte-compile-body (cdr (cdr form)) t))
3990 3988
3991(defun byte-compile-prog2 (form)
3992 (byte-compile-form (nth 1 form) t)
3993 (byte-compile-form-do-effect (nth 2 form))
3994 (byte-compile-body (cdr (cdr (cdr form))) t))
3995
3996(defmacro byte-compile-goto-if (cond discard tag) 3989(defmacro byte-compile-goto-if (cond discard tag)
3997 `(byte-compile-goto 3990 `(byte-compile-goto
3998 (if ,cond 3991 (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."
556 556
557 (`(,func . ,forms) 557 (`(,func . ,forms)
558 ;; First element is function or whatever function-like forms are: or, and, 558 ;; First element is function or whatever function-like forms are: or, and,
559 ;; if, catch, progn, prog1, prog2, while, until 559 ;; if, catch, progn, prog1, while, until
560 `(,func . ,(mapcar (lambda (form) 560 `(,func . ,(mapcar (lambda (form)
561 (cconv-convert form env extend)) 561 (cconv-convert form env extend))
562 forms))) 562 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.")
374 `(setf ,cps--value-symbol ,temp-var-symbol 374 `(setf ,cps--value-symbol ,temp-var-symbol
375 ,cps--state-symbol ,next-state)))))))) 375 ,cps--state-symbol ,next-state))))))))
376 376
377 ;; Process `prog2'.
378
379 (`(prog2 ,form1 ,form2 . ,body)
380 (cps--transform-1
381 `(progn ,form1 (prog1 ,form2 ,@body))
382 next-state))
383
384 ;; Process `unwind-protect': If we're inside an unwind-protect, we 377 ;; Process `unwind-protect': If we're inside an unwind-protect, we
385 ;; have a block of code UNWINDFORMS which we would like to run 378 ;; have a block of code UNWINDFORMS which we would like to run
386 ;; whenever control flows away from the main piece of code, 379 ;; 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."
1183(put 'autoload 'lisp-indent-function 'defun) ;Elisp 1183(put 'autoload 'lisp-indent-function 'defun) ;Elisp
1184(put 'progn 'lisp-indent-function 0) 1184(put 'progn 'lisp-indent-function 0)
1185(put 'prog1 'lisp-indent-function 1) 1185(put 'prog1 'lisp-indent-function 1)
1186(put 'prog2 'lisp-indent-function 2)
1187(put 'save-excursion 'lisp-indent-function 0) ;Elisp 1186(put 'save-excursion 'lisp-indent-function 0) ;Elisp
1188(put 'save-restriction 'lisp-indent-function 0) ;Elisp 1187(put 'save-restriction 'lisp-indent-function 0) ;Elisp
1189(put 'save-current-buffer 'lisp-indent-function 0) ;Elisp 1188(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.
118 ;; depend on backquote.el. 118 ;; depend on backquote.el.
119 (list 'function (cons 'lambda cdr))) 119 (list 'function (cons 'lambda cdr)))
120 120
121(defmacro prog2 (form1 form2 &rest body)
122 "Eval FORM1, FORM2 and BODY sequentially; return value from FORM2.
123The value of FORM2 is saved during the evaluation of the
124remaining args, whose values are discarded."
125 (declare (indent 2) (debug t))
126 `(progn ,form1 (prog1 ,form2 ,@body)))
127
121(defmacro setq-default (&rest args) 128(defmacro setq-default (&rest args)
122 "Set the default value of variable VAR to VALUE. 129 "Set the default value of variable VAR to VALUE.
123VAR, the variable name, is literal (not evaluated); 130VAR, 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...) */)
495 return val; 495 return val;
496} 496}
497 497
498DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0,
499 doc: /* Eval FORM1, FORM2 and BODY sequentially; return value from FORM2.
500The value of FORM2 is saved during the evaluation of the
501remaining args, whose values are discarded.
502usage: (prog2 FORM1 FORM2 BODY...) */)
503 (Lisp_Object args)
504{
505 eval_sub (XCAR (args));
506 return Fprog1 (XCDR (args));
507}
508
509DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0, 498DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0,
510 doc: /* Set each SYM to the value of its VAL. 499 doc: /* Set each SYM to the value of its VAL.
511The symbols SYM are variables; they are literal (not evaluated). 500The symbols SYM are variables; they are literal (not evaluated).
@@ -4219,7 +4208,6 @@ alist of active lexical bindings. */);
4219 defsubr (&Scond); 4208 defsubr (&Scond);
4220 defsubr (&Sprogn); 4209 defsubr (&Sprogn);
4221 defsubr (&Sprog1); 4210 defsubr (&Sprog1);
4222 defsubr (&Sprog2);
4223 defsubr (&Ssetq); 4211 defsubr (&Ssetq);
4224 defsubr (&Squote); 4212 defsubr (&Squote);
4225 defsubr (&Sfunction); 4213 defsubr (&Sfunction);