Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

How can I prevent this? Right now, I have this code in my .emacs:

(if featurep 'python)
    (unload-feature 'python))

That seems to reduce the instances of this happening, but sometimes I'll open a python file -- in the same session! -- and it'll get the python.el python-mode instead of the python-mode.el version. And yet, the next buffer over still has the old mode.

This is quickly driving me bananas!

share|improve this question
add comment

4 Answers

up vote 6 down vote accepted

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")
share|improve this answer
add comment

Should it happen again, it signals a bug in python-mode.el too. Python-mode.el – that's my endeavour – should be designed in a way, python.el does not disturb, even if loaded.

In case, please make an entry at the bug-tracker.

share|improve this answer
add comment

the following link may also be relevant..

http://permalink.gmane.org/gmane.emacs.cedet/4935

i use python-mode and despite the above advised code featuring in my .emacs, i still had to do things like..

M-x py-pdbtrack-toggle-stack-tracking  ; followed by..
M-x python-pdbtrack-toggle-stack-tracking

..to actually turn off a feature.

the culprit was the wisent-python.el python.el dependency which caused the re-loading of some common variable defs. i commented the (require 'python nil t) as i already manually define the include path that it (the code requiring this file) sets up anyway.

share|improve this answer
add comment

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

share|improve this answer
    
The problem there is that the .el.gz file is part of the core Emacs distribution, over in non-user-space. –  Chris R Feb 14 '10 at 16:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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