unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55329: [PATCH] Choose latex environment for table.el export
@ 2022-05-09  2:30 Vladimir Nikishkin
  2022-05-09 10:05 ` bug#55333: " Lars Ingebrigtsen
  2022-05-09 11:25 ` bug#55329: " Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Vladimir Nikishkin @ 2022-05-09  2:30 UTC (permalink / raw)
  To: 55329

Dear Emacs Developers,

Please, consider this patch for inclusion.
This patch slightly generalises the way Emacs' table.el handles
latex export.
Currently, the export always uses the "tabular" environment.
This patch adds a customize option to select a different one, and
adds one built-in suggestion of "longtable", which should be
perfectly compatible with "tabular".

The patch creates 1 new customize variable:
1. table-latex-environment

And changes the following 2 functions:
1. table--generate-source-epilogue
2. table--generate-source-prologue

#+begin_src patch
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 2175900194..eafa3e7b3c 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -753,6 +753,18 @@ table-html-cell-attribute
   :type 'string
   :group 'table)

+(defcustom table-latex-environment "tabular"
+  "Which tabular-compatible environment to use when generating latex.
+tabular and longtable are known to work."
+  :tag "Latex environment used to export tables"
+  :type '(choice
+	  (const :tag "tabular" "tabular")
+	  (const :tag "longtable"  "longtable")
+          string)
+  :group 'table
+  :local t)
+
 (defcustom table-cals-thead-rows 1
   "Number of top rows to become header rows in CALS table."
   :tag "CALS Header Rows"
@@ -3025,7 +3037,7 @@ table--generate-source-prologue
 		"")))
      ((eq language 'latex)
       (insert (format "%% This LaTeX table template is generated by emacs %s\n" emacs-version)
-	      "\\begin{tabular}{|" (apply #'concat (make-list (length col-list) "l|")) "}\n"
+	      "\\begin{" table-latex-environment "}{|" (apply #'concat (make-list (length col-list) "l|")) "}\n"
 	      "\\hline\n"))
      ((eq language 'cals)
       (insert (format "<!-- This CALS table template is generated by emacs %s -->\n" emacs-version)
@@ -3051,7 +3063,7 @@ table--generate-source-epilogue
      ((eq language 'html)
       (insert "</table>\n"))
      ((eq language 'latex)
-      (insert "\\end{tabular}\n"))
+      (insert "\\end{" table-latex-environment "}\n"))
      ((eq language 'cals)
       (set-marker-insertion-type (table-get-source-info 'colspec-marker) t) ;; insert before
       (save-excursion
#+end_patch

The copyright disclaimer has been signed by me and submitted to FSF
last August.

-- 
Your sincerely,
Vladimir Nikishkin (MiEr, lockywolf)
(Laptop)





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

* bug#55333: [PATCH] Choose latex environment for table.el export
  2022-05-09  2:30 bug#55329: [PATCH] Choose latex environment for table.el export Vladimir Nikishkin
@ 2022-05-09 10:05 ` Lars Ingebrigtsen
  2022-05-09 11:25 ` bug#55329: " Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-09 10:05 UTC (permalink / raw)
  To: Vladimir Nikishkin; +Cc: 55333

Vladimir Nikishkin
<for.emacs-table.el-environment-patch_2022-05-09@lockywolf.net> writes:

> Please, consider this patch for inclusion.
> This patch slightly generalises the way Emacs' table.el handles
> latex export.
> Currently, the export always uses the "tabular" environment.
> This patch adds a customize option to select a different one, and
> adds one built-in suggestion of "longtable", which should be
> perfectly compatible with "tabular".

Thanks; makes sense to me, so I've pushed it to Emacs 29 (with some
small changes).

By the way, the patch didn't apply directly, so it seems like something
had mangled it in transmission.  For future patches, it's probably
better to include patches as attachments.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#55329: [PATCH] Choose latex environment for table.el export
  2022-05-09  2:30 bug#55329: [PATCH] Choose latex environment for table.el export Vladimir Nikishkin
  2022-05-09 10:05 ` bug#55333: " Lars Ingebrigtsen
@ 2022-05-09 11:25 ` Eli Zaretskii
  2022-05-09 11:28   ` Vladimir Nikishkin
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2022-05-09 11:25 UTC (permalink / raw)
  To: Vladimir Nikishkin; +Cc: 55329

> From: Vladimir Nikishkin  <lockywolf@gmail.com>
> Date: Mon, 09 May 2022 10:30:57 +0800
> 
> The patch creates 1 new customize variable:
> 1. table-latex-environment
> 
> And changes the following 2 functions:
> 1. table--generate-source-epilogue
> 2. table--generate-source-prologue

Thanks.  A couple of minor nits:

> +(defcustom table-latex-environment "tabular"
> +  "Which tabular-compatible environment to use when generating latex.
> +tabular and longtable are known to work."

I'm not sure I understand the purpose of the last sentence, nor what
it adds to the doc string.

Also, perhaps we should prefer symbol values, not string values here?
Symbols are easier to compare and harder to make mistakes.





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

* bug#55329: [PATCH] Choose latex environment for table.el export
  2022-05-09 11:25 ` bug#55329: " Eli Zaretskii
@ 2022-05-09 11:28   ` Vladimir Nikishkin
  0 siblings, 0 replies; 4+ messages in thread
From: Vladimir Nikishkin @ 2022-05-09 11:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 55329


Eli Zaretskii <eliz@gnu.org> writes:

>> From: Vladimir Nikishkin  <lockywolf@gmail.com>
>> Date: Mon, 09 May 2022 10:30:57 +0800
>> 
>> The patch creates 1 new customize variable:
>> 1. table-latex-environment
>> 
>> And changes the following 2 functions:
>> 1. table--generate-source-epilogue
>> 2. table--generate-source-prologue
>
> Thanks.  A couple of minor nits:
>
>> +(defcustom table-latex-environment "tabular"
>> +  "Which tabular-compatible environment to use when generating latex.
>> +tabular and longtable are known to work."
>
> I'm not sure I understand the purpose of the last sentence, nor what
> it adds to the doc string.
>
> Also, perhaps we should prefer symbol values, not string values here?
> Symbols are easier to compare and harder to make mistakes.

I think this is a duplicate bug, I am sorry. This patch has already been
reviewed and accepted by Lars Ingebrigtsen.

> I'm not sure I understand the purpose of the last sentence, nor what
> Symbols are easier to compare and harder to make mistakes.

This setting accepts a free-form write-in. There may be more Latex
environments satisfying the "tabular" protocol, not just "tabular"
itself and "longtable". I haven't done an extensive survey, but I
suspect that most do. If this value is interpreted as a symbol, it
would require a "symbol->string" at the time of actually writing
the code into the final buffer. I don't think that a symbol would
really fit here.

-- 
Your sincerely,
Vladimir Nikishkin (MiEr, lockywolf)
(Laptop)





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

end of thread, other threads:[~2022-05-09 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09  2:30 bug#55329: [PATCH] Choose latex environment for table.el export Vladimir Nikishkin
2022-05-09 10:05 ` bug#55333: " Lars Ingebrigtsen
2022-05-09 11:25 ` bug#55329: " Eli Zaretskii
2022-05-09 11:28   ` Vladimir Nikishkin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).