unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Slawomir Nowaczyk <slawomir.nowaczyk.847@student.lu.se>
Subject: python.el patch: compilation-fake-loc broken
Date: Mon, 28 Aug 2006 13:23:32 +0200	[thread overview]
Message-ID: <20060828131329.397B.SLAWOMIR.NOWACZYK.847@student.lu.se> (raw)

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.

             reply	other threads:[~2006-08-28 11:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-28 11:23 Slawomir Nowaczyk [this message]
2006-08-28 21:13 ` python.el patch: compilation-fake-loc broken Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060828131329.397B.SLAWOMIR.NOWACZYK.847@student.lu.se \
    --to=slawomir.nowaczyk.847@student.lu.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).