[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
python.el patch: compilation-fake-loc broken
From: |
Slawomir Nowaczyk |
Subject: |
python.el patch: compilation-fake-loc broken |
Date: |
Mon, 28 Aug 2006 13:23:32 +0200 |
Hello,
One of the recent changes to python.el broke the association between
temporary files executed by Python and emacs buffers (basically,
compilation-fake-loc doesn't have any effect).
Try python-send-buffer on a buffer containing "assert False", switch to
Inferior Python buffer, put point on """ File "c:/temp/py4388_sF", line
1, in ?""" line, press RET. The point should be moved to the appropriate
place in a buffer, you should not be asked for a file to visit.
The reason, AFAIU, is that by the time compilation-fake-loc runs, the
error message has already been received by accept-process-output.
The following patch fixes things for me, but I am not entirely sure it
is the right fix.
**********************************************************************
--- m:/EmacsCVS/EmacsCVS/lisp/progmodes/python.el 2006-08-26
21:48:19.180332800 +0200
+++ c:/Emacs/lisp/progmodes/python.el 2006-08-28 13:13:04.022593600 +0200
@@ -1366,13 +1366,18 @@
;; be the place to check it, e.g. we might actually want to send
;; commands having set up such a state.
-(defun python-send-command (command)
+(defun python-send-command (command orig-start f)
"Like `python-send-string' but resets `compilation-shell-minor-mode'.
COMMAND should be a single statement."
(assert (not (string-match "\n" command)))
(let ((end (marker-position (process-mark (python-proc)))))
(with-current-buffer python-buffer (goto-char (point-max)))
(compilation-forget-errors)
+ (with-current-buffer (process-buffer (python-proc))
+ ;; Tell compile.el to redirect error locations in file `f' to
+ ;; positions past marker `orig-start'. It has to be done *after*
+ ;; `python-send-command''s call to `compilation-forget-errors'.
+ (compilation-fake-loc orig-start f))
;; Must wait until this has completed before re-setting variables below.
(python-send-receive (concat command "; print '_emacs_out ()'"))
(with-current-buffer python-buffer
@@ -1407,13 +1412,7 @@
;; Wrong if we had indented code at buffer start.
(set-marker orig-start (line-beginning-position 0)))
(write-region "if True:\n" nil f nil 'nomsg))
- (write-region start end f t 'nomsg)
- (python-send-command command)
- (with-current-buffer (process-buffer (python-proc))
- ;; Tell compile.el to redirect error locations in file `f' to
- ;; positions past marker `orig-start'. It has to be done *after*
- ;; `python-send-command''s call to `compilation-forget-errors'.
- (compilation-fake-loc orig-start f))))
+ (write-region start end f t 'nomsg)))
(defun python-send-string (string)
"Evaluate STRING in inferior Python process."
**********************************************************************
--
Best wishes,
Slawomir Nowaczyk
( address@hidden )
War doesn't determine who's right, war determines who's left.
- python.el patch: compilation-fake-loc broken,
Slawomir Nowaczyk <=