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:40:53 +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="9842"; 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:42:53 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 1mfFEa-0002OU-Sb for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 07:42:52 +0200 Original-Received: from localhost ([::1]:34648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfFEZ-0003qT-G7 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 01:42:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfFCt-0003qE-Ki for help-gnu-emacs@gnu.org; Tue, 26 Oct 2021 01:41:07 -0400 Original-Received: from mail-ua1-x92d.google.com ([2607:f8b0:4864:20::92d]:45917) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfFCr-0006Dg-UC; Tue, 26 Oct 2021 01:41:07 -0400 Original-Received: by mail-ua1-x92d.google.com with SMTP id f24so7725341uav.12; Mon, 25 Oct 2021 22:41:04 -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=bgr+1bf0avR2bJBsDcBpwcpk2IpLNwXOyOvMRGU1RxQ=; b=lPtRKLQ+Fnid7L+RrDNWZaj5sblSjNoJp1AJ+0u7tQxUhKhEfwdoAiwjJt0sxVqdT1 5/h4XpuO3lwuWsPS15qg5S148AJVHP87hY/gi0J5saene0y9WLSxD8JVxVzww5sl8MvB AXgVL0gCT3gPUz1/xh5NrnXR1bbcXOJq/wzq0/zhJNbwS6wUxC/Ut1hlSUdW3zf+zPxu jPSE7gWdCsMWJpVe8j29lF/2X1HdJtvOa6yQgAoZSY35FedjpIer/aJI1p1nfqCvUz2K wdz/doVrjxIv/0zVVYa82NYQg+H7wyMrOegZ1wrdoE6S4skoxsVVQ2ar/FDkf+OOFptz fUyw== 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=bgr+1bf0avR2bJBsDcBpwcpk2IpLNwXOyOvMRGU1RxQ=; b=E5/ttBlXQMuRkLqY0SXe/YeS+hD9qZPNp3GBY5FV1dTUTsZ7y2BuzPvSGtryEk6Q56 3qKQVCLOt7+HGXfAHSKFA0aZIZEU8E2yjSIsIwUyRrZhHt+4rwNzvD0WhnkGP/QmqSX9 SgrjF9OiOXheFPFiq8V9znY8OWMXIlgjz6Ym2y9LzosUGGKD/HCMz1/xyETV0iGoJWbU z8tuvaoTZANcdhUbecGuLxBmz31UN9f2Jd6D1ipoX2Th05uFU+T91Tx7Rei6k8Vl/MZY hqN+R9Jxou10dqj1kJ9kJUo/xJmmmWPvDzahx7kkRSPNZng23jZWXICvqGH4TyhMTXE0 WSwA== X-Gm-Message-State: AOAM532OHdBCIDeLh31jQrDkMlCF7lhaQgQG/DIs2N+g+/vl42LHHdIt QgCULmkNxVlyBI6ATgfwJhw/t2+RqAwUeu1IR+IM6cQnWwWccMYg X-Google-Smtp-Source: ABdhPJy8NPLfLRUA083q6dvhBI7Z+Xj6lIT2tVU07fY0R8bTbjUH6xcyt1JA2rlFgkkniHc7wwFX4fS39ZyRNfl0/Eo= X-Received: by 2002:a67:a60c:: with SMTP id p12mr21039683vse.25.1635226864203; Mon, 25 Oct 2021 22:41:04 -0700 (PDT) In-Reply-To: <875ytkqt4x.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::92d; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x92d.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:134179 Archived-At: 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? HZ