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 21:41:38 +0800 Message-ID: References: <875ytkqt4x.fsf@gnu.org> <871r48qpuv.fsf@gnu.org> <87sfwop8iu.fsf@gnu.org> <87o87cp3fs.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="24756"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs , Tassilo Horn To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 26 15: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 1mfMj7-0006Dt-4R for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 15:42:53 +0200 Original-Received: from localhost ([::1]:55300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfMj5-0001nI-QZ for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 09:42:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfMiB-0001iY-Pz for help-gnu-emacs@gnu.org; Tue, 26 Oct 2021 09:41:55 -0400 Original-Received: from mail-ua1-x92b.google.com ([2607:f8b0:4864:20::92b]:44801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfMi9-00027s-09; Tue, 26 Oct 2021 09:41:55 -0400 Original-Received: by mail-ua1-x92b.google.com with SMTP id e5so22075731uam.11; Tue, 26 Oct 2021 06:41:50 -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=YebFex4+qOV66UnFkShKInj8N1X28Te/5dxDEHkBt+o=; b=S6x07VfbbWKNS63wnRBerhaAI12SAb8FaRyJ+F75REGi0jLLy1FEKBYDXueBzVisc0 2Ck7kKHzlPQRJZtbrttNNG74+sEfNSPVuCP0ZPPZmYrRmMQxhF6Rfmwnv8Nc1DWgetmK eWVELZdWFthjfYsL1EuC/x2o+wBq/My306vtuEgpcoVUa3NUU9WvMcVJJyDWk9/jFWzE 1WktZKELuL3WbRCbjFmqK2alGaFn83+onoMsP6WiSOwg9IQsedsHsv/8maUW5kYru9ex 66JXB3ki+Ka0tmQAOtQanNb7oKksxkMqIjo0kVtt5S87c00hVCix8fhzNNj2R/l4R1cO w3Sg== 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=YebFex4+qOV66UnFkShKInj8N1X28Te/5dxDEHkBt+o=; b=VjfhKFBFU4ANNzblxsx3YEH68pKYHPdnuGYtgnAfkmSc64WjN/PIVfXZLunwJ9baPc OSI65pNHb8ibf+wd5ER0h/Ulzp6KAY5PTFd2jXSSCgPiVHtXKrTrFWcj5cvFZfByQwLf s9GYKYl3hXuYpWIFpSV6KglPEJukkYzoo+19cPRrx5NrwQxDDSNntVymXLwZKAn5Ekpn xfJFfHzAF6JIyjyrn1/c5/L0vGWlZknT4bwDW+Sftu4rtc/GBlcJJSow7AvqWE7KQLiQ ZvMGF4OjKSauJCFDBeklcu8p6Ob3H1RJS5W4ZdQPqDtQQ8XG9ewwpLnq83C2gzf/VIJa NCbQ== X-Gm-Message-State: AOAM531e1RaokqH7ojHxZSzOekND+Y9USDiwcfSl2FG3Luq3c6iAPcR5 SSn4k4wsDAOMdCSDCe9HpF8SEQ9Hsp9icn9zJawDLhfeeVa9ieq8 X-Google-Smtp-Source: ABdhPJwbjv2Gu64qCnVtM8Mn8Zubk5D0RLfHdFVLiDH3j8myg7lQhOu8QCTGTnwFI2pSif1MPY3PAhsKWpiq6inMB7I= X-Received: by 2002:a67:a60c:: with SMTP id p12mr23693500vse.25.1635255709813; Tue, 26 Oct 2021 06:41:49 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::92b; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x92b.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:134211 Archived-At: On Tue, Oct 26, 2021 at 8:36 PM Stefan Monnier wrote: > > Tassilo Horn [2021-10-26 10:15:29] wrote: > > Hongyi Zhao writes: > >> I tried with the following function: > >> > >> ```emacs-lisp > >> (defun hz/scratch-init () > >> (with-current-buffer "*scratch*" > >> (make-local-variable 'company-backends) > >> (setf (alist-get 'company-tabnine company-backends) > >> (remove 'company-ispell (alist-get 'company-tabnine > >> company-backends))) > >> )) > >> ``` > >> > >> The above method will set the correct company-backends when I'm on > >> scratch buffer. But I also find that when I switch to other buffers, > >> says, AUCTeX based LaTeX-mode, the company-backends settings still > >> remains the same, > > > > You mean, the above function changes the value not only in *scratch* but > > all buffers? That shouldn't happen, I'd say, as the function explicitly > > makes `company-backends' buffer-local in *scratch* before modifying it. > > The `setf` above changes the data structure by side-effect. > It does not change the variable itself. How can I solve this problem to achieve the same effect as my original function? HZ