From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Slawomir Nowaczyk Newsgroups: gmane.emacs.devel Subject: python.el patch: compilation-fake-loc broken Date: Mon, 28 Aug 2006 13:23:32 +0200 Message-ID: <20060828131329.397B.SLAWOMIR.NOWACZYK.847@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1156764258 25301 80.91.229.2 (28 Aug 2006 11:24:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Aug 2006 11:24:18 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 28 13:24:15 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GHfDo-0005Td-93 for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2006 13:24:04 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GHfDn-00089w-MZ for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2006 07:24:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GHfDc-00088i-MZ for emacs-devel@gnu.org; Mon, 28 Aug 2006 07:23:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GHfDW-000866-PG for emacs-devel@gnu.org; Mon, 28 Aug 2006 07:23:51 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GHfDW-00085o-HO for emacs-devel@gnu.org; Mon, 28 Aug 2006 07:23:46 -0400 Original-Received: from [130.235.16.11] (helo=himmelsborg.cs.lth.se) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GHfMS-00015j-FY for emacs-devel@gnu.org; Mon, 28 Aug 2006 07:33:00 -0400 Original-Received: from [127.0.0.1] (slawek@dain [130.235.16.76]) by himmelsborg.cs.lth.se (8.13.6/8.13.6/perf-jw-tr) with ESMTP id k7SBNfvV017339 for ; Mon, 28 Aug 2006 13:23:43 +0200 (CEST) Original-To: emacs-devel@gnu.org X-Esmandil_Citation: done X-Mailer-Plugin: Popup Memopad for Becky!2 Ver.0.02 Rev.2 X-Mailer: Becky! ver. 2.25.02 [en] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58990 Archived-At: 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 ( slawomir.nowaczyk.847@student.lu.se ) War doesn't determine who's right, war determines who's left.