emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Jonas Bernoulli <jonas@bernoul.li>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH v3 2/3] ox-texinfo: Optionally use @itemx for certain description list items
Date: Sat, 22 Jan 2022 16:33:56 +0100	[thread overview]
Message-ID: <874k5vzswr.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <20220118151129.19646-3-jonas@bernoul.li> (Jonas Bernoulli's message of "Tue, 18 Jan 2022 16:11:28 +0100")

Hello,

Jonas Bernoulli <jonas@bernoul.li> writes:

> * doc/org-manual.org (Plain lists in Texinfo export): Reorder and
> document new functionality.
> * lisp/ox-texinfo.el: Add org-texinfo--combine-items to the list of
> :filter-parse-tree functions of the texinfo backend.
> * lisp/ox-texinfo.el (org-texinfo--combine-items) New function.
> * lisp/ox-texinfo.el (org-texinfo-item) Transcode combined items to
> one @item and one or more @itemx.

This looks good. I have some comments below.

>  #+begin_example
> -,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
> +,#+attr_texinfo: :table-type vtable :indic asis :sep ,
>  - foo, bar :: This is the common text for variables foo and bar.
>  #+end_example

This change is not needed. Org markup is capitalized in examples to make
it stand out. It's not great because 1) it is ugly 2) users may think
Org syntax is uppercase. But changing that is not the point of this patch.

> -#+ATTR_TEXINFO: :enum A
> -1. Alpha
> -2. Bravo
> -3. Charlie
> +,#+attr_texinfo: :table-type vtable :indic asis :combine t
> +- foo ::
> +- bar ::
> +  This is the common text for variables foo and bar.

See above.

>  (defun org-texinfo--normalize-headlines (tree _backend info)
>    "Normalize headlines in TREE.
>  
> -BACK-END is the symbol specifying back-end used for export.
> +_BACKEND is the symbol `texinfo'; the back-end used for export.

You don't need to document ignored arguments.

> +(defun org-texinfo--combine-items (tree _backend info)
> +  "Combine certain description list items.
> +
> +_BACKEND is the symbol `texinfo'; the back-end used for export.
> +INFO is a plist used as a communication channel.

Same as above.

> +If the `:combine' attribute of a description list is non-nil and
> +an item in that list has no body and is followed by another item,
> +then remove the first item and prepend its `:tag' to that of the
> +second item.
> +
> +Such an item that absorbed the tags of other items is later
> +transcoded to one `@item', followed by one or more `@itemx'.
> +
> +Return new tree."
> +  (org-element-map tree 'item
> +    (lambda (item)
> +      (let ((plain-list (org-element-property :parent item)))
> +	(when (and (org-not-nil (org-export-read-attribute
> +				 :attr_texinfo plain-list :compact))
> +		   (eq (org-element-property :type plain-list) 'descriptive))
> +	  (let ((next-item
> +		 (cadr (memq item (org-element-contents plain-list)))))

I suggest to use `org-export-get-next-element', which is not as
low-level as this.

> +	    (when (and next-item
> +		       (not (org-element-contents item))
> +		       (= (org-element-property :post-blank item) 1))

Be careful, (org-element-property :post-blank item) may be nil.
I suggest to use (eq 1 (org-element-property :post-blank item)) instead.

> -	 (items (and tag
> -		     (let ((tag (org-export-data tag info)))
> +	 (items (org-element-property :itemx item))
> +	 (items (cond (items
> +		       (mapcar (lambda (tag) (org-export-data tag info))
> +			       (nconc items (list tag))))
> +		      ((not tag) nil)
> +		      (t
> +		       (setq tag (org-export-data tag info))

OK, but I think this is a bit convoluted. I wonder if we need
`org-texinfo--combine-items' at all. I.e., `org-texinfo-item' could
decide to prefix current tag with @itemx if 1) the item is empty 2) the
list has a non-nil :compact attribute 3) there's another item following
it. IOW, we do not need to rely on an :itemx property.

WDYT?

Regards,
-- 
Nicolas Goaziou


  reply	other threads:[~2022-01-22 15:34 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 18:01 Merging ox-texinfo+ into ox-texinfo Jonas Bernoulli
2021-11-19 12:46 ` Nicolas Goaziou
2021-11-20 21:06   ` Jonas Bernoulli
2021-11-21 12:41     ` Nicolas Goaziou
2021-11-30 16:58       ` Jonas Bernoulli
2021-12-18 21:40         ` [PATCH 0/2] ox-texinfo: Define definition commands using description lists Jonas Bernoulli
2021-12-18 21:40           ` [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx Jonas Bernoulli
2021-12-26 21:37             ` Nicolas Goaziou
2021-12-27 18:05               ` Jonas Bernoulli
2021-12-30  9:40                 ` Nicolas Goaziou
2022-01-05 13:12                   ` Jonas Bernoulli
2022-01-23 15:01                   ` Jonas Bernoulli
2021-12-18 21:40           ` [PATCH 2/2] ox-texinfo: Define definition commands using description lists Jonas Bernoulli
2021-12-26 21:46             ` Nicolas Goaziou
2021-12-27 18:05               ` Jonas Bernoulli
2021-12-30  0:57                 ` Nicolas Goaziou
2022-01-05 13:16                   ` Jonas Bernoulli
2022-01-05 13:30           ` [PATCH v2 0/3] " Jonas Bernoulli
2022-01-05 13:30             ` [PATCH v2 1/3] ox-texinfo: Add function for use by kbd macro Jonas Bernoulli
2022-01-05 13:30             ` [PATCH v2 2/3] ox-texinfo: Optionally use @itemx for certain description list items Jonas Bernoulli
2022-01-05 13:30             ` [PATCH v2 3/3] ox-texinfo: Define definition commands using description lists Jonas Bernoulli
2022-01-14 23:01             ` [PATCH v2 0/3] " Jonas Bernoulli
2022-01-18 15:11           ` [PATCH v3 " Jonas Bernoulli
2022-01-18 15:11             ` [PATCH v3 1/3] ox-texinfo: Add function for use by kbd macro Jonas Bernoulli
2022-01-22 15:19               ` Nicolas Goaziou
2022-01-18 15:11             ` [PATCH v3 2/3] ox-texinfo: Optionally use @itemx for certain description list items Jonas Bernoulli
2022-01-22 15:33               ` Nicolas Goaziou [this message]
2022-01-23  1:26                 ` Jonas Bernoulli
2022-01-23 20:43                 ` Jonas Bernoulli
2022-01-18 15:11             ` [PATCH v3 3/3] ox-texinfo: Define definition commands using description lists Jonas Bernoulli
2022-01-23  0:02               ` Nicolas Goaziou
2022-01-23  1:14                 ` Jonas Bernoulli
2022-01-23 14:45                 ` Jonas Bernoulli
2022-01-23 20:27           ` [PATCH v4 0/3] " Jonas Bernoulli
2022-01-23 20:27             ` [PATCH v4 1/3] ox-texinfo: Add function for use by kbd macro Jonas Bernoulli
2022-01-23 20:27             ` [PATCH v4 2/3] ox-texinfo: Optionally use @itemx for certain description list items Jonas Bernoulli
2022-01-23 21:17               ` Jonas Bernoulli
2022-01-23 20:27             ` [PATCH v4 3/3] ox-texinfo: Define definition commands using description lists Jonas Bernoulli
2022-01-31 23:45           ` [PATCH v5 0/4] " Jonas Bernoulli
2022-01-31 23:45             ` [PATCH v5 1/4] ox-texinfo: Add function for use by kbd macro Jonas Bernoulli
2022-01-31 23:45             ` [PATCH v5 2/4] ox-texinfo: Optionally use @itemx for certain description list items Jonas Bernoulli
2022-01-31 23:45             ` [PATCH v5 3/4] ox-texinfo: Define definition commands using description lists Jonas Bernoulli
2022-01-31 23:45             ` [PATCH v5 4/4] ox-texinfo: Allow enabling compact syntax for @itemx per file Jonas Bernoulli
2022-02-08 23:46             ` [PATCH v5 0/4] ox-texinfo: Define definition commands using description lists Nicolas Goaziou
2022-02-11 20:01               ` Jonas Bernoulli
2022-02-15 21:01               ` [PATCH] etc/ORG-NEWS: Add news items about new features in texinfo exporter Jonas Bernoulli
2022-02-22 19:14                 ` Nicolas Goaziou

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=874k5vzswr.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=jonas@bernoul.li \
    --subject='Re: [PATCH v3 2/3] ox-texinfo: Optionally use @itemx for certain description list items' \
    /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

Code repositories for project(s) associated with this 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).