[Top][All Lists]

[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 17:26:37 +0800

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.


reply via email to

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