I installed Emacs 24.5 using homebrew
$ brew install emacs
and the Emacs-Live package collection. Most things work really well, but I'd like to get a python IDE going in emacs (so I don't have to leave emacs to run python, etc.)
First, I open up one of my python programs, foo.py:
print 42
and verify this works from the shell:
M-xshell
$ python foo.py
42
Great. The underpinnings seem to be working.
Following the minor-mode help (M-x help
m), which shows many key bindings, I now start the python subprocess:
C-cC-p
Python 2.7.10 (default, Jun 10 2015, 19:42:47)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Now I try to send my program to this subprocess:
C-cC-c
Wrong type argument: stringp, nil
Uh-oh. Ok, I can deal with this. Back to *Help*
mode. M-xhelp
, find the entry for C-cC-c
C-c C-c python-shell-send-buffer <<<--- that's a hyperlink
clink on the hyperlink:
python-shell-send-buffer is an interactive compiled Lisp function in
`python.el'. <<<--- that's a hyperlink
click on that hyperlink:
(defun python-shell-send-buffer (&optional send-main)
"Send the entire buffer to inferior Python process.
When optional argument SEND-MAIN is non-nil, allow execution of
...etc...
put the point
cursor in the defun
and press C-uC-M-x, which instruments the function for Edebug
. Another C-cC-c in my python buffer and Edebug
stops in this function. Info-mode has full documentation of Edebug
,
M-xinfo
Ret
mm Elisp
Ret
mm Debugging
Ret
mm Edebug
Ret
and I do lots of stepping into and checking stuff, which I won't repeat here. Suffice to say, I eventually find the offending line inside python.el, line 4138
(set (make-local-variable 'outline-regexp)
(python-rx (* space) block-start))
When I try to step into this call of python-rx, Edebug either tells me that it can't find function python-rx,
Symbol's function definition is void: python-rx
or emacs goes into the weeds and I have to Force-Kill it, depending on how much other stuff I've done in the debugger session. I try looking for python-rx
M-x find-grep-dired
/usr/local/Cellar/emacs/24.5/share/emacs/24.5/lisp/progmodes
(I think this is where homebrew puts emacs lisp code for program modes)
python-rx
nothing found :(
I find it hard to believe that python mode is actually broken in this distro -- millions would have picked up their pitchforks and torches and taken to the streets. It must be something I've done wrong. I'd be grateful for any advice.
grep
on the Emacs sources will not work as they're usually compressed files. FWIW, I can find apython-rx
macro inpython.el
viaM-x find-library RET python RET
.emacs -q
.find-library
hint -- I didn't know about that one.