From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#35546: 27.0.50; setf return value for new alist entries is wrong Date: Tue, 07 May 2019 13:19:54 +0200 Message-ID: <87ftpqmrz9.fsf@web.de> References: <87lfznzm08.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="130571"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 35546@debbugs.gnu.org To: Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 07 13:21:15 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hNy9q-000XsD-9w for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 May 2019 13:21:14 +0200 Original-Received: from localhost ([127.0.0.1]:44804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNy9p-0006SW-6c for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 May 2019 07:21:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNy9f-0006QK-9J for bug-gnu-emacs@gnu.org; Tue, 07 May 2019 07:21:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNy9e-00088n-90 for bug-gnu-emacs@gnu.org; Tue, 07 May 2019 07:21:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNy9e-00088j-4z for bug-gnu-emacs@gnu.org; Tue, 07 May 2019 07:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hNy9d-0006X1-V3 for bug-gnu-emacs@gnu.org; Tue, 07 May 2019 07:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 May 2019 11:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35546 X-GNU-PR-Package: emacs Original-Received: via spool by 35546-submit@debbugs.gnu.org id=B35546.155722800424961 (code B ref 35546); Tue, 07 May 2019 11:21:01 +0000 Original-Received: (at 35546) by debbugs.gnu.org; 7 May 2019 11:20:04 +0000 Original-Received: from localhost ([127.0.0.1]:58271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hNy8i-0006UX-3C for submit@debbugs.gnu.org; Tue, 07 May 2019 07:20:04 -0400 Original-Received: from mout.web.de ([212.227.15.3]:36269) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hNy8f-0006Ts-TF for 35546@debbugs.gnu.org; Tue, 07 May 2019 07:20:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1557227995; bh=39mp3DYwUC4p/S5Y53O2h4Y22PeoyEHg2kmckWRUVgs=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=RvVVJkHwFGQDK8oEQ7MyZaBDS62pUseKLNBljSW1xPFgQDEiNMR0fyEYpqYwXilYn xRQC/9JliAVpkTr1komjqgad5LI/js+9pjo8aEhyOtIUiilCC72gIlOWNDndAVbxIn trALLbhsef7C9zO/ytOq7fs3EO4UkSvI9llzJjwk= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([88.66.186.107]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lvjoa-1gev031fci-017Yqh; Tue, 07 May 2019 13:19:55 +0200 In-Reply-To: <87lfznzm08.fsf@gnu.org> (Tassilo Horn's message of "Fri, 03 May 2019 15:49:11 +0200") X-Provags-ID: V03:K1:LcgUnvF8BEOI71ncPSSG4uMW0nhrJe2BNoCvsF18ICIHZNlQu8U oopHkrw1A8Yq2mvvPvxTBZiFJZ64YkJ+kdBzHv2LFQ9PrAQ0AeGEJYWpCJjCm5kTLLufVCk glH5UgcNXRcNutW+2vxBOoKtMFYcPJEsztFcggGpG5utI/ssOKYQ/LIewa9YHv9kTiDdojw bk60U2vB66M01byJsak9A== X-UI-Out-Filterresults: notjunk:1;V03:K0:LrgeVuon84U=:CyrXowZBYzPaHbxraJYdbP iMb0vxL3U8aDatK+8pPpMmIsVhv/hMhoGAnQqAMyGcONJptOjRouboiKJtLeleLXa+XVM66MY j5tflebC6WG7epY5Fe3wNTi06TmD34L2W/56hWn/wI0vMFTw8QbsFr1NM4jdSKvRpWMgUEplf vHCqEieJcOyR9qCKR0aqVejdZwuV18I2F7XXgRjxparvXjkll3wV8LY5RGCVjS3rL248Ddr6C Ku5xqR4DI89nBm02V+fu5IkC2OdYdOHICsgYtc9WS7CKPQpqvDKA2QUmq+8i0sOOJG7zN5GN3 KN63uR9uyJ84l2YxFR2Nlj6TbFUQXw52XQ7W6+V+SFmA9NfZI47hbjSUXtfXCjcNzVigJrwzd dZYkn7T9kM9mcz9H8llCBQDXLa3Qq5ydwJPRmGKNAifyrY5W5JxdFtKa7x3XtuHmECMogBPTr qZfYivuW3vAX6LuwGTHjcUsIEd//mGh6gL0muKZXQQLmKmuF6fjvwhxFTU8zf5TlvJcE1cx2a fzHo8zJ5FPiFBZsY9E2e2jwRmyf7W62G40VFNSxjMr3eT+j3GTp+qiMh2lFq1/1nfSG0bbhSg 1gtdyODCAEcrSoU8K+/HmIYKOCwvb2p/DW+y577YaMbRG8GhTJPbL1U6mB8/8xPUXHk6l0QoY /me4oHpeZgmXpfRDiEg9w5SpSnqndVbGu6dVkhuYYoJhdMzT2Su9Mag4jrxwRsI8sqZDKk0rt cG/frjkXmNE+A4aKLGgB4ne1fqTlpMbMmtmp689jaRuo6F5icsf1ax4jwCjxqZiJSx5IPPU9 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158866 Archived-At: --=-=-= Content-Type: text/plain Tassilo Horn writes: > According to the last sentence, I'd assume that > > (setq my-alist nil) > (setf (alist-get 'foo my-alist) "foo-value") > > would return "foo-value", but infact it returns ((foo . "foo-value")). > As soon as there is an association for 'foo, it returns the new value, > i.e., "foo-value". I agree. I think fixing should be quite straightforward: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-alist-get-gv-setter-not-returning-VAL.patch Content-Transfer-Encoding: quoted-printable =46rom 2fc149e3afa411f5b64c743de362378568f97bd6 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Mon, 6 May 2019 14:58:24 +0200 Subject: [PATCH] Fix alist-get gv setter not returning VAL This fixes Bug#35546. * lisp/emacs-lisp/gv.el (alist-get): Make setter return the set value to preserve 'setf' semantics. =2D-- lisp/emacs-lisp/gv.el | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 4ea3ce84fc..bdd1574820 100644 =2D-- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -392,18 +392,20 @@ setf ,(funcall setter `(cons (setq ,p (cons ,k ,v)) ,getter))))) - (cond - ((null remove) set-exp) - ((or (eql v default) - (and (eq (car-safe v) 'quote) - (eq (car-safe default) 'quote) - (eql (cadr v) (cadr default)))) - `(if ,p ,(funcall setter `(delq ,p ,getter)))) - (t - `(cond - ((not (eql ,default ,v)) ,set-exp) - (,p ,(funcall setter - `(delq ,p ,getter)))))))))))))= )) + `(progn + ,(cond + ((null remove) set-exp) + ((or (eql v default) + (and (eq (car-safe v) 'quote) + (eq (car-safe default) 'quote) + (eql (cadr v) (cadr default)))) + `(if ,p ,(funcall setter `(delq ,p ,getter)= ))) + (t + `(cond + ((not (eql ,default ,v)) ,set-exp) + (,p ,(funcall setter + `(delq ,p ,getter)))))) + ,v)))))))))) ;;; Some occasionally handy extensions. =2D- 2.20.1 --=-=-= Content-Type: text/plain Michael. --=-=-=--