From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp12.migadu.com ([2001:41d0:8:6d80::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms5.migadu.com with LMTPS
	id YGv5HJlxuGIVWQEAbAwnHQ
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 26 Jun 2022 16:47:53 +0200
Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp12.migadu.com with LMTPS
	id KKDPHJlxuGIlYwAAauVa8A
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sun, 26 Jun 2022 16:47:53 +0200
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id EA9FF1E882
	for <larch@yhetil.org>; Sun, 26 Jun 2022 16:47:52 +0200 (CEST)
Received: from localhost ([::1]:54578 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	id 1o5TYF-0000my-Uu
	for larch@yhetil.org; Sun, 26 Jun 2022 10:47:51 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:40942)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <danflscr@gmail.com>)
 id 1o5TWo-0000TL-TX
 for emacs-orgmode@gnu.org; Sun, 26 Jun 2022 10:46:25 -0400
Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:34395)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <danflscr@gmail.com>)
 id 1o5TWm-00070h-TS
 for emacs-orgmode@gnu.org; Sun, 26 Jun 2022 10:46:22 -0400
Received: by mail-wr1-x430.google.com with SMTP id r20so9631257wra.1
 for <emacs-orgmode@gnu.org>; Sun, 26 Jun 2022 07:46:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=vZLp793sBtMllrZ/qMpgYQmswiIxMVeZOunI/DmVaQI=;
 b=HdF1PL7thzvSZt8o83emfxpBFmH/Y83uhOqkMi35WlcOXdtQwsqhiSZsxelTrL0h6L
 U4nvVcR74iAKO5QPs99YtUw2HJBQR2R+MHsw4JmPrNqwhyJO/wsuQdqkjSYyMxH6lTVf
 z+nXbVjUhG9rY7iEJ+7T3jdB3BIh6byyJO8NX2L0K5AZVFVdIPfVMpWIRQYe08pDf4XA
 IM+Yag1pK2VkFpGDE4Mp+VrrFnqcjohOnVYAA8iaZXBI5VHRuhGPgJCFZ1d5Njinc1PF
 hb9JD+gfpV1joyr+roULcDDLyvkjAdWX5sghCmpnJUWp+v6HLLu47rHpYhT8GJV21nzw
 SeFQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=vZLp793sBtMllrZ/qMpgYQmswiIxMVeZOunI/DmVaQI=;
 b=mUA0PO0lG1LXMAGCi80btkqL9PiioOPhUJ0D+ay7FO21ZQlMvJzhg7Wp0pjCoeJYzC
 EOCxBA7PlUEO/hhVLO/oKH0SE4mgUFiDc3MmRDexKALau9yBuHhp9/LBuFOKl7WaC5TD
 VG2rXwdALj435c/qTf88whtVU+x/1hfPQDCk6ln4WFfq8k8aEE+Qn+tl6ilMpZh7pUwN
 gVZlx72a4OgcNknjI6NQ6jLMrgabnI8DkA7T0Xj7YckT29tFV65GfG2OwBVykewn3VnO
 hEgqNe71Es367xYK+4LLK/+wMPiVYXv8fEuOYj2fXnBzoP9diD8E7w8n4OhGqWb3k0ti
 IB3g==
X-Gm-Message-State: AJIora9+u/Ax2hyCz6I8ZSDURS0lGkP0dVMMFVHaxSTVTzbytkQEA5V/
 nKisiLokyhzF1uP1BsFzrzE=
X-Google-Smtp-Source: AGRyM1vDEb71ezdNVasK9ufccHu+nYC4L4TfQTyc8wbOqBoXEBIq4VdduJbSuAAgqZpJGw74dZuczQ==
X-Received: by 2002:a5d:64c7:0:b0:21b:9661:6aac with SMTP id
 f7-20020a5d64c7000000b0021b96616aacmr8096365wri.496.1656254779199; 
 Sun, 26 Jun 2022 07:46:19 -0700 (PDT)
Received: from Home-Mac ([141.226.10.20]) by smtp.gmail.com with ESMTPSA id
 l13-20020a5d674d000000b0021bbdc3375fsm4375036wrw.68.2022.06.26.07.46.17
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 26 Jun 2022 07:46:18 -0700 (PDT)
From: Daniel Fleischer <danflscr@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>
Cc: Ihor Radchenko <yantar92@gmail.com>,  emacs-orgmode@gnu.org,
 emacs@vergauwen.me
Subject: [PATCH] Re: ox-latex table tabbing support.
References: <MzFxcjy--7-2@vergauwen.me>
 <87wng5nno3.fsf@localhost-Mzo7eKN----2> <MzosmTn--3-2@vergauwen.me>
 <m235fy1va7.fsf@gmail.com> <87zgi0tcj6.fsf@localhost>
 <87k09413uc.fsf@kyleam.com>
Date: Sun, 26 Jun 2022 17:46:15 +0300
In-Reply-To: <87k09413uc.fsf@kyleam.com> (Kyle Meyer's message of "Sat, 25 Jun
 2022 23:49:31 -0400")
Message-ID: <m2y1xjcwjs.fsf_-_@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::430;
 envelope-from=danflscr@gmail.com; helo=mail-wr1-x430.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-orgmode@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: "Emacs-orgmode" <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
X-Migadu-Flow: FLOW_IN
X-Migadu-To: larch@yhetil.org
X-Migadu-Country: US
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1656254873;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:in-reply-to:in-reply-to:
	 references:references:list-id:list-help:list-unsubscribe:
	 list-subscribe:list-post:dkim-signature;
	bh=vZLp793sBtMllrZ/qMpgYQmswiIxMVeZOunI/DmVaQI=;
	b=UDRu04SBQFCft5tH71uT012jJI0kLz1wnCRWbCxNA2UulLcgt/nfZpQzSzs2JpCcJRT4XX
	lQF8H6xz6xG1NMtr/Yik2aXUjb2FiRHfrndvmw7zyefxhDed0uPi/yHneZXbhGLDXy8zDm
	DNCKetSBxJH2R8RZpa8AHhYwzGqHkS8dfWLQXIDVDkQ1FCmXLz5wydM9WlMzCHC6ThiEQr
	YGPcWEa6j6PsfaepKp8hPUzwd+h3JSl9r9MlaWS7Fz3mPZ6J5i9Y4y/uTfFg7wjce/qguj
	0FjB/auRbvkKXo7QQZwwveVWeSR4+iR9Esa1ic3uHlEct4nk6PH3kXztbw378g==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656254873; a=rsa-sha256; cv=none;
	b=dutwhCv47zZTLVF+u+rStDJ4TbYdY0mo7wsj77CrQNYaWH1M85qIdnb3tsHT/UYedPGNS4
	cKnIDJ1iABlIxnBJGGj1Ud2eMNkn5oEtObHLbXkBxw7/tOi/168KZ5QUXzbEB2CeJ8fN1d
	ZpZDOlDBpaRxR+mQzcTDSNVP71KdIvWKxjLLYZH/Ewhl009AZ2deI3nbnS6UbU0Fd6zWkM
	F5ZXtYksxAnOnclbP/p/K1aqrsdFq1vBSUvkw0fDQH6OQrHCBqgaFqJUeKIRormP4tc7U1
	e+uUvL9EGmAundTeZojbLOCDNmjA+kmk9HX+nlAznlfViY1Lg92WWdsrgZn5JQ==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=gmail.com header.s=20210112 header.b=HdF1PL7t;
	dmarc=pass (policy=none) header.from=gmail.com;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"
X-Migadu-Spam-Score: -4.26
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=gmail.com header.s=20210112 header.b=HdF1PL7t;
	dmarc=pass (policy=none) header.from=gmail.com;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"
X-Migadu-Queue-Id: EA9FF1E882
X-Spam-Score: -4.26
X-Migadu-Scanner: scn0.migadu.com
X-TUID: Kl+KcFD9zsva

--=-=-=
Content-Type: text/plain

Kyle Meyer [2022-06-25 Sat 23:49] wrote:

> Thanks for flagging this, Ihor.  I was just glancing at this commit
> (4a0d951c6) due to seeing this warning.  It's doing
>
>   (let ((align ...))
>     (setq align ...))
>
> where the align value is returned, so the align binding can be dropped
> altogether.
>
> Daniel, in addition to that, there are at least a few other issues with
> 4a0d951c6 that should be addressed:
>
>  * the first line of the new docstrings should be a complete sentence.
>
>    For example
>
>      Return an appropriate LaTeX alignment string, for the
>      latex tabbing environment.
>
>    should be changed to something like
>
>      Return alignment string for LaTeX tabbing environment.
>
>    See (info "(elisp)Documentation Tips")
>
>  * the indentation is off in several places, including the start of the
>    docstrings.  Please indent the code with, e.g., indent-region.
>
>  * one of org-table--org-tabbing's parameters is a typo (contenst),
>    which it looks like Ihor pointed out in an earlier review
>
>  * comment typo: documets
>
>  * several spots put opening and trailing parentheses on their own line
>
>    That goes against the usual conventions of this repo:
>
>      $ git grep '^ *)' '*.el' | wc -l
>      42
>      $ git grep '( *$' '*.el' | wc -l
>      17
>
>  * rather than doing something like
>
>      (let ((x ""))
>        (setq x <something else>)
>        ...)
>
>    just do
>
>      (let ((x <something else>))
>       ...)
>
>    And consider whether it's worth adding a binding at all rather than
>    inlining the code.
>
>    As an extreme case, org-table--org-tabbing does
>
>      (let ((output (format ...)))
>        output)
>
>    rather than
>
>      (format ...)

Thanks for the code feedback; patch attached. 


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-lisp-ox-latex.el-tabbing-code-refactor.patch
Content-Description: patch

>From b041dd62cbeea924ea6d2b6dee9b1142aef968ec Mon Sep 17 00:00:00 2001
From: Daniel Fleischer <danflscr@gmail.com>
Date: Sun, 26 Jun 2022 17:25:00 +0300
Subject: [PATCH] lisp/ox-latex.el: tabbing code refactor

* lisp/ox-latex.el: documentation, indentation, cleaning
(org-latex-table)
(org-latex--align-string-tabbing)
(org-table--org-tabbing)

See
https://lists.gnu.org/archive/html/emacs-orgmode/2022-06/msg00700.html.
---
 lisp/ox-latex.el | 66 +++++++++++++++++++++++-------------------------
 1 file changed, 31 insertions(+), 35 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 898fa34dd..1446b7fca 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3667,7 +3667,8 @@ (defun org-latex-table (table contents info)
        ((or (string= type "math") (string= type "inline-math"))
         (org-latex--math-table table info))
        ;; Case 3: Tabbing
-       ((string= type "tabbing") (org-table--org-tabbing table contents info))
+       ((string= type "tabbing")
+        (org-table--org-tabbing table contents info))
        ;; Case 4: Standard table.
        (t (concat (org-latex--org-table table contents info)
 		  ;; When there are footnote references within the
@@ -3706,32 +3707,29 @@ (defun org-latex--align-string (table info &optional math?)
 	(apply 'concat (nreverse align)))))
 
 (defun org-latex--align-string-tabbing (table info)
-    "Return an appropriate LaTeX alignment string, for the
-latex tabbing environment.
+  "Return LaTeX alignment string using tabbing environment.
 TABLE is the considered table.  INFO is a plist used as
 a communication channel."
-    (or (org-export-read-attribute :attr_latex table :align)
-        (let ((align "")
-              (count 0)
-              (separator ""))
-            ;; Count the number of cells in the first row.
-            (setq count (length
-                  (org-element-map
-                      (org-element-map table 'table-row
-                        (lambda (row)
-                          (and (eq (org-element-property :type row) 'standard) row))
-                        info 'first-match)
-                      'table-cell
-                    (lambda (cell) cell))))
-            ;; Calculate the column width, using a proportion of the documets
-            ;; textwidth.
-            (setq separator (format
-                             "\\hspace{%s\\textwidth} \\= "
-                             (- (/  1.0 count) 0.01)))
-            (setq align (concat
-                         (apply 'concat (make-list count separator))
-                         "\\kill")))
-            ))
+  (or (org-export-read-attribute :attr_latex table :align)
+      (let* ((count
+              ;; Count the number of cells in the first row.
+              (length
+               (org-element-map
+                   (org-element-map table 'table-row
+                     (lambda (row)
+                       (and (eq (org-element-property :type row)
+                                'standard)
+                            row))
+                     info 'first-match)
+                   'table-cell
+                 (lambda (cell) cell))))
+             ;; Calculate the column width, using a proportion of
+             ;;the documets textwidth.
+             (separator
+              (format "\\hspace{%s\\textwidth} \\= "
+                      (- (/  1.0 count) 0.01))))
+        (concat (apply 'concat (make-list count separator))
+                "\\kill"))))
 
 (defun org-latex--decorate-table (table attributes caption above? info)
   "Decorate TABLE string with caption and float environment.
@@ -3836,21 +3834,19 @@ (defun org-latex--org-table (table contents info)
 	(org-latex--decorate-table output attr caption above? info))))))
 
 
-(defun org-table--org-tabbing (table contenst info)
-      "Return appropriate LaTeX code for an Org table, using the
-latex tabbing syntax.
+(defun org-table--org-tabbing (table contents info)
+  "Return tabbing environment latex code for Org table.
 TABLE is the table type element to transcode.  CONTENTS is its
 contents, as a string.  INFO is a plist used as a communication
 channel.
+
 This function assumes TABLE has `org' as its `:type' property and
 `tabbing' as its `:mode' attribute."
-    (let ((output (format "\\begin{%s}\n%s\n%s\\end{%s}"
-                          "tabbing"
-                          (org-latex--align-string-tabbing table info )
-                          contenst
-                          "tabbing")))
-      output)
-    )
+  (format "\\begin{%s}\n%s\n%s\\end{%s}"
+          "tabbing"
+          (org-latex--align-string-tabbing table info)
+          contents
+          "tabbing"))
 
 (defun org-latex--table.el-table (table info)
   "Return appropriate LaTeX code for a table.el table.
-- 
2.36.0


--=-=-=
Content-Type: text/plain

-- 

Daniel Fleischer

--=-=-=--