I can't help with what shows up when you do M+x package-list-packages
, but to clean-up the command namespace (minibuffer prompt, functions available to you in lisp, etc) there are a few hacks.
The workaround
You might be seeing functions even after deletion due to residual autoload files. Firstly you need to find out what are the locations of the different packages. You can use locate-library
for that. The library name is whatever you would write in a require
statement if you were to use the library. For example, on my system (locate-library "org")
returns "/home/user/build/org-mode/lisp/org.elc"
. Once you have located the libraries, you can clean up the namespace with something like this:
;; clean load-path
(setq load-path
(delq nil (mapcar
(function (lambda (p)
(unless (string-match "lisp\\(/packages\\)?/org$" p)
p)))
load-path)))
;; remove property list to defeat cus-load and remove autoloads
(mapatoms (function (lambda (s)
(let ((sn (symbol-name s)))
(when (string-match "^\\(org\\|ob\\|ox\\)\\(-.*\\)?$" sn)
(setplist s nil)
(when (eq 'autoload (car-safe s))
(unintern s)))))))
Source: org-mode.git/testing/org-batch-test-init.el
Background information
I use the above snippet to clean up the builtin Org mode before I setup the bleeding edge. Of course you would need to update the regular expressions according to the packages you are trying to delete.
How it works
The first part of the snippet cleans up the load-path
. This is only necessary for big packages like Org that reside in their own directory in a typical Emacs distribution. For smaller modes, say a programming mode like ruby-mode
, this isn't necessary.
Now to adapt the above regexes to your needs, you need to experiment a bit. Try evaluating these with C+j in the lisp interaction (*scratch*
) buffer:
(locate-library "ruby-mode")
"/opt/lisp/share/emacs/27.0.50/lisp/progmodes/ruby-mode.elc"
(locate-library "tetris")
"/opt/lisp/share/emacs/27.0.50/lisp/play/tetris.elc"
Your load-path
probably has these: "[..]/lisp/play", "[..]/lisp/progmodes". Unless you want to remove all progmodes, to "remove" ruby-mode
you can skip the first part. On the other hand, if you want to remove all games, you might want to include the play directory. The corresponding regex then becomes: "lisp\\(/packages\\)?/play$"
(the "packages" portion of the regex is an optional match, see: (info "(elisp)Syntax of Regexps")
).
For the second part: clearing your namespace, you need to construct the regex based on what prefix is being used by the library in question. So for ruby-mode
and tetris
, you might try: "^\\(ruby\\|tetris\\)\\(-.*\\)?$"
. I hope this gets you started. Some experimentation in the scratch buffer is your friend :)