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: Mon, 16 Apr 2018 23:30:14 +0200 Message-ID: <87in8qyh3t.fsf@killashandra.ballybran.fr> References: <87tvsbx72g.fsf@killashandra.ballybran.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8Bha-0003yH-P4 for emacs-orgmode@gnu.org; Mon, 16 Apr 2018 17:30:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8BhZ-0003RE-6F for emacs-orgmode@gnu.org; Mon, 16 Apr 2018 17:30:18 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:1984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f8BhY-0003Q8-M2 for emacs-orgmode@gnu.org; Mon, 16 Apr 2018 17:30:17 -0400 Received: from killashandra.ballybran.fr.free.fr (unknown [IPv6:2a01:e35:2e14:eab0:b51f:3dc7:7e03:942]) by smtp4-g21.free.fr (Postfix) with ESMTPS id CBB4519F58D for ; Mon, 16 Apr 2018 23:30:14 +0200 (CEST) In-Reply-To: <87tvsbx72g.fsf@killashandra.ballybran.fr> ("Pierre \=\?utf-8\?Q\?T\=C3\=A9choueyres\=22's\?\= message of "Mon, 16 Apr 2018 21:52:23 +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: org-mode --=-=-= Content-Type: text/plain Hello org's developpers, Sorry, I forgot the patch. so here is the whole mail + patch: I want to propose the attached patch which allow you to specify an optionnal `:coding' keyword to the `#+INCLUDE:' directive. This allow you to specify something like #+begin_example ,#+INCLUDE: "myfile.cmd" src cmd :coding "cp850-dos" #+end_example Which allow you to have different encoding for your various sources files. This allow me to include localised Microsoft Windows batch sources inside my utf-8-unix org-files. Thanks in advance for your remarks. Pierre --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-new-keyword-coding-for-include-directive.patch Content-Description: add-keyword-to-include >From 5200ea1fed3f13f429615baa0f196f512ca47fe7 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..7a526d737 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..9423ae090 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 +\"\\([^\"]+\\)\"" 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 "\\