emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: pierre.techoueyres@free.fr (Pierre Téchoueyres)
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: org-mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Add new keyword :coding for #+include directive
Date: Tue, 15 May 2018 01:44:08 +0200	[thread overview]
Message-ID: <87y3gl6bw7.fsf@killashandra.ballybran.fr> (raw)
In-Reply-To: <87o9hqrr54.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Tue, 08 May 2018 19:31:03 +0200")

[-- Attachment #1: Type: text/plain, Size: 2269 bytes --]

Hello,
And sorry for the delay.


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> pierre.techoueyres@free.fr (Pierre Téchoueyres) 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. 

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,

[-- Attachment #2: test.org --]
[-- Type: text/x-org, Size: 383 bytes --]

# -*- coding: utf-8 -*-
#+title: test with different encodings.

* Pierre Téchoueyres
  bad
  #+include: "./file.cmd.txt" src bat
  or
  #+include: "./file.sh.txt" src sh

  and good ? 
  #+include: "./file.cmd.txt" src bat :coding iso-8859-15-dos
  or
  #+include: "./file.sh.txt" src sh :coding iso-8859-15-unix
 

# Local Variables:
# coding: utf-8-unix
# End:

[-- Attachment #3: file.cmd --]
[-- Type: text/plain, Size: 120 bytes --]

@echo off

echo Hello Pierre TÚchoueyres ñ

rem Local Variables:
rem coding: cp850-dos
rem mode: bat
rem End:

[-- Attachment #4: file.sh --]
[-- Type: text/plain, Size: 140 bytes --]

#!/bin/sh # -*- coding: iso-8859-15-unix -*-

echo "Hello Pierre Téchoueyres"

# Local Variables:
# coding: iso-8859-15-unix
# End:

  reply	other threads:[~2018-05-14 23:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 19:52 [PATCH] Add new keyword :coding for #+include directive Pierre Téchoueyres
2018-04-16 21:30 ` Pierre Téchoueyres
2018-04-17  8:36   ` Nicolas Goaziou
2018-04-18 18:40     ` Pierre Téchoueyres
2018-04-20 23:08       ` Pierre Téchoueyres
2018-04-23 10:27         ` Nicolas Goaziou
2018-04-23 19:44           ` Pierre Téchoueyres
2018-04-24 21:59             ` Nicolas Goaziou
2018-04-24 22:57               ` Pierre Téchoueyres
2018-05-04 22:41                 ` Pierre Téchoueyres
2018-05-08 17:31                   ` Nicolas Goaziou
2018-05-14 23:44                     ` Pierre Téchoueyres [this message]
2018-05-19 13:13                       ` Nicolas Goaziou
2018-05-19 16:09                         ` Pierre Téchoueyres
2018-05-20  7:33                           ` Nicolas Goaziou
2018-05-24 21:29                             ` Pierre Téchoueyres
2018-06-02 10:13                               ` Nicolas Goaziou
2018-06-08 19:21                                 ` Pierre Téchoueyres
2018-06-13 13:39                                   ` Nicolas Goaziou

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87y3gl6bw7.fsf@killashandra.ballybran.fr \
    --to=pierre.techoueyres@free.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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/org-mode.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).