help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add/remove an element into/from a cons.


From: Hongyi Zhao
Subject: Re: Add/remove an element into/from a cons.
Date: Tue, 26 Oct 2021 14:30:47 +0800

On Tue, Oct 26, 2021 at 2:21 PM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > (defun my-scratch-init ()
> >   (with-current-buffer "*scratch*"
> >     (setq-local company-backends (let ((place (assoc 'company-tabnine
> > company-backends)))
> >                    (setf place (remove 'company-ispell place))))
> >     ))
>
> setf returns the new value, so here you are setting company-backends to
> the modified alist entry, not the alist itself.  This should work:
>
> --8<---------------cut here---------------start------------->8---
> (defun my-scratch-init ()
>   (with-current-buffer "*scratch*"
>     ;; Ensure it has a local variable.  Not sure if it has by default...
>     (make-local-variable 'company-backends)
>     (let ((place (assoc 'company-tabnine company-backends)))
>       (setf place (remove 'company-ispell place)))))
> --8<---------------cut here---------------end--------------->8---

It doesn't work. The variable hasn't been revised when I'm switch to
scratch buffer.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]