1

I've tried this:

(setq pkg-list '(rust-mode lsp-mode))

(dolist (pkg pkg-list)
  (when (package-installed-p pkg)
    (package-delete pkg)))

But it doesn't work.

3
  • 1
    What do you mean by "it doesn't work"? Do you get any errors or it doesn't do what you wanted it to?
    – user12563
    Commented Jun 23, 2018 at 14:28
  • I get this Debugger entered--Lisp error: (wrong-type-argument package-desc rust-mode). The code is working with package-install.
    – bertfred
    Commented Jun 23, 2018 at 14:40
  • 1
    Put the error message in the question. Comments can be deleted at any time. As it stands now, the question risks being deleted because it is unclear. Describe what you mean by "it doesn't work".
    – Drew
    Commented Jun 23, 2018 at 20:41

1 Answer 1

3

In a case like this you can inspect the function to see what it does with the interactive form. That is, use C-h f package-delete, then follow the link to the source, and then look at the (interactive ...) bit. You'll also see in the docstring that the function expects a cl struct.

The code for this function is a bit convoluted, but eventually you can see that it is looking up in package-alist. So you can use:

(dolist (pkg pkg-list)
  (when (package-installed-p pkg)
    (package-delete (car (cdr (assoc pkg package-alist))))))
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.