emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Question to the list about csquotes
@ 2011-07-09  0:04 Nick Dokos
  2011-07-11 13:11 ` [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes Bastien
  2011-07-11 13:14 ` Question to the list about csquotes Bastien
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Dokos @ 2011-07-09  0:04 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Frederik, nicholas.dokos


There's been a recent discussion about using csquotes in the latex
exporter[fn:1] and Tom Dye came up with a good idea of how to implement
it. We have been discussing it off list but there is a point that might
benefit from more general airing, so I offered to solicit opinions on
the list.

The question is about the following bit of code in
org-export-latex-quotation-marks:

,----
|   ...
|   (let* ((lang (plist-get org-export-latex-options-plist :language))
| 	 (quote-rpl (if (equal lang "fr")
| 			'(("\\(\\s-\\)\"" "«~")
| 			  ("\\(\\S-\\)\"" "~»")
| 			  ("\\(\\s-\\)'" "`"))
| 		      '(("\\(\\s-\\|[[(]\\)\"" "``")
| 			("\\(\\S-\\)\"" "''")
| 			("\\(\\s-\\|(\\)'" "`")))))
|   ...
`----

The question is what to do about the lang = "fr" case (which I think we
all agree is a hack):

o leave it alone and implement the csquotes mechanism on top of it?

o get rid of it and depend on the general csquotes mechanism to replace it?

The first solution perpetuates the hack but leaves existing org files that
use it unaffected.

The second cleans up the hack but at the cost of some backward inompatibility:
files that use the hack will not get guillemets unless some (one-time)
customizations are done: the LaTeX preamble has to be expanded to pull
in the appropriate packages (babel and csquotes) and a couple of string
variables have to be set to the right values.

So we turn to the collective wisdom of the list: how important is
backward compatibility in this case (i.e. are there lots of files out
there that use the hack)? And if it is important, how would you weigh
the inconvenience of the required customizations against the code
cleanup?  Presumably, french speakers have been the heaviest users of
this, so we'd like to hear from you - but opinions are welcome.

Thanks,
Nick

Footnotes:

[fn:1] http://thread.gmane.org/gmane.emacs.orgmode/43689

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes.
  2011-07-09  0:04 Question to the list about csquotes Nick Dokos
@ 2011-07-11 13:11 ` Bastien
  2011-07-11 14:38   ` Stefan Nobis
  2011-07-11 13:14 ` Question to the list about csquotes Bastien
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2011-07-11 13:11 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Frederik, emacs-orgmode

[-- 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Question to the list about csquotes
  2011-07-09  0:04 Question to the list about csquotes Nick Dokos
  2011-07-11 13:11 ` [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes Bastien
@ 2011-07-11 13:14 ` Bastien
  2011-07-12  8:22   ` Frederik
  1 sibling, 1 reply; 6+ messages in thread
From: Bastien @ 2011-07-11 13:14 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Frederik, emacs-orgmode

Hi Nick, Thomas and Frederik,

I've just sent a patch for this question: it sticks to the 
solution suggested in this thread, with minor variations.
Thanks all for working out this simple solution!

It defines a new `org-export-latex-quotes' variable -- please
see the docstring.

The default behavior reproduces the current behavior, so no
one should be hurt in the process.

Thanks for any feedback,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes.
  2011-07-11 13:11 ` [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes Bastien
@ 2011-07-11 14:38   ` Stefan Nobis
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Nobis @ 2011-07-11 14:38 UTC (permalink / raw)
  To: Bastien; +Cc: Frederik, nicholas.dokos, emacs-orgmode

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

Bastien <bzg@altern.org> writes:

> Org to output something like \endquote{some quoted text} instead

s/endquote/enquote/

-- 
Until the next mail...,
Stefan.

[-- Attachment #2: Type: application/pgp-signature, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Question to the list about csquotes
  2011-07-11 13:14 ` Question to the list about csquotes Bastien
@ 2011-07-12  8:22   ` Frederik
  2011-07-12  8:30     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Frederik @ 2011-07-12  8:22 UTC (permalink / raw)
  To: emacs-orgmode

Am 11.07.2011 15:14, schrieb Bastien:
> Hi Nick, Thomas and Frederik,
> 
> I've just sent a patch for this question: it sticks to the 
> solution suggested in this thread, with minor variations.
> Thanks all for working out this simple solution!
> 
> It defines a new `org-export-latex-quotes' variable -- please
> see the docstring.
> 
> The default behavior reproduces the current behavior, so no
> one should be hurt in the process.
> 
> Thanks for any feedback,
> 


Do I have to apply the patch to the development version or is 7.6 just fine?

Thanks & Regards

-- 
Frederik

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Question to the list about csquotes
  2011-07-12  8:22   ` Frederik
@ 2011-07-12  8:30     ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2011-07-12  8:30 UTC (permalink / raw)
  To: Frederik; +Cc: emacs-orgmode

Frederik <freak.fred@gmail.com> writes:

> Do I have to apply the patch to the development version or is 7.6 just
> fine?

Get the latest version from git, it has been applied this morning.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-12  8:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-09  0:04 Question to the list about csquotes Nick Dokos
2011-07-11 13:11 ` [PATCH] org-latex.el: New defcustom `org-export-latex-quotes' to control quotes Bastien
2011-07-11 14:38   ` 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

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).