I asked How can I script emacs to install packages from list? and got this answer.
(setq package-selected-packages
'(async
epl
evil
goto-chg
helm
helm-ag
helm-core
helm-descbinds
helm-projectile
pkg-info
popup
projectile
undo-tree))
(package-install-selected-packages)
When I inspect the value of the variable package-activated-list
in my installation the output is (evil goto-chg undo-tree goto-chg helm-ag helm helm-core async popup async helm-descbinds helm helm-core async popup async helm-projectile
projectile pkg-info epl helm helm-core async popup async popup projectile pkg-info epl undo-tree)
How could I insert the literal output of package-activated-list
into the buffer, after the quote. ie generate the script
(setq package-selected-packages
'
;;<<list of `package-activated-list` goes here >>
)
(package-install-selected-packages)
It would be better with duplicates removed and sorted, but those are secondary issues.
(setq package-selected-packages '(async … undo-tree))
, right? Do you want to generate just this snippet or a function? If a function, what arguments should it take? And most importantly, what input does the generator take? – Gilles 'SO- stop being evil' Jul 16 '17 at 08:48setq(...
with a placeholder for whatever variable is involved, which ispackage-activated-list
and a function to deduplicate and sort its output. – vfclists Jul 16 '17 at 10:31(setq package-selected-packages package-activated-list)
won't work for duplicatingpackage-activated-list
from one instance of emacs to the init file for setting up emacs on a different machine (as explained in the linked-to question). – Peder Klingenberg Jul 16 '17 at 19:26setq
with an unquoted value sets your variable to the result of evaluating the value.(setq foo
(a b c)) (setq bar foo)sets both
fooand
barto the list
(a b c), because
fooin the second form evaluates to the list you set it to in the first form. In your usecase (if I understand it correctly),
package-activated-liston the second machine presumably has the wrong value initially, that would be why you want to set
package-selected-packages`. Then you need the quoted variant. – Peder Klingenberg Jul 16 '17 at 19:36