From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: Appending to a list Date: Sun, 13 Dec 2020 22:03:34 +0100 Message-ID: <877dpljtwg.fsf@fastmail.fm> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17501"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.7; emacs 27.1.50 Cc: help-gnu-emacs@gnu.org To: steve-humphreys@gmx.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 13 22:14:41 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1koYhU-0004Ro-OH for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 22:14:40 +0100 Original-Received: from localhost ([::1]:34416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koYhT-0004aR-KU for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 16:14:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koYby-0004Zt-AJ for help-gnu-emacs@gnu.org; Sun, 13 Dec 2020 16:08:59 -0500 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:46657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koYbt-0005BU-E3 for help-gnu-emacs@gnu.org; Sun, 13 Dec 2020 16:08:58 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id B319C6D9; Sun, 13 Dec 2020 16:08:51 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 13 Dec 2020 16:08:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:cc:subject:date:in-reply-to:message-id :mime-version:content-type; s=fm1; bh=iKYebqnL2COmhJhe0hjGw8favT efK8lWxFH9lUltZe4=; b=rZ+1AcmfS1cAa5ZK2zYJj11yQ7QsdcN/UFasCMCPha I3FR8B5P01kQLfPFBtTn3I2IGBmtJGPMQx3HyC4lzQKkvdzEzsq+J06ayc3TpX58 5GAGYftG12tjfWwBJGMsVYCg6lUdMXL/xjw6SEaS8YQxZ4BGpNe43gaL1ePukmRB JZRih6WxTbNJ/paCoUmXjgyCBuJ6KDJB+EsOOCewzVAp7dYSBoQBAmfp8f7ya9an TloV/SoUoVnNwkvevMEC4XkTwk/HUlcLXWn70E7WdZHEiz2WsjtONtD7AerJALLz K44wgldfydEfYvJbbCi+BVqtHcdaxvwTY0Zsg3JZ35JA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=iKYebq nL2COmhJhe0hjGw8favTefK8lWxFH9lUltZe4=; b=cgH7BONefZ/hGH3Gp5LCaV HN36KRB46MTJPgE28cuvsDhwQFpSmJNAnO97ErpjkKW/AnUPxmLWl2e8vwfTZhcq MbN9ia8YQ4ivjkcTOFcpf9hBTsORNvSCNrskJtApReOcRTECaRggE4fwLZKmrFRb L1ByKzSEhsxV/+AwW5+veFjOmpOtCgrXL8WZERk0TNWuyaJGuFqjkVLFt1nERQlo b+12JhZHThNPpx/iWeCkQFkx28kslwZIFpe2cVoUahao4JR7sROVAusdgf0R+JQj IlG2I+KYWeYF/9/AFvPK+g3UramoOZUFWvVCvz1F9d+TNvpX1ZOsDpsLuNPWcdow == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudekiedgudegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfhgfhffvufffjgfkgggtsehttd ertddtredtnecuhfhrohhmpeflohhoshhtucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgv mhgvrhhssehfrghsthhmrghilhdrfhhmqeenucggtffrrghtthgvrhhnpedviefhteeuve ekudetheduieehvdelgfeijeehvdetfeegleelhefhjeduieejveenucfkphepleehrdel tddrvddvgedrvddttdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: from Swift.fastmail.com (ip5f5ae0c8.dynamic.kabel-deutschland.de [95.90.224.200]) by mail.messagingengine.com (Postfix) with ESMTPA id 7671D108005B; Sun, 13 Dec 2020 16:08:50 -0500 (EST) In-reply-to: Received-SPF: pass client-ip=64.147.123.20; envelope-from=joostkremers@fastmail.fm; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:126325 Archived-At: On Sun, Dec 13 2020, steve-humphreys@gmx.com wrote: > Would appending to list like this be good? > > (setq bird '("Toucan" "King Fisher")) > (setq bird (append bird ("Swift") )) This should result in an error, because `("Swift")` isn't quoted. You'd need: (setq bird (append bird '("Swift"))) But note that the last argument of `append` isn't copied, so it may not be a good idea to use a literal list. > Or does one customarily use other constructs for > adding to a list? `push` is what I would use: (push "Swift" bird) No need to use `setq` here. `push` won't check if the element is already in the list, though. You can use `cl-pushnew` in that case, but be sure to load the library it's in: (require 'cl-lib) (cl-pushnew "Swift" bird) HTH -- Joost Kremers Life has its moments