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: Wed, 18 Apr 2018 20:40:32 +0200 Message-ID: <87muy0b4kw.fsf@killashandra.ballybran.fr> References: <87tvsbx72g.fsf@killashandra.ballybran.fr> <87in8qyh3t.fsf@killashandra.ballybran.fr> <874lkakz58.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8uOs-0001ua-3a for emacs-orgmode@gnu.org; Wed, 18 Apr 2018 17:13:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8uOo-0005vR-T1 for emacs-orgmode@gnu.org; Wed, 18 Apr 2018 17:13:58 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:40812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f8uOo-0005v0-Gw for emacs-orgmode@gnu.org; Wed, 18 Apr 2018 17:13:54 -0400 In-Reply-To: <874lkakz58.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Tue, 17 Apr 2018 10:36:35 +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 Content-Disposition: inline Hello, Nicolas Goaziou writes: > Hello, > ... >> This allow you to specify something like >> >> #+begin_example >> ,#+INCLUDE: "myfile.cmd" src cmd :coding "cp850-dos" >> #+end_example > > The quotes are not necessary. AFAICT, coding systems do not contain > spaces. Ok, I've reworked the rexexp to suppress them. New patch attached --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-new-keyword-coding-for-include-directive.patch Content-Description: include-with-coding > From fcf191842bea64442d69a0fcfa927a046d8fbd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= Date: Mon, 16 Apr 2018 21:20:17 +0200 Subject: [PATCH] Add new keyword :coding for #+include directive * lisp/ox.el (org-export-expand-include-keyword): Add new keyword `:coding' for specify the file encoding whith the `#+include:' directive. This allow to use somting like : when your org-file is encoded in utf-8. --- etc/ORG-NEWS | 10 ++++- lisp/ox.el | 117 +++++++++++++++++++++++++++++++---------------------------- 2 files changed, 71 insertions(+), 56 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 013c7b139..f285b7337 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -108,6 +108,14 @@ You can use =ob-scala.el= as packaged in scala-mode, available from the MELPA repository. ** New features +*** New keyword for ~#+include:~ directive +Add ~:coding "codign-system"~ keyword to allow include of files from +different codign system than the main org-file. +For example: +#+begin_example +,#+INCLUDE: "myfile.cmd" src cmd :coding cp850-dos +#+end_example + *** iCalendar export uses inheritance for TIMEZONE and LOCATION properties Both these properties can be inherited during iCalendar export, depending on the value of ~org-use-property-inheritance~. @@ -514,7 +522,7 @@ want to take over maintenance of this compatibility, please contact our mailing list. *** New syntax for export blocks - + Export blocks are explicitly marked as such at the syntax level to disambiguate their parsing from special blocks. The new syntax is diff --git a/lisp/ox.el b/lisp/ox.el index ea7d1dc81..f4c5660ff 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3326,6 +3326,12 @@ storing and resolving footnotes. It is created automatically." value) (prog1 (match-string 1 value) (setq value (replace-match "" nil nil value))))) + (coding + (intern (or (and (string-match + ":coding +\\<\\([a-z0-9\\-]+\\)\\>" value) + (prog1 (match-string 1 value) + (setq value (replace-match "" nil nil value)))) + (symbol-name buffer-file-coding-system)))) (env (cond ((string-match "\\" value) 'literal) ((string-match "\\ ... > Is it really an Org problem? E.g., couldn't you put a coding: cookie in > your ".cmd" file? IMO, the coding system depends on the includee, not > the includer. I tend to aggree with you that TRTDT is to put cookies or something inside the included file. But : a) This seem to not work as expected (see exemples joinned). b) Sometimes you can't modify the included file (ex: remote file access). --=-=-= 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.1.txt" src bat or #+include: "./file.2.txt" src sh =20 and good ?=20 #+include: "./file.1.txt" src bat :coding cp850-dos or #+include: "./file.2.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.1.txt Content-Transfer-Encoding: quoted-printable Content-Description: file.1.txt ::- -*- coding: cp850-dos -*- @echo off echo Hello Pierre T=C3=A9choueyres rem Local Variables: rem coding: cp850-dos rem End: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=file.2.txt Content-Transfer-Encoding: quoted-printable Content-Description: file.2.txt #!/bin/sh # -*- coding: iso-8859-15-unix -*- echo "Hello Pierre T=C3=A9choueyres" # Local Variables: # coding: iso-8859-15-unix # End: --=-=-= Content-Type: text/plain For a I can try to jump into the rabbit hole and find a solution (but for now I'm lost) Regards, --=-=-=--