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 21:41:38 +0800

On Tue, Oct 26, 2021 at 8:36 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> Tassilo Horn [2021-10-26 10:15:29] wrote:
> > Hongyi Zhao <hongyi.zhao@gmail.com> 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



reply via email to

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