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 13:42:57 +0800

On Tue, Oct 26, 2021 at 1:40 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Tue, Oct 26, 2021 at 12:58 PM Tassilo Horn <tsdh@gnu.org> wrote:
> >
> > Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> >
> > > How can I add/remove an element into/from a cons, taking the following
> > > one as an example:
> > >
> > > ```emacs-lisp
> > > (setq company-backends '((company-tabnine :separate company-capf
> > > company-dabbrev company-keywords company-files company-ispell)))
> > > ```
> > >
> > > How can I  remove `company-ispell` from and re-add it into the
> > > company-backends defined above?
> >
> > You can use `setf' with the place being the alist entry like this
> > (company-backends replaced with th/test in my example):
> >
> > --8<---------------cut here---------------start------------->8---
> > (setq th/test '(( company-tabnine :separate company-capf company-dabbrev
> >                   company-keywords company-files company-ispell)))
> >
> > (let ((place (assoc 'company-tabnine th/test)))
> >   (setf place (remove 'company-ispell place)))
> > --8<---------------cut here---------------end--------------->8---
>
> Yes. It does the trick:
>
> `C-j' (setq th/test '((company-tabnine :separate company-capf company-dabbrev
>                  company-keywords company-ispell company-files)))
>
> ;; ((company-tabnine :separate company-capf company-dabbrev
> company-keywords company-ispell company-files))
>
>
> `C-j' (setq th/test (let ((place (assoc 'company-tabnine th/test)))
>         (setf place (remove 'company-ispell place))))
>
> ;; (company-tabnine :separate company-capf company-dabbrev
> company-keywords company-files)
>
> But how to add it back to the alist?

I mean: But how to add it back to its original position in the list?



reply via email to

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