From b715ed4447b025d713fc68a7af3728c2d463974b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 6 Nov 2012 22:39:33 -0500 Subject: [PATCH] * lisp/emacs-lisp/gv.el (gv-define-simple-setter): Don't evaluate `val' twice when `fix-return' is set. Fixes: debbugs:12813 --- lisp/ChangeLog | 3 +++ lisp/emacs-lisp/gv.el | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b88baaa2f0a..187ff2d7e1d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2012-11-07 Stefan Monnier + * emacs-lisp/gv.el (gv-define-simple-setter): Don't evaluate `val' + twice when `fix-return' is set (bug#12813). + * emacs-lisp/cl.el (defsetf): Pass the third arg to gv-define-simple-setter (bug#12812). diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 3dd021f9e74..a0c412a9504 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -213,9 +213,11 @@ If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and instead the assignment is turned into (prog1 VAL (SETTER ARGS... VAL)) so as to preserve the semantics of `setf'." (declare (debug (sexp (&or symbolp lambda-expr) &optional sexp))) - (let ((set-call `(cons ',setter (append args (list val))))) `(gv-define-setter ,name (val &rest args) - ,(if fix-return `(list 'prog1 val ,set-call) set-call)))) + ,(if fix-return + `(macroexp-let2 nil v val + (cons ',setter (append args (list v)))) + `(cons ',setter (append args (list val)))))) ;;; Typical operations on generalized variables. -- 2.39.2