[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: append, push, and add-to-list.

From: Hongyi Zhao
Subject: Re: append, push, and add-to-list.
Date: Sun, 4 Jul 2021 13:11:34 +0800

On Sun, Jul 4, 2021 at 12:36 PM Jean Louis <> wrote:
> * Hongyi Zhao <> [2021-07-04 06:19]:
> > I've noticed there are some similar functions, i.e., append, push, and
> > add-to-list, for revising/updating the content of a list. But I'm
> > still not so clear on the specific use scenarios for them. Consider
> > the following command [1]:
> >
> > (push '(company-capf company-ispell) company-backends)
> >
> > What's the equivalent representations using append and add-to-list?
> > Which methods are preferable?
> It is recommended to review documentation for each function by using
> {C-h f} -
> - function add-to-list is traditionally rather used in configurations,
>   how I see it, like (add-to-list 'load-path "/my/directory") or
>   similar, instead, in programming code one shall rather use `push' or
>   `cl-pushnew' as `add-to-list' adds only new unique elements;

Thank you. I listed the usages below for all above-mentioned functions
by {C-h f} function-name:

(add-to-list LIST-VAR ELEMENT &optional APPEND COMPARE-FN)
(cl-pushnew X PLACE [KEYWORD VALUE]...)
(append &rest SEQUENCES)

> Because you use it more for configurations, then add-to-list would be:
> (add-to-list 'company-backends '(company-capf company-ispell))

Why can't this be written as follows, just like the other two?

(add-to-list company-backends '(company-capf company-ispell))

> and with append
> (append company-backends '(company-capf company-ispell))

Assoc. Prof. Hongyi Zhao <>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China

reply via email to

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