2

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 helpm), 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-xinfoRet mm ElispRet mm DebuggingRet mm EdebugRet

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.

  • 1
    Using grep on the Emacs sources will not work as they're usually compressed files. FWIW, I can find a python-rx macro in python.el via M-x find-library RET python RET. – wasamasa Jun 27 '15 at 15:20
  • 1
    Also, make sure it's not your starter kit by trying to reproduce this with emacs -q. – wasamasa Jun 27 '15 at 15:21
  • @wasamasa ok that was it. Things work with emacs-q, so I have to figure out what in the starter kit manages to kill the built-in python support. Thanks also for the find-library hint -- I didn't know about that one. – Reb.Cabin Jun 27 '15 at 15:33
  • @Dan it was fun figuring out how to debug the built-in elisp code. Another great thing about emacs is that all the tools for creating emacs in the first place are built-in, online, embedded, available, documented, and that "we-the-people" are "empowered" to debug and fix the thing :) – Reb.Cabin Jun 27 '15 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.