* doc/org-manual.org (Plain lists in Texinfo export): Reorder and document new functionality. * lisp/ox-texinfo.el (org-texinfo-item): In a description list when its :compact attribute is non-nil, then transcode consecutive items using one @item and one or more @itemx commands, if all of them except for the last one lack content. --- doc/org-manual.org | 36 +++++++++++++++++++++--------- lisp/ox-texinfo.el | 55 ++++++++++++++++++++++++++++++---------------- 2 files changed, 62 insertions(+), 29 deletions(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org index e88cf1ed9..344aaf3e7 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -15236,6 +15236,23 @@ This paragraph is preceded by... :DESCRIPTION: List attributes. :END: +#+cindex: lettered lists, in Texinfo export +#+cindex: enum, Texinfo attribute +The Texinfo export back-end converts unordered and ordered lists in +the Org file using the default command =@itemize=. + +Ordered lists are numbered when exported to Texinfo format. Such +numbering obeys any counter (see [[*Plain Lists]]) in the first item of +the list. The =:enum= attribute also let you start the list at a +specific number, or switch to a lettered list, as illustrated here: + +#+begin_example +#+ATTR_TEXINFO: :enum A +1. Alpha +2. Bravo +3. Charlie +#+end_example + #+cindex: @samp{ATTR_TEXINFO}, keyword #+cindex: two-column tables, in Texinfo export #+cindex: table-type, Texinfo attribute @@ -15277,18 +15294,17 @@ This is the common text for variables foo and bar. @end table #+end_example -#+cindex: lettered lists, in Texinfo export -#+cindex: enum, Texinfo attribute -Ordered lists are numbered when exported to Texinfo format. Such -numbering obeys any counter (see [[*Plain Lists]]) in the first item of -the list. The =:enum= attribute also let you start the list at -a specific number, or switch to a lettered list, as illustrated here +The =:compact= attribute is an alternative to the =:sep= attribute, +which allows writing each entry on its own line. If this attribute is +non-nil and an item in a description list has no body but is followed +by another item, then the second item is transcoded to =@itemx=. This +example is transcoded to the same output as above. #+begin_example -#+ATTR_TEXINFO: :enum A -1. Alpha -2. Bravo -3. Charlie +,#+ATTR_TEXINFO: :table-type vtable :indic asis :compact t +- foo :: +- bar :: + This is the common text for variables foo and bar. #+end_example *** Tables in Texinfo export diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index ddd405d05..9b2c0616c 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -997,25 +997,42 @@ (defun org-texinfo-item (item contents info) CONTENTS holds the contents of the item. INFO is a plist holding contextual information." (let* ((tag (org-element-property :tag item)) - (split (org-string-nw-p - (org-export-read-attribute :attr_texinfo - (org-element-property :parent item) - :sep))) - (items (and tag - (let ((tag (org-export-data tag info))) - (if split - (split-string tag (regexp-quote split) t "[ \t\n]+") - (list tag)))))) - (format "%s\n%s" - (pcase items - (`nil "@item") - (`(,item) (concat "@item " item)) - (`(,item . ,items) - (concat "@item " item "\n" - (mapconcat (lambda (i) (concat "@itemx " i)) - items - "\n")))) - (or contents "")))) + (plain-list (org-element-property :parent item)) + (compact (and (eq (org-element-property :type plain-list) 'descriptive) + (org-not-nil (org-export-read-attribute + :attr_texinfo plain-list :compact)))) + (previous-item nil)) + (when (and compact + (org-export-get-next-element item info) + (not (org-element-contents item)) + (memq (org-element-property :post-blank previous-item) + '(1 nil))) + (org-element-put-property item :post-blank 0)) + (if (and compact + (setq previous-item (org-export-get-previous-element item info)) + (not (org-element-contents previous-item)) + (eq 0 (org-element-property :post-blank previous-item))) + (format "@itemx%s\n%s" + (if tag (concat " " (org-export-data tag info)) "") + (or contents "")) + (let* ((split (org-string-nw-p (org-export-read-attribute + :attr_texinfo plain-list :sep))) + (items (and tag + (let ((tag (org-export-data tag info))) + (if split + (split-string tag (regexp-quote split) + t "[ \t\n]+") + (list tag)))))) + (format "%s\n%s" + (pcase items + (`nil "@item") + (`(,item) (concat "@item " item)) + (`(,item . ,items) + (concat "@item " item "\n" + (mapconcat (lambda (i) (concat "@itemx " i)) + items + "\n")))) + (or contents "")))))) ;;;; Keyword -- 2.34.1