From mboxrd@z Thu Jan 1 00:00:00 1970 From: pierre.techoueyres@free.fr (Pierre =?utf-8?Q?T=C3=A9choueyres?=) Subject: Re: [PATCH] Add new keyword :coding for #+include directive Date: Tue, 15 May 2018 01:44:08 +0200 Message-ID: <87y3gl6bw7.fsf@killashandra.ballybran.fr> References: <87tvsbx72g.fsf@killashandra.ballybran.fr> <87in8qyh3t.fsf@killashandra.ballybran.fr> <874lkakz58.fsf@nicolasgoaziou.fr> <87muy0b4kw.fsf@killashandra.ballybran.fr> <87in8lh3xk.fsf@killashandra.ballybran.fr> <87zi1uqkta.fsf@nicolasgoaziou.fr> <87in8hd7xe.fsf@killashandra.ballybran.fr> <87zi1sl0yq.fsf@nicolasgoaziou.fr> <874lk01ad6.fsf@killashandra.ballybran.fr> <871serrqla.fsf@killashandra.ballybran.fr> <87o9hqrr54.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIN8b-0002Jt-I8 for emacs-orgmode@gnu.org; Mon, 14 May 2018 19:44:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIN8W-00088b-MD for emacs-orgmode@gnu.org; Mon, 14 May 2018 19:44:17 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:5312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fIN8W-00083V-Be for emacs-orgmode@gnu.org; Mon, 14 May 2018 19:44:12 -0400 In-Reply-To: <87o9hqrr54.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Tue, 08 May 2018 19:31:03 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: org-mode --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, And sorry for the delay. Nicolas Goaziou writes: > Hello, > > pierre.techoueyres@free.fr (Pierre T=C3=A9choueyres) writes: > >> Hello Nicolas, >> Did you have time to review the patches ? > > Sorry for the delay, I have been sidetracked. > > I admit I don't fully understand your bugfix patch, i.e., "[PATCH] > Correctly convert encoding of included files". > > For the record, here is the change: > > (with-temp-buffer > - (insert-file-contents file) > + (let ((org-buffer-coding-system buffer-file-coding-system)) > + (insert-file-contents file) > + (unless (eq org-buffer-coding-system buffer-file-coding-system) > + (set-buffer-file-coding-system org-buffer-coding-system))) > > > You pretend `org-buffer-coding-system' is storing coding-system from the > Org buffer, but the let-binding happens from within `with-temp-buffer'. > So the coding system comes from the temporary buffer instead.=20 Yes, that's true, but the coding system of the temporary buffer is inherited of the one of the org file (At least it's what I've found in my tests). But my be should I add a comment to explain that. > > Also, `insert-file-contents' is not supposed to change coding system, or > is it? So when would the `unless' be triggered? > For the tests I've made and the examples I had sent, it seem to change the coding system. > Could you explain a bit the issue you are fixing here? > > Thank you. > > Regards, I hoped the example Ive had sent was clear enough. I'm using org on an Windows machine where the default encoding seem to be iso-latin-1-dos. But I edit my org files in utf-8 encoding and of course I want to include some files as source files for reference. Thoses files are sometime encoded wit an different coding system (espetially cmd files with comments in french : cp850). I use principally those coding ystems : - cmd : cp850 - org : utf-8 or iso8859-15 - sql : window1252-dos But when I include thoses files their content isn't correctly inserted, especially the accents. Hope I'me clearer now. I reattach the examples, but note that the cmd.txt or sh.txt extensions are only there to avoid my mail to be wiped out. Regards, --=-=-= Content-Type: text/x-org; charset=utf-8 Content-Disposition: attachment; filename=test.org Content-Transfer-Encoding: quoted-printable Content-Description: test.org # -*- coding: utf-8 -*- #+title: test with different encodings. * Pierre T=C3=A9choueyres bad #+include: "./file.cmd.txt" src bat or #+include: "./file.sh.txt" src sh and good ?=20 #+include: "./file.cmd.txt" src bat :coding iso-8859-15-dos or #+include: "./file.sh.txt" src sh :coding iso-8859-15-unix =20 # Local Variables: # coding: utf-8-unix # End: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=file.cmd.txt Content-Transfer-Encoding: quoted-printable Content-Description: file.cmd @echo off echo Hello Pierre T=C3=9Achoueyres =C3=B1 rem Local Variables: rem coding: cp850-dos rem mode: bat rem End: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=file.sh.txt Content-Transfer-Encoding: quoted-printable Content-Description: file.sh #!/bin/sh # -*- coding: iso-8859-15-unix -*- echo "Hello Pierre T=C3=A9choueyres" # Local Variables: # coding: iso-8859-15-unix # End: --=-=-=--