From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Add/remove an element into/from a cons. Date: Tue, 26 Oct 2021 13:42:57 +0800 Message-ID: References: <875ytkqt4x.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16910"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Tassilo Horn Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 26 07:44:30 2021 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 1mfFG9-0004Bg-Ls for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 07:44:29 +0200 Original-Received: from localhost ([::1]:35562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfFG7-0004ba-UF for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 01:44:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfFEu-0004b0-V7 for help-gnu-emacs@gnu.org; Tue, 26 Oct 2021 01:43:13 -0400 Original-Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]:39608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfFEs-0002nZ-BH; Tue, 26 Oct 2021 01:43:12 -0400 Original-Received: by mail-ua1-x935.google.com with SMTP id p23so14097983uaa.6; Mon, 25 Oct 2021 22:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=W+6Jft+PEhBp37Z3jvVM+x5UBC7rbXMhEAXaX7BOako=; b=K3xe1d17F4yUIScf8zh8YhSFMJdhB8vlHJsvf/SUOjKhh8seUcAmU+hhxDmc7Z+0oo lNj6aMoPlPAIBH461Rj84iP4BR7lnuuiJ/Xs0ceLc8TLr84Zt3qvIjKqWZqCIkKYZdNS yJNequFSWE24oI9BvSh1fZClf2MoK1uw64AH/vmn40soM+ustiuNRv7zXpd+VFIvr0g2 zFnNhScSyGbYNc+oSL+88udxSCwLsBrh/flw1OEleaiKVDJTQy6sPAtCh+fOqGtm/3g+ TEfqLqC+Y3G5rJgV4w1GXFUI6nZx3ihdp1gn/vSBC856UseCGkx0wCaPRhN3HQ2ywZ5J PQQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=W+6Jft+PEhBp37Z3jvVM+x5UBC7rbXMhEAXaX7BOako=; b=F4QIZOX6P6c93u/G64PvPVPpHudobuA/oWHxINVrjrQVD+DLw7oDaSs6d/sdinM9Eb 19CEKitCZ8bDMaCz0S/elA8cNlQBTDxpKiZVKvbd4EZ3gMPjUSCQOmcKTMimALvg3ve5 3aH/kKCM8vhMUlhwPm+Dztzktn/RHroN+qoplKCpc4sIbPz73zN3b1hBLhQ2XPuM77wU kfevTH56cWK1Dpa5tFznqml4pg0w5C7RcwHzR9ldHPbZHR1ujg6o5ETtEzXfcfQmJTXV 0LXVETS9/RRMu5i8qSrTGELSgUcijGG/Z+GRqeifLuIwnHR1IRN6JuHfFSqgRklsTUC2 Z2gw== X-Gm-Message-State: AOAM530JETPwOGDQC+y6i6n8SBloMrJixOaKycKp9nyzZND3PYKSJL/q 9kiRjE8jH63oLHpaKbgfMkKINk1jhDnBtFsoy0FaAz4ykLStXF9M X-Google-Smtp-Source: ABdhPJyDFF/wFueLku7wycYiuS/lYSjBc1dkpRPv7SxNpfAqBzLyzPB7hvHhjAXZ/1JcPLky/lX9IiZQ7TEQD8LqpZg= X-Received: by 2002:a67:c29d:: with SMTP id k29mr20882232vsj.51.1635226988861; Mon, 25 Oct 2021 22:43:08 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::935; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x935.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=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:134180 Archived-At: On Tue, Oct 26, 2021 at 1:40 PM Hongyi Zhao wrote: > > On Tue, Oct 26, 2021 at 12:58 PM Tassilo Horn wrote: > > > > Hongyi Zhao writes: > > > > > How can I add/remove an element into/from a cons, taking the following > > > one as an example: > > > > > > ```emacs-lisp > > > (setq company-backends '((company-tabnine :separate company-capf > > > company-dabbrev company-keywords company-files company-ispell))) > > > ``` > > > > > > How can I remove `company-ispell` from and re-add it into the > > > company-backends defined above? > > > > You can use `setf' with the place being the alist entry like this > > (company-backends replaced with th/test in my example): > > > > --8<---------------cut here---------------start------------->8--- > > (setq th/test '(( company-tabnine :separate company-capf company-dabbrev > > company-keywords company-files company-ispell))) > > > > (let ((place (assoc 'company-tabnine th/test))) > > (setf place (remove 'company-ispell place))) > > --8<---------------cut here---------------end--------------->8--- > > Yes. It does the trick: > > `C-j' (setq th/test '((company-tabnine :separate company-capf company-dabbrev > company-keywords company-ispell company-files))) > > ;; ((company-tabnine :separate company-capf company-dabbrev > company-keywords company-ispell company-files)) > > > `C-j' (setq th/test (let ((place (assoc 'company-tabnine th/test))) > (setf place (remove 'company-ispell place)))) > > ;; (company-tabnine :separate company-capf company-dabbrev > company-keywords company-files) > > But how to add it back to the alist? I mean: But how to add it back to its original position in the list?