[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:40:53 +0800 |
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?
HZ
- Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/25
- Re: Add/remove an element into/from a cons., Tassilo Horn, 2021/10/26
- Re: Add/remove an element into/from a cons.,
Hongyi Zhao <=
- Re: Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/26
- Re: Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/26
- Re: Add/remove an element into/from a cons., Tassilo Horn, 2021/10/26
- Re: Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/26
- Re: Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/26
- Re: Add/remove an element into/from a cons., Tassilo Horn, 2021/10/26
- Re: Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/26
- Re: Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/26
- Re: Add/remove an element into/from a cons., Tassilo Horn, 2021/10/26
- Re: Add/remove an element into/from a cons., Hongyi Zhao, 2021/10/26