Home » Questions » Computers [ Ask a new question ]

How can I prevent the python.el that ships with Emacs 23 from EVER loading?

How can I prevent the python.el that ships with Emacs 23 from EVER loading?

I use python-mode.el instead of python.el for python work, and all of my customizations depend on it. However, periodically for some reason the python.el that ships with Emacs23 will magically get loaded and suddenly all of my configuration just goes out the window.

Asked by: Guest | Views: 373
Total answers/comments: 2
bert [Entry]

"It all depends on how you've set up your .emacs.

By default, the function 'python-mode is associated with the package python.el. You need to change that with the following:

(autoload 'python-mode ""python-mode"" ""Python Mode."" t)

That assumes the python-mode package is already on your load-path. You'll also need to be sure that the above happens in your .emacs before anything causes the python.el to be loaded.

These other two lines are probably not needed, but don't hurt:

(add-to-list 'auto-mode-alist '(""\\.py\\'"" . python-mode))
(add-to-list 'interpreter-mode-alist '(""python"" . python-mode))

If that doesn't work, then we'll need more information.

Another alternative is to override the functions that are auto-loaded from python.el, which as of Emacs 23.1 are the following:

(defun run-python (&rest args) nil)
(defun python-mode (&rest args) nil)
(defun jython-mode (&rest args) nil)
(defun python-shell (&rest args) nil)

If you define those in your .emacs, then the autoloads that Emacs sets up will have no effect. You'll have to load python-mode.el manually (since the autoload for python-mode doesn't need to be run (because you defined that function)). Load the python-mode.el with:

(load ""/path/to/python-mode.el"")"
bert [Entry]

You should be able to simply remove python.el (and perhaps the .elc? Is that still the extension for the compiled file)