emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Mario Frasca <mario@anche.no>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] allow for multiline headers
Date: Sun, 14 Jun 2020 21:23:17 +0200	[thread overview]
Message-ID: <87a715e9ju.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <f7f06bf3-53a5-7b94-54c7-cde7191b9552@anche.no> (Mario Frasca's message of "Sat, 13 Jun 2020 18:03:27 -0500")

Hello,

Mario Frasca <mario@anche.no> writes:

> On 13/06/2020 17:18, Nicolas Goaziou wrote:

>> Unit tests are not worth a formal definition. However, "test-ox.el"
>> contains unit tests.
>
> I'm not sure what you mean by the first sentence

I mean that, even though unit tests are great, and certainly welcome, we
first and foremost need a clear definition of a table header. This
concept is suggested in the manual, and more accurately defined in
ox.el. It would be nice to define it properly in the syntax.

> but I found the header tests in the test-ox.el file, and added one
> where multiple lines header is accepted.  is it related enough as to
> be included in my proposal?

Sure.

> I can move the org-table-collapse-header function from org-table.el to
> org-plot.el, but to me it makes little sense, relegating a generic
> function to a sub-module: others will look for the functionality in
> org-table, not see it, and duplicate the function somewhere else.

This doesn't seem to be a generic function, but a very specific one.
More on this below.

> +  (setq glue (or glue " "))
> +  (setq max-header-lines (or max-header-lines 4))

Please use `let' instead of `setq' whenever possible, e.g., here.

> +  (while (equal 'hline (car table))

equal -> eq

> +    (setq table (cdr table)))

(pop table)

> +  (let* ((trailer table)
> +	 (header-lines (cl-loop for line in table
> +				until (equal line 'hline)
> +				collect line
> +				do (setq trailer (cdr trailer)))))

You couldn't resist. 

This could be extracted as an independent function, which would return
the header, or nil. We can also imagine a function returning a cons cell
(HEADER . BODY), both HEADER and BODY being list of rows (possibly
empty).

Note that the function may be more complicated than the above, because,
in the following tables

    | a |
    | b |

or

    |---|
    | a |
    | b |
    |---|

there's a body, but no header. It depends on the definition chosen for
headers.

> +    (if (and trailer (<= (length header-lines) max-header-lines))
> +	(cons (apply #'cl-mapcar
> +		     #'(lambda (&rest x)

The #', aka, `function', is just noise before `lambda'.

   --> (lambda (&rest x))

> +			 (org-trim
> +			  (mapconcat #'identity x glue)))
> +		     header-lines)
> +	      trailer)
> +      table)))

Here you are going further than setting the definition for tables
headers. You imply that:

    | header line 1 |
    | header line 2 |
    |---------------|
    | body          |

is equivalent to

    | header line 1 header line 2 |
    |-----------------------------|
    | body                        |

I'm not so sure this is a good idea. It might be a good idea for Org
Plot, I don't know, but generally speaking, is it?

Regards,
-- 
Nicolas Goaziou


  reply	other threads:[~2020-06-14 19:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12 17:14 [PATCH] allow for multiline headers Mario Frasca
2020-06-12 22:44 ` Nicolas Goaziou
2020-06-13 20:20   ` Mario Frasca
2020-06-13 21:20     ` Mario Frasca
2020-06-13 22:18     ` Nicolas Goaziou
2020-06-13 23:03       ` Mario Frasca
2020-06-14 19:23         ` Nicolas Goaziou [this message]
     [not found]           ` <3e6ee551-4ef7-7d96-93dc-19a4973e1af8@anche.no>
     [not found]             ` <871rm5vslh.fsf@nicolasgoaziou.fr>
2020-06-27 15:39               ` Mario Frasca
2020-06-28 23:17                 ` Nicolas Goaziou
2020-06-29  0:27                   ` Mario Frasca
2020-06-29 12:50                     ` Nicolas Goaziou
2020-06-29 16:26                       ` Mario Frasca
2020-06-29 18:36                         ` Nicolas Goaziou
2020-06-29 22:01                           ` Mario Frasca
2020-07-01 10:46                             ` Nicolas Goaziou
2020-07-01 12:06                               ` Mario Frasca
2020-07-04  8:58                                 ` Nicolas Goaziou
2020-07-04 13:47                                   ` Mario Frasca

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a715e9ju.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=mario@anche.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).