help-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Jean Louis
Subject: Re: append, push, and add-to-list.
Date: Sun, 4 Jul 2021 14:28:24 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-04 08:12]:
> 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)
> (push NEWELT PLACE)
> (cl-pushnew X PLACE [KEYWORD VALUE]...)
> (append &rest SEQUENCES)

Good, I can also see some possible inconsistencies with X and NEWELT,
as it would be better to call X also NEWELT. I can also see that
documentation for `cl-pushnew' is not adequate enough. You are
probably expected to learn definition from Common Lisp to understand
the KEYWORDs:
http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_pushnew.html#pushnew

Function `append' will work with various sequences not just lists.

Please see manual: (info "(elisp) Sequences Arrays Vectors")

> > 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))

Functions `add-to-list' and `append' do different things, though
similar. 


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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