emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: nicholas.dokos@hp.com
Cc: Frederik <freak.fred@gmail.com>, emacs-orgmode@gnu.org
Subject: [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes.
Date: Mon, 11 Jul 2011 15:11:33 +0200	[thread overview]
Message-ID: <8762n9arne.fsf@gnu.org> (raw)
In-Reply-To: <6492.1310169884@alphaville.dokosmarshall.org> (Nick Dokos's message of "Fri, 08 Jul 2011 20:04:44 -0400")

[-- Attachment #1: 0001-org-latex.el-New-defcustom-org-export-latex-quotes-t.patch --]
[-- Type: text/x-patch, Size: 3699 bytes --]

From 08c8be7e0403f58a16670a84dbd66d7dd34c7b43 Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
Date: Mon, 11 Jul 2011 15:10:00 +0200
Subject: [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to
 control quotes.

* org-latex.el (org-export-latex-quotes): New defcustom.
(org-export-latex-quotation-marks): Use it.

This allows users to define what quotes they want to use as a
replacement of english double-quotes while exporting to LaTeX.

In particular, if you use the csquote package, you can configure
Org to output something like \endquote{some quoted text} instead
of "some quoted text".

Thanks to Frederik for bringing this issue up, and to Thomas S.
Dye, Nick Dokos and Stefan Nobis for elaborating this solution.
---
 lisp/org-latex.el |   53 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index e1c85ce..34ceca9 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -321,6 +321,32 @@ will be filled with the link, the second with its description."
   :group 'org-export-latex
   :type 'string)
 
+(defcustom org-export-latex-quotes
+  '(("fr" ("\\(\\s-\\|[[(]\\)\"" . "«~") ("\\(\\S-\\)\"" . "~»") ("\\(\\s-\\|(\\)'" . "'"))
+    ("en" ("\\(\\s-\\|[[(]\\)\"" . "``") ("\\(\\S-\\)\"" . "''") ("\\(\\s-\\|(\\)'" . "`")))
+  "Alist for quotes to use when converting english double-quotes.
+
+The CAR of each item in this alist is the language code.
+The CDR of each item in this alist is a list of three CONS:
+- the first CONS defines the opening quote;
+- the second CONS defines the closing quote;
+- the last CONS defines single quotes.
+
+For each item in a CONS, the first string is a regexp
+for allowed characters before/after the quote, the second
+string defines the replacement string for this quote."
+  :group 'org-export-latex
+  :type '(list
+	  (cons :tag "Opening quote"
+		(string :tag "Regexp for char before") 
+		(string :tag "Replacement quote     "))
+	  (cons :tag "Closing quote"
+		(string :tag "Regexp for char after ") 
+		(string :tag "Replacement quote     "))
+	  (cons :tag "Single quote"
+		(string :tag "Regexp for char before") 
+		(string :tag "Replacement quote     "))))
+
 (defcustom org-export-latex-tables-verbatim nil
   "When non-nil, tables are exported verbatim."
   :group 'org-export-latex
@@ -1624,21 +1650,18 @@ links, keywords, lists, tables, fixed-width"
 
 (defun org-export-latex-quotation-marks ()
   "Export quotation marks depending on language conventions."
-  (let* ((lang (plist-get org-export-latex-options-plist :language))
-	 (quote-rpl (if (equal lang "fr")
-			'(("\\(\\s-\\)\"" "«~")
-			  ("\\(\\S-\\)\"" "~»")
-			  ("\\(\\s-\\)'" "`"))
-		      '(("\\(\\s-\\|[[(]\\)\"" "``")
-			("\\(\\S-\\)\"" "''")
-			("\\(\\s-\\|(\\)'" "`")))))
-    (mapc (lambda(l) (goto-char (point-min))
-	    (while (re-search-forward (car l) nil t)
-	      (let ((rpl (concat (match-string 1)
-				 (org-export-latex-protect-string
-				  (copy-sequence (cadr l))))))
-		(org-if-unprotected-1
-		 (replace-match rpl t t))))) quote-rpl)))
+  (mapc (lambda(l)
+	  (goto-char (point-min))
+	  (while (re-search-forward (car l) nil t)
+	    (let ((rpl (concat (match-string 1)
+			       (org-export-latex-protect-string
+				(copy-sequence (cdr l))))))
+	      (org-if-unprotected-1
+	       (replace-match rpl t t))))) 
+	(cdr (or (assoc (plist-get org-export-latex-options-plist :language)
+			org-export-latex-quotes)
+		 ;; falls back on english
+		 (assoc "en" org-export-latex-quotes)))))
 
 (defun org-export-latex-special-chars (sub-superscript)
   "Export special characters to LaTeX.
-- 
1.7.5.2


[-- Attachment #2: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

  reply	other threads:[~2011-07-11 13:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-09  0:04 Question to the list about csquotes Nick Dokos
2011-07-11 13:11 ` Bastien [this message]
2011-07-11 14:38   ` [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes Stefan Nobis
2011-07-11 13:14 ` Question to the list about csquotes Bastien
2011-07-12  8:22   ` Frederik
2011-07-12  8:30     ` Bastien

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=8762n9arne.fsf@gnu.org \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=freak.fred@gmail.com \
    --cc=nicholas.dokos@hp.com \
    /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).