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: Stefan Monnier
Subject: Re: Add/remove an element into/from a cons.
Date: Tue, 26 Oct 2021 08:36:44 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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.


        Stefan




reply via email to

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