emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 2/3] ox-texinfo: Optionally use @itemx for certain descrip


From: Nicolas Goaziou
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]