I wish I had the time to merge the two python modes into one so that we
all use a single python mode rather than two. I never seem to be able
to find that time. Below I provide my past efforts to support both in
my environment and explain why I just gave up.
First I created a boolean flag to switch between the two:
(defvar kimr-use-python-mode nil
"If non-nil, then enable the use of python-mode.el from python.org.
Default is nil which means to use the built-in python.el.")
Second I created an ELPA package called python-mode consisting of a
$ cd ~/elpa-kimr/python-mode
$ ls -l
-rw-r--r-- 1 kimr kimr 85097 Oct 10 2011 doctest-mode.el
-rw-r--r-- 1 kimr kimr 786 Oct 10 2011 NEWS
-rw-r--r-- 1 kimr kimr 1581 Oct 10 2011 pycomplete.el
-rw-r--r-- 1 kimr kimr 3274 Oct 10 2011 pycomplete.py
-rw-r--r-- 1 kimr kimr 169873 Apr 20 17:11 python-mode.el
-rw-rw-r-- 1 kimr kimr 5148 Mar 2 2012 pyton-mode.texi
-rw-r--r-- 1 kimr kimr 316 Oct 10 2011 README
drwxr-xr-x 3 kimr kimr 4096 Oct 10 2011 website
Also I created another package consisting of a few other python packages
that I downloaded:
$ cd ~/elpa-kimr/python-utils/
$ ls -l
-rw-r--r-- 1 kimr kimr 20856 Oct 10 2011 ipython.el
-rw-r--r-- 1 kimr kimr 3421663 Oct 10 2011 pylookup.db
-rw-r--r-- 1 kimr kimr 9137 Oct 10 2011 pylookup.el
-rwxr-xr-x 1 kimr kimr 7282 Oct 10 2011 pylookup.py
-rw-r--r-- 1 kimr kimr 33613 Oct 10 2011 pymacs.el
-rw-r--r-- 1 kimr kimr 4083 Oct 10 2011 python-pep8.el
-rw-r--r-- 1 kimr kimr 4170 Oct 10 2011 python-pylint.el
Third I use this flag to do things differently for the two modes.
For example I turn on python-mode and python-utils packages only if I'm
kimr-package-activate is a thin wrapper which adds an item to
package-load-list then calls (package-initialize).
Some, if not all, of the files in python-utils above work only for
python-mode.el, but not for the built-in python.el.
That is why I turn on these only when I'm using python-mode.el.
Also you have to be very careful to prevent loading the built-in
python.el if you are using python-mode.el, because the two define many
functions with the same names, but which behave differently.
So I tried the following:
;; Autoloading for python-mode does not work, because of conflict with built-in
;; python.el. Also something within emacs seems to have (require 'python) so
;; that if 'python-mode is loaded first, then (require 'python) later on
;; clobbers python-mode.
(defun kimr-disable-built-in-python-mode ()
"Call this to improve chances of lisp/progmodes/python.el not getting loaded
accidentally. This should be called after loading python-mode.el."
(defun jython-mode ())
(defun python-after-info-look ())
(defun python-backspace (arg))
(defun python-beginning-of-block (&optional arg))
(defun python-check (command))
(defun python-describe-symbol (symbol))
(defun python-electric-colon (arg))
(defun python-end-of-block (&optional arg))
(defun python-expand-template (name))
(defun python-fill-paragraph (&optional justify))
(defun python-find-function (name))
(defun python-find-imports ())
(defun python-guess-indent ())
(defun python-indent-line ())
(defun python-load-file (file-name))
(defun python-mark-block ())
(defun python-next-statement (&optional count))
(defun python-pdbtrack-toggle-stack-tracking (arg))
(defun python-previous-statement (&optional count))
(defun python-send-buffer ())
(defun python-send-defun ())
(defun python-send-region (start end))
(defun python-send-region-and-go (start end))
(defun python-send-string (string))
(defun python-set-proc ())
(defun python-setup-brm ())
(defun python-shell (&optional argprompt))
(defun python-shift-left (start end &optional count))
(defun python-shift-right (start end &optional count))
(defun python-switch-to-python (eob-p))
(defun python-toggle-shells (arg))
(defun run-python (&optional cmd noshow new))
(defun turn-off-pdbtrack ())
(defun turn-on-pdbtrack ())
After all this effort, I got fed up and gave up.
I'm going to just stick with built-in python.el and hope that someone
figures out a way to merge the two modes.
> David Engster <firstname.lastname@example.org> writes:
>> This little Python issue has haunted us for years. I've now started a
>> thread on Emacs-devel which hopefully will settle this issue once and
>> for all. The Python situation on Emacs is really... complicated.
> Thank you for your attention, I'll follow the thread.
I've now pushed a change that uses python-shell-internal-send-string. I
have no idea whether that also works for the external
python-mode. However, I'm not fond of supporting two different python
modes in the first place. The Python support in CEDET is lacking anyway,
so I'd rather not make it more complicated.
We can apply small changes if necessary (for example regarding the
initial require statement), but otherwise python-mode should provide the
necessary aliases, or advice CEDET functions as necessary.
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
Cedet-devel mailing list