1

I'm new to using emacs as an IDE to python. I have pymode and Ropemacs active. My understanding is that I should be able to highlight a region then use C-c C-c to send it to an interactive terminal. Are there additional packages that I need to accomplish this?

The error I'm getting for C-c C-c is:

Wrong type argument: integer-or-marker-p, nil

I saw also this link had a statement on that, but that didn't look like my error.

Update answering Zack

To set that variable, I went into emacs scratch and did this:

(setq debug-on-error t)

Then M-x eval-region

(Is that the right way to set that to true?)

Then this is what appeared in my debugger:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  count-lines(1 nil)
  (save-restriction (widen) (count-lines (point-min) (or (and (eq start (line-beginning-position)) (not (eobp)) (1+ start)) start)))
  (let* ((windows-config (window-configuration-to-register 313465889)) (origline (save-restriction (widen) (count-lines (point-min) (or (and (eq start ...) (not ...) (1+ start)) start)))) (py-shell-name (or shell (py-choose-shell))) (py-exception-buffer (current-buffer)) (execute-directory (cond ((condition-case nil (progn (file-name-directory ...)) (error nil))) ((and py-use-current-dir-when-execute-p (buffer-file-name)) (file-name-directory (buffer-file-name))) ((and py-use-current-dir-when-execute-p py-fileless-buffer-use-default-directory-p) (expand-file-name default-directory)) ((stringp py-execute-directory) py-execute-directory) ((getenv "VIRTUAL_ENV")) (t (getenv "HOME")))) (py-buffer-name (or py-buffer-name (py-buffer-name-prepare))) (filename (and filename (expand-file-name filename))) (py-orig-buffer-or-file (or filename (current-buffer))) (proc (or proc (if py-dedicated-process-p (get-buffer-process (py-shell nil py-dedicated-process-p py-shell-name py-buffer-name t)) (or (and (boundp ...) (get-buffer-process py-buffer-name)) (get-buffer-process (py-shell nil py-dedicated-process-p py-shell-name ... t)))))) err-p) (set-buffer py-exception-buffer) (py-update-execute-directory proc py-buffer-name execute-directory) (cond (python-mode-v5-behavior-p (py-execute-python-mode-v5 start end)) (py-execute-no-temp-p (py-execute-ge24\.3 start end filename execute-directory)) ((or file (and (not (buffer-modified-p)) filename)) (py-execute-file-base proc filename nil py-buffer-name filename execute-directory)) (t (py-execute-buffer-finally start end execute-directory))))
  py-execute-base(nil nil nil "/home/mittenchops/gh/myscript.py" nil "/home/mittenchops/gh/myscript.py")
  (setq erg (py-execute-base nil nil nil file nil (or (and (boundp (quote py-orig-buffer-or-file)) py-orig-buffer-or-file) file)))
  (if (file-readable-p file) (setq erg (py-execute-base nil nil nil file nil (or (and (boundp (quote py-orig-buffer-or-file)) py-orig-buffer-or-file) file))) (message "%s not readable. %s" file "Do you have write permissions?"))
  (let (erg) (if (file-readable-p file) (setq erg (py-execute-base nil nil nil file nil (or (and (boundp (quote py-orig-buffer-or-file)) py-orig-buffer-or-file) file))) (message "%s not readable. %s" file "Do you have write permissions?")) erg)
  py-execute-file("/home/mittenchops/gh/myscript.py")
  (let* ((py-master-file (or py-master-file (py-fetch-py-master-file))) (file (if py-master-file (expand-file-name py-master-file) (buffer-file-name)))) (py-execute-file file))
  py-execute-buffer-base()
  (progn (write-file (buffer-file-name)) (py-execute-buffer-base))
  (if (y-or-n-p "Buffer changed, save first? ") (progn (write-file (buffer-file-name)) (py-execute-buffer-base)) (py-execute-region (point-min) (point-max)))
  (if (and py-prompt-on-changed-p (buffer-file-name) (interactive-p) (buffer-modified-p)) (if (y-or-n-p "Buffer changed, save first? ") (progn (write-file (buffer-file-name)) (py-execute-buffer-base)) (py-execute-region (point-min) (point-max))) (if (buffer-file-name) (py-execute-buffer-base) (py-execute-region (point-min) (point-max))))
  py-execute-buffer()
  call-interactively(py-execute-buffer nil nil)
2
  • 1
    Set debug-on-error to t, repeat the test, and post the traceback you get in the **Debug** window. (Then use M-x top-level to get out of the debugger. The Emacs debugger is horrible and you don't want to try to use it any more than you absolutely have to. But we do need that traceback.) Commented Jan 17, 2014 at 15:56
  • 2
    For future reference, Lisp variables can be set with M-x set-variable, which is likely to be more convenient than pulling up the scratch buffer. Tab completion and everything. Commented Jan 17, 2014 at 22:26

1 Answer 1

4

The error shown results from a bug in python-mode.el, which is fixed in trunk. AFAIK the bug only occurs when executing a non-saved buffer, so saving the buffer first makes C-c C-c work.

BTW py-execute-region RET is C-c |, while C-c C-c will always send the whole buffer, regardless of an existing region. If C-c C-c should honor a region, that might be worth a feature request. If interested, please file it here:

https://bugs.launchpad.net/python-mode

Still a personal view: marking a region as such is a costly--e.g. a laborious thing, as it requires some attention defining the borders right, which is spent better at the issue at stake itself. Python-mode will take a lot of this work from you by offering a couple of commands what-to-execute. Maybe have a look into the menu "Python", see section "Execute..." and button "More...". In a similar way a couple of other edits should be made easier.

Sign up to request clarification or add additional context in comments.

2 Comments

I've updated to 6.1.3 and still seem to have this error. I'm working with a saved buffer.
@Mittenchops Can't reproduce so far. Please open a ticket at bugs.launchpad.net/python-mode. Need some example code, the output of M-x report-emacs-bug RET and the recent traceback if available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.