all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Longtable continuation strings customizable
@ 2013-10-27  0:42 Thomas S. Dye
  2013-10-27  8:05 ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2013-10-27  0:42 UTC (permalink / raw)
  To: Org-mode

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

Aloha all,

The attached patch should be applied on top of the earlier patch.  It
makes the continuation strings customizable.

All the best,
Tom


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch to ox-latex.el --]
[-- Type: text/x-patch, Size: 2228 bytes --]

From 2b3fbcf9a8ea64ef6207237ef48b9c62cded01ff Mon Sep 17 00:00:00 2001
From: Thomas Dye <tsd@tsdye.com>
Date: Sat, 26 Oct 2013 14:37:30 -1000
Subject: [PATCH] Longtable continuation strings customizable

---
 lisp/ox-latex.el | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 6426d55..6bca7a3 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -525,6 +525,19 @@ When nil, no transformation is made."
 	  (string :tag "Format string")
 	  (const :tag "No formatting")))
 
+(defcustom org-latex-longtable-continued-on "Continued on next page"
+  "String to indicate table continued on next page."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-latex-longtable-continued-from "Continued from previous page"
+  "String to indicate table continued from previous page."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
 
 ;;;; Text markup
 
@@ -2625,17 +2638,18 @@ a communication channel."
 	((and longtablep (org-export-table-row-ends-header-p table-row info))
 	 (format "%s
 \\endfirsthead
-\\multicolumn{%d}{l}{Continued from previous page} \\\\
+\\multicolumn{%d}{l}{%s} \\\\
 %s
 %s \\\\\n
 %s
 \\endhead
-%s\\multicolumn{%d}{r}{Continued on next page} \\\\
+%s\\multicolumn{%d}{r}{%s} \\\\
 \\endfoot
 \\endlastfoot"
 		 (if booktabsp "\\midrule" "\\hline")
 		 (cdr (org-export-table-dimensions
 		       (org-export-get-parent-table table-row) info))
+		 org-latex-longtable-continued-from
 		 (cond ((and booktabsp (memq 'top borders)) "\\toprule\n")
 		       ((and (memq 'top borders)
 			     (memq 'above borders)) "\\hline\n")
@@ -2645,7 +2659,8 @@ a communication channel."
 		 (if booktabsp "\\midrule" "\\hline")
 		 ;; Number of columns.
 		 (cdr (org-export-table-dimensions
-		       (org-export-get-parent-table table-row) info))))
+		       (org-export-get-parent-table table-row) info))
+		 org-latex-longtable-continued-on))
 	;; When BOOKTABS are activated enforce bottom rule even when
 	;; no hline was specifically marked.
 	((and booktabsp (memq 'bottom borders)) "\\bottomrule")
-- 
1.8.3.3


[-- Attachment #3: Type: text/plain, Size: 146 bytes --]


-- 
T.S. Dye & Colleagues, Archaeologists
735 Bishop St, Suite 315, Honolulu, HI 96813
Tel: 808-529-0866, Fax: 808-529-0884
http://www.tsdye.com

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-27  0:42 [PATCH] Longtable continuation strings customizable Thomas S. Dye
@ 2013-10-27  8:05 ` Nicolas Goaziou
  2013-10-27  8:07   ` Carsten Dominik
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2013-10-27  8:05 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org-mode

Hello,

tsd@tsdye.com (Thomas S. Dye) writes:

> The attached patch should be applied on top of the earlier patch.  It
> makes the continuation strings customizable.

Wouldn't it be better if these strings where hardcoded, but with support
for internationalization in `org-export-dictionary'?

Meanwhile, I applied your patch. Thank you.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-27  8:05 ` Nicolas Goaziou
@ 2013-10-27  8:07   ` Carsten Dominik
  2013-10-27 16:52     ` Thomas S. Dye
  0 siblings, 1 reply; 12+ messages in thread
From: Carsten Dominik @ 2013-10-27  8:07 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode, Thomas S. Dye


On 27.10.2013, at 09:05, Nicolas Goaziou <n.goaziou@gmail.com> wrote:

> Hello,
> 
> tsd@tsdye.com (Thomas S. Dye) writes:
> 
>> The attached patch should be applied on top of the earlier patch.  It
>> makes the continuation strings customizable.
> 
> Wouldn't it be better if these strings where hardcoded, but with support
> for internationalization in `org-export-dictionary'?

I agree that this would be better.

- Carsten

> 
> Meanwhile, I applied your patch. Thank you.
> 
> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> 

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-27  8:07   ` Carsten Dominik
@ 2013-10-27 16:52     ` Thomas S. Dye
  2013-10-28  9:28       ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2013-10-27 16:52 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-mode, Nicolas Goaziou

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On 27.10.2013, at 09:05, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
>
>> Hello,
>> 
>> tsd@tsdye.com (Thomas S. Dye) writes:
>> 
>>> The attached patch should be applied on top of the earlier patch.  It
>>> makes the continuation strings customizable.
>> 
>> Wouldn't it be better if these strings where hardcoded, but with support
>> for internationalization in `org-export-dictionary'?
>
> I agree that this would be better.
>
> - Carsten
>

I think there are two axes of variation here:

1) internationalization, and
2) style guides, e.g., for a particular journal, Chicago Manual, etc.

IIUC, hardcoding and org-export-dictionary solve 1) but not 2).

In my experience, variation in 2) is idiosyncratic, though I haven't
looked specifically at table continuation lines.

The user can solve both 1) and 2) with customizable continuation
strings, so it might be best to stay on this path instead of hardcoding
and internationalization in org-export-dictionary.

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-27 16:52     ` Thomas S. Dye
@ 2013-10-28  9:28       ` Nicolas Goaziou
  2013-10-28 14:55         ` Thomas S. Dye
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2013-10-28  9:28 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org-mode, Carsten Dominik

Hello,

tsd@tsdye.com (Thomas S. Dye) writes:

> I think there are two axes of variation here:
>
> 1) internationalization, and
> 2) style guides, e.g., for a particular journal, Chicago Manual, etc.
>
> IIUC, hardcoding and org-export-dictionary solve 1) but not 2).
>
> In my experience, variation in 2) is idiosyncratic, though I haven't
> looked specifically at table continuation lines.
>
> The user can solve both 1) and 2) with customizable continuation
> strings, so it might be best to stay on this path instead of hardcoding
> and internationalization in org-export-dictionary.

I agree customization is more powerful here (although it means that all
non-English Org users will need to change it), but so it is for every
other multilingual string. 

Since we didn't choose to make multilingual strings customizable, I find
it strange that this particular one is.

Also, I you can use a filter to modify that string and make it comply to
a specific style, if needed. IOW, you also get 1) and 2) with the
`org-export-dictionary' way, with 1) being more user-friendly and 2)
more difficult than in the current way.

Am I missing something?


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-28  9:28       ` Nicolas Goaziou
@ 2013-10-28 14:55         ` Thomas S. Dye
  2013-10-28 17:27           ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2013-10-28 14:55 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode, Carsten Dominik

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> I agree customization is more powerful here (although it means that all
> non-English Org users will need to change it), but so it is for every
> other multilingual string. 
>
> Since we didn't choose to make multilingual strings customizable, I find
> it strange that this particular one is.
>
> Also, I you can use a filter to modify that string and make it comply to
> a specific style, if needed. IOW, you also get 1) and 2) with the
> `org-export-dictionary' way, with 1) being more user-friendly and 2)
> more difficult than in the current way.
>
> Am I missing something?

An example filter?

Otherwise, I agree, there is no need to break the mold here.

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-28 14:55         ` Thomas S. Dye
@ 2013-10-28 17:27           ` Nicolas Goaziou
  2013-10-28 19:15             ` Thomas S. Dye
  2013-10-30 16:36             ` Thomas S. Dye
  0 siblings, 2 replies; 12+ messages in thread
From: Nicolas Goaziou @ 2013-10-28 17:27 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org-mode, Carsten Dominik

Hello,

tsd@tsdye.com (Thomas S. Dye) writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> I agree customization is more powerful here (although it means that all
>> non-English Org users will need to change it), but so it is for every
>> other multilingual string. 
>>
>> Since we didn't choose to make multilingual strings customizable, I find
>> it strange that this particular one is.
>>
>> Also, I you can use a filter to modify that string and make it comply to
>> a specific style, if needed. IOW, you also get 1) and 2) with the
>> `org-export-dictionary' way, with 1) being more user-friendly and 2)
>> more difficult than in the current way.
>>
>> Am I missing something?
>
> An example filter?

  (defun my-personal-table-continuation-strings (row backend info)
    (when (org-export-derived-backend-p 'latex)
      (replace-regexp-in-string
       "multicolumn{[0-9]+}{l}{\\(.*\\)}" "String 1"
       (replace-regexp-in-string
        "multicolumn{[0-9]+}{r}{\\(.*\\)}" "String 2"
        row nil nil 1)
       nil nil 1)))
  (add-to-list 'org-export-filter-table-row-functions
               'my-personal-table-continuation-strings)

Untested.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-28 17:27           ` Nicolas Goaziou
@ 2013-10-28 19:15             ` Thomas S. Dye
  2013-10-29 14:40               ` Nicolas Goaziou
  2013-10-30 16:36             ` Thomas S. Dye
  1 sibling, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2013-10-28 19:15 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode, Carsten Dominik

Nicolas Goaziou <n.goaziou@gmail.com> writes:

>>> Am I missing something?
>>
>> An example filter?
>
>   (defun my-personal-table-continuation-strings (row backend info)
>     (when (org-export-derived-backend-p 'latex)
>       (replace-regexp-in-string
>        "multicolumn{[0-9]+}{l}{\\(.*\\)}" "String 1"
>        (replace-regexp-in-string
>         "multicolumn{[0-9]+}{r}{\\(.*\\)}" "String 2"
>         row nil nil 1)
>        nil nil 1)))
>   (add-to-list 'org-export-filter-table-row-functions
>                'my-personal-table-continuation-strings)
>
> Untested.

Thanks!

Tom
-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-28 19:15             ` Thomas S. Dye
@ 2013-10-29 14:40               ` Nicolas Goaziou
  0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Goaziou @ 2013-10-29 14:40 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org-mode, Carsten Dominik

Hello,

tsd@tsdye.com (Thomas S. Dye) writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>>>> Am I missing something?
>>>
>>> An example filter?
>>
>>   (defun my-personal-table-continuation-strings (row backend info)
>>     (when (org-export-derived-backend-p 'latex)
>>       (replace-regexp-in-string
>>        "multicolumn{[0-9]+}{l}{\\(.*\\)}" "String 1"
>>        (replace-regexp-in-string
>>         "multicolumn{[0-9]+}{r}{\\(.*\\)}" "String 2"
>>         row nil nil 1)
>>        nil nil 1)))
>>   (add-to-list 'org-export-filter-table-row-functions
>>                'my-personal-table-continuation-strings)
>>
>> Untested.
>
> Thanks!

I switched to hardcoded strings and internationalization. Now, we need
volunteers to fill missing translations for:

 "Continued on next page"
 "Continued from previous page"


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-28 17:27           ` Nicolas Goaziou
  2013-10-28 19:15             ` Thomas S. Dye
@ 2013-10-30 16:36             ` Thomas S. Dye
  2013-10-31 10:19               ` Nicolas Goaziou
  1 sibling, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2013-10-30 16:36 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode, Carsten Dominik

Nicolas Goaziou <n.goaziou@gmail.com> writes:

>> An example filter?
>
>   (defun my-personal-table-continuation-strings (row backend info)
>     (when (org-export-derived-backend-p 'latex)
>       (replace-regexp-in-string
>        "multicolumn{[0-9]+}{l}{\\(.*\\)}" "String 1"
>        (replace-regexp-in-string
>         "multicolumn{[0-9]+}{r}{\\(.*\\)}" "String 2"
>         row nil nil 1)
>        nil nil 1)))
>   (add-to-list 'org-export-filter-table-row-functions
>                'my-personal-table-continuation-strings)
>
> Untested.

I can't get this to work :(

I have this, based on the example above:

#+name: tsd-continuation-strings
#+begin_src emacs-lisp
  (defun my-personal-table-continuation-strings (row backend info)
    (when (org-export-derived-backend-p 'latex)
      (replace-regexp-in-string
       "multicolumn{[0-9]+}{l}{\\(.*\\)}" "\\ldots\\ continued from previous page"
       row nil nil 1)
       (replace-regexp-in-string
        "multicolumn{[0-9]+}{r}{\\(.*\\)}" "continued on next page \\ldots"
       row nil nil 1)))
  (add-to-list 'org-export-filter-table-row-functions
               'my-personal-table-continuation-strings)
#+end_src

I also tried 'org-export-filter-table-functions without success.  I
always get the default continuation strings.  I've looked around for an
error message, but there doesn't appear to be one, at least that I can
find. The asynchronous export runs through to completion.

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-30 16:36             ` Thomas S. Dye
@ 2013-10-31 10:19               ` Nicolas Goaziou
  2013-10-31 21:25                 ` Thomas S. Dye
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2013-10-31 10:19 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org-mode, Carsten Dominik

Hello,

tsd@tsdye.com (Thomas S. Dye) writes:

> I have this, based on the example above:
>
>
> #+name: tsd-continuation-strings
> #+begin_src emacs-lisp
>
>   (defun my-personal-table-continuation-strings (row backend info)
>     (when (org-export-derived-backend-p 'latex)
>       (replace-regexp-in-string
>        "multicolumn{[0-9]+}{l}{\\(.*\\)}" "\\ldots\\ continued from previous page"
>        row nil nil 1)
>        (replace-regexp-in-string
>         "multicolumn{[0-9]+}{r}{\\(.*\\)}" "continued on next page \\ldots"
>        row nil nil 1)))
>   (add-to-list 'org-export-filter-table-row-functions
>                'my-personal-table-continuation-strings)
> #+end_src
>
> I also tried 'org-export-filter-table-functions without success.  I
> always get the default continuation strings.  I've looked around for an
> error message, but there doesn't appear to be one, at least that I can
> find. The asynchronous export runs through to completion.

The first `replace-regexp-in-string' has to be applied to the return
value of the second one. IOW they have to be nested.

Also, you need to double again backslashes in replacement string, or use
a non-nil LITERAL argument in `replace-regexp-in-string'.

Eventually, I made a typo in my suggestion: the second line should be:

  (org-export-derived-backend-p backend 'latex)

In a nutshell:

  (defun my-personal-table-continuation-strings (row backend info)
    (when (org-export-derived-backend-p backend 'latex)
      (replace-regexp-in-string
       "multicolumn{[0-9]+}{l}{\\(.*\\)}" "\\ldots\\ continued from previous page"
       (replace-regexp-in-string
        "multicolumn{[0-9]+}{r}{\\(.*\\)}" "continued on next page \\ldots"
        row nil t 1) nil t 1)))


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Longtable continuation strings customizable
  2013-10-31 10:19               ` Nicolas Goaziou
@ 2013-10-31 21:25                 ` Thomas S. Dye
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas S. Dye @ 2013-10-31 21:25 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode, Carsten Dominik

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> In a nutshell:
>
>   (defun my-personal-table-continuation-strings (row backend info)
>     (when (org-export-derived-backend-p backend 'latex)
>       (replace-regexp-in-string
>        "multicolumn{[0-9]+}{l}{\\(.*\\)}" "\\ldots\\ continued from previous page"
>        (replace-regexp-in-string
>         "multicolumn{[0-9]+}{r}{\\(.*\\)}" "continued on next page \\ldots"
>         row nil t 1) nil t 1)))

Thanks again for your patience and help. This works!

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

end of thread, other threads:[~2013-10-31 21:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-27  0:42 [PATCH] Longtable continuation strings customizable Thomas S. Dye
2013-10-27  8:05 ` Nicolas Goaziou
2013-10-27  8:07   ` Carsten Dominik
2013-10-27 16:52     ` Thomas S. Dye
2013-10-28  9:28       ` Nicolas Goaziou
2013-10-28 14:55         ` Thomas S. Dye
2013-10-28 17:27           ` Nicolas Goaziou
2013-10-28 19:15             ` Thomas S. Dye
2013-10-29 14:40               ` Nicolas Goaziou
2013-10-30 16:36             ` Thomas S. Dye
2013-10-31 10:19               ` Nicolas Goaziou
2013-10-31 21:25                 ` Thomas S. Dye

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.