Emacs C-c C-c用于python码 [英] Emacs C-c C-c for python code

查看:84
本文介绍了Emacs C-c C-c用于python码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用emacs作为一个IDE来蟒蛇。我有pymode和Ropemacs活跃。我的理解是,我应该能够突出一个区域,然后使用C-c C-c将其发送到交互式终端。有没有额外的包,我需要完成这个?



我得到的Cc Cc的错误是:

 错误的类型参数:integer-or-marker-p,nil 

我也看到这个链接有一个声明,但这看起来不像我的错误。



更新回答Zack



要设置该变量,进入emacs,并做到这一点:

 (setq debug-on-error t)

然后 Mx eval-region



(这是正确的方式设置为true吗?)



然后这是我调试器中出现的:

 调试器输入 -  Lisp错误:(错误类型参数整数或 - 标记 -  p nil)
count-lines(1 nil)
(保存限制(加宽)(count-lines(point-min))(或(和(eq start(line-beginning-位置))(not(eobp))(1+ start))start)))
(let *((windows-config(window-configuration-to-register 313465889)))(origline(save-restriction )(count-lines(point-min)(或(和(eq start ...)(not ...)(1+ start))start))))(py-shell-name(或shell(py- select-shell)))(py-exception-buffer(current-buffer))(execute-directory(cond((condition-case nil(progn(file-name-directory ...))(error nil))) (和py-use-current-dir-when-execute-p(buffer-file-name))(file-name-directory(buffer-file-name)))((和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)((getenvVIRTUAL_ENV )()()()()()()(文件名(扩展名 - 文件名 - 文件名) )(py-orig-buffer-or-file(或filename(current-buffer)))(proc(或proc(if py-dedicated-process-p(get-buffer-process(py-shell nil py-dedicate d-process-p py-shell-name py-buffer-name t))(或(and(boundp ...)(get-buffer-process py-buffer-name))(get-buffer-process(py- (python) - (python) - (python) - (python) (python-mode-v5-behavior-p(py-execute-python-mode-v5 start end))(py-execute-no-temp-p(py-execute-ge24\ 。(启动结束文件名执行目录))((或文件(和(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/home/mittenchops/gh/myscript.pynil/ home / )
(setq erg(py-execute-base nil nil文件nil(或(和(boundp(quote py-orig-buffer-or-file))py-orig-缓冲区或文件)文件)))
(if(file-readable-p file)(setq erg(py-execute-base nil nil file nil(或(and(boundp te py-orig-buffer-or-file))py-orig-buffer-or-file))))(消息%s不可读。 %s文件你有写权限?))
(let(erg)(if(file-readable-p file))(setq erg(py-execute-base nil nil file nil和(boundp(引用py-orig-buffer-or-file))py-orig-buffer-or-file)))(消息%s不可读。%s文件你有写权限吗? ))
py-execute-file(/ home / mittenchops / gh / myscript.py)
(let *((py-master-file(或py-master-file -fetch-py-master-file)))(文件(如果是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-np缓冲区已更改,先保存?)(progn(write-file(buffer-file-name))(py-execute-buffer-base))(py-execute-region(point-min) -max)))
(if(和py-prompt-on-changed-p(buffer-file-name)(interactive-p)(buffer-modified-p))(if(y-or-np 缓冲区已更改,先保存?)(progn(write-file(buffer-file-name))(py-execute-buffer (py-execute-region(point-min))(py-execute-region(point-min)(point-max))(if(buffer-file-name) )(point-max)))
py-execute-buffer()
调用交互式(py-execute-buffer nil nil)


解决方案

显示的错误来自python-mode.el中的一个错误,它在trunk中已修复。 AFAIK仅在执行非保存缓冲区时发生错误,因此先保存缓冲区使 Cc Cc 工作。



BTW py-execute-区域RET是 Cc | ,而 Cc Cc 将始终发送整个缓冲区,而不管现有区域。如果 C-c C-c 应该尊重一个区域,这可能值得一个功能请求。如有兴趣,请在这里提交:



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



仍然是一个个人视图:标记一个区域是昂贵的 - 例如这是一件艰巨的事情,因为它需要一些注意力来界定边界权利,这在边缘问题上更好地利用。 Python模式将通过提供几个命令执行任务来从您处理这些工作。也许看看菜单Python,请参阅执行...部分和按钮更多...。以类似的方式,几个其他的编辑应该更容易。


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)

解决方案

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.

这篇关于Emacs C-c C-c用于python码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆