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 17:26:37 +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="16605"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs , Stefan Monnier To: Tassilo Horn Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 26 11:27:36 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 1mfIk4-00042Q-7P for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 11:27:36 +0200 Original-Received: from localhost ([::1]:37370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfIk2-0007h4-Ln for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 05:27:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfIjL-0007gl-JU for help-gnu-emacs@gnu.org; Tue, 26 Oct 2021 05:26:51 -0400 Original-Received: from mail-ua1-x934.google.com ([2607:f8b0:4864:20::934]:42756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfIjK-00082e-4f; Tue, 26 Oct 2021 05:26:51 -0400 Original-Received: by mail-ua1-x934.google.com with SMTP id b4so15674978uaq.9; Tue, 26 Oct 2021 02:26:49 -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=P/tNzAwWvr01YRHjlsgsjIAOO/3+9DhlPEOnQspql74=; b=cJtXz+WxxyrxEKEHA+KAJorlbKmVH+50WPOGtlz040MU+UbU46SleXQllOIOn8gcDr G4bxRVpx1YqiwW9UhinP4cpBHevETTZ/i01tSKHtTINSBLQ9smTFa0UFZ7lwU26HnLAm i3pDaGcv6AVhAsEyWzAw5EcQTYiO2x8dP3ZSgckciFgIfC+pVVRoUhIu30KRWGvnDu5J oWKWpFmcCk6aq+Dm9RwqP6WA0eafNw1AW5csDq3plyknZhBNq8PR8Bu8GhuENCHGlkOk V4anEp6juXrtPn/36ZfTv+ulUp4/7HP+jjCU9MP6RYCl5lpWa8gi7hLuqWFbK2GBDcY2 m7Ww== 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=P/tNzAwWvr01YRHjlsgsjIAOO/3+9DhlPEOnQspql74=; b=WF7g6q5cNPx3uow304dYHJATBLfE0HTDn9BSm0E+ExUYqX8pZSdV75X9UHDaZ5K51E 6N8jsULaksU5LgiMYWg32mToWsCkEeJbAuM3YQ6Dk1FdGn9e9w9EfYUfCTd9soDk2+rm BzntJbzPGhJ/94GWe+1L8LISMS5wsIIKCfaOX/MMXDPVKv9aPufw5pQC7RKEBFeQF0RK M6hMf3DY9REOjyerVOy9RmGEj1w2/BHBBHzhBVoMGvkaLE1GDa2iFeMD1/f06VAFzAnQ gk65N1af02sQO7OgznZzJIjvpG5W1UChqg5Xra6KwNh8XE3BsfLHe0pDtNlNNzKnI908 TJEQ== X-Gm-Message-State: AOAM533RigHFcelFD9Flf5jj9CXTVLweYjhVhtleG3ieIOvsZ7/n5h+Q NTcq/et4PRY/WbkBB788VoP3VQDPItF6jd2+RngaTRUOUEe1lVxF X-Google-Smtp-Source: ABdhPJxxBGmSvjcfG1F4dx4phJ8Qgkz0kNfn6+cmPnTdBojuf5qLMYqxjhh15C/ekppYI0z6hyvo6VDqeLIMgkEHPuY= X-Received: by 2002:a67:a60c:: with SMTP id p12mr21991325vse.25.1635240408709; Tue, 26 Oct 2021 02:26:48 -0700 (PDT) In-Reply-To: <87o87cp3fs.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::934; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x934.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:134198 Archived-At: On Tue, Oct 26, 2021 at 4:59 PM Tassilo Horn 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? After using the above function, it disables me to check the value of `company-backends' when I switch from scratch to other buffers. The following message will be triggered when I call `C-h v company-backends RET': Type "q" to restore previous buffer, SPC to scroll help. > That shouldn't happen, I'd say, as the function explicitly > makes `company-backends' buffer-local in *scratch* before modifying it. > > In any case, I think it would be more valuable for any of us if you'd > start a discussion with a statement on what you want to achieve instead > of some non-working snippet of code where the intent is to be > interpreted by the reader. I'm using company-tabnine package and the following company-backends setting: (setq company-backends '((company-tabnine :separate company-dabbrev company-keywords company-files company-ispell company-capf))) I want to disable the company-ispell backend when I'm in emacs-lisp-mode. The following function will do the trick: (defun hz/scratch-init () (with-current-buffer "*scratch*" (setq-local company-backends '((company-tabnine :separate company-capf company-dabbrev company-keywords company-files))) )) (add-hook 'emacs-lisp-mode-hook #'hz/scratch-init) But as I've posted here, considering that I've also had a definite company-backends setting, so I want to remove the company-ispell from it programmatically. I hope this time I've clearly stated my intention. HZ