From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: plist-put: destructive? Date: Fri, 20 Jan 2017 11:13:28 -0800 Message-ID: <87mvelzgrr.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1484940497 19559 195.159.176.226 (20 Jan 2017 19:28:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 20 Jan 2017 19:28:17 +0000 (UTC) User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/26.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 20 20:28:14 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cUeqa-0002Co-Sa for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Jan 2017 20:27:40 +0100 Original-Received: from localhost ([::1]:56938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUeqg-0004p0-0b for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Jan 2017 14:27:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUedP-00023x-1G for help-gnu-emacs@gnu.org; Fri, 20 Jan 2017 14:14:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUedK-0000t8-1p for help-gnu-emacs@gnu.org; Fri, 20 Jan 2017 14:14:03 -0500 Original-Received: from [195.159.176.226] (port=46640 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cUedJ-0000s9-RK for help-gnu-emacs@gnu.org; Fri, 20 Jan 2017 14:13:57 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cUed8-0004wP-RI for help-gnu-emacs@gnu.org; Fri, 20 Jan 2017 20:13:46 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 38 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:bS7VbPTXjWy0IUd4A6/Qm4u5Tpo= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-Mailman-Approved-At: Fri, 20 Jan 2017 14:27:19 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112133 Archived-At: Plists are great, except for setting keys, which isn't great. Occasionally it annoys me enough to want to try to "do something" about it. The docstring for plist-put says we should be using: (setq some-plist (plist-put some-plist :prop val)) To be sure of modifying the list correctly. But all my experiments have shown that a plain plist-put does modify the original list, and everything works as expected without re-assigning to the original variable. So what's the ambiguity? Are there circumstances where a simple plist-put isn't going to modify the original plist? I tried this: (gv-define-simple-setter plist-get plist-put) Which allows this to work: (setf (plist-get some-plist :prop) val) That's hardly less verbose than the setq re-assignment, but I suppose it would allow for a plist to be used in cl-letf, or for a custom macro like: (with-plist-props ((prop1 :prop1) (prop2 :prop2)) some-plist ...) But if plist-put is reliably destructive, I don't suppose any of that is really necessary. Can we rely on plist-put? Thanks, Eric