From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-15?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: python-shell-send-region uses wrong encoding? Date: Wed, 30 Oct 2013 07:45:07 +0100 Message-ID: <5270AAF3.5040906@easy-emacs.de> References: <20131029113044.GA28039@doriath.local> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1383115382 24582 80.91.229.3 (30 Oct 2013 06:43:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Oct 2013 06:43:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 30 07:43:05 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VbPUc-0003JS-QD for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Oct 2013 07:43:02 +0100 Original-Received: from localhost ([::1]:50692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbPUc-0001KX-Eb for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Oct 2013 02:43:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbPUL-0001KS-LR for help-gnu-emacs@gnu.org; Wed, 30 Oct 2013 02:42:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbPUE-0004E5-Bj for help-gnu-emacs@gnu.org; Wed, 30 Oct 2013 02:42:45 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.187]:54918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbPUE-0004E1-27 for help-gnu-emacs@gnu.org; Wed, 30 Oct 2013 02:42:38 -0400 Original-Received: from purzel.sitgens (brln-4d0c7d89.pool.mediaWays.net [77.12.125.137]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LkSV9-1WDUBz3GYd-00cCul; Wed, 30 Oct 2013 07:42:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: X-Provags-ID: V02:K0:eHWNHKopUXuuXROZXDkf/uSKjo6W6uX97xKl58tnWDW 0t5QAWODrzc/zstu0+6j2StumbL/CpVPL5Ok/Q0ekPTeLmEqnX 9TaQdtNXhm+VRjGIOjZ/4+t7Nu3sV+C/986/2vzWm24ZGAM7MY fpkUkDv2YA20tPeUZJxNKZ1ZI+u1dfvEP4bcX4xTpl3Lk6YG1D 2k33HxLeTAkp1e44F1xrdhMbzSatqPTULEBgxpR2PZsdzhb8Oz ReSPAluoDrFcc2icSaHWOnI0yLt3q5hpYOGgt8xglXGNsBs6ir Ph6dEgOLmLPVx4z6FU0XfucITtKq6LeQnNxs6b9gbqmN66xVJ2 JYHeE4rr/8g7Gtret77DCmEAQkDukl30FLhE9sCmK X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.126.187 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94267 Archived-At: 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.