From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes. Date: Mon, 11 Jul 2011 15:11:33 +0200 Message-ID: <8762n9arne.fsf@gnu.org> References: <6492.1310169884@alphaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgGGZ-0006gu-OL for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 09:11:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QgGGX-0007iz-DV for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 09:11:15 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:53072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QgGGW-0007is-SG for emacs-orgmode@gnu.org; Mon, 11 Jul 2011 09:11:13 -0400 Received: by wyg36 with SMTP id 36so3114479wyg.0 for ; Mon, 11 Jul 2011 06:11:12 -0700 (PDT) In-Reply-To: <6492.1310169884@alphaville.dokosmarshall.org> (Nick Dokos's message of "Fri, 08 Jul 2011 20:04:44 -0400") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: nicholas.dokos@hp.com Cc: Frederik , emacs-orgmode@gnu.org --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename=0001-org-latex.el-New-defcustom-org-export-latex-quotes-t.patch Content-Transfer-Encoding: 8bit >From 08c8be7e0403f58a16670a84dbd66d7dd34c7b43 Mon Sep 17 00:00:00 2001 From: Bastien Guerry 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 --=-=-= Content-Type: text/plain -- Bastien --=-=-=--