help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: python-shell-send-region uses wrong encoding?


From: Andreas Röhler
Subject: Re: python-shell-send-region uses wrong encoding?
Date: Wed, 30 Oct 2013 07:45:07 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0

Am 30.10.2013 04:20, schrieb Stefan Monnier:
E.g. the patch below (which causes python-shell-send-string to tell
Python that the file sent is using utf-8) should fix your problem (tho
it's not a proper fix, since we shouldn't hardcode utf-8 here, but copy
which ever -*- coding: -*- coding is in the file).

I installed a variant of that patch in Emacs's trunk, which should fix
the problem.  The relevant part of the patch is quoted below, so you can
try it out,


         Stefan


=== modified file 'lisp/progmodes/python.el'
--- lisp/progmodes/python.el    2013-10-07 18:51:26 +0000
+++ lisp/progmodes/python.el    2013-10-30 01:28:36 +0000
@@ -2045,7 +2051,9 @@
                      (concat (file-remote-p default-directory) "/tmp")
                    temporary-file-directory))
                 (temp-file-name (make-temp-file "py"))
+               (coding-system-for-write 'utf-8)
                 (file-name (or (buffer-file-name) temp-file-name)))
            (with-temp-file temp-file-name
+            (insert "# -*- coding: utf-8 -*-\n")
              (insert string)
              (delete-trailing-whitespace))




IIUC the second added line "-*- coding: utf-8 -*-\n" should not be needed, as 
that's the default at the Python side anyway.

Also functions tracing a possibly error might see a different line-offset that 
way - just an abstract reasoning so far.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]