emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jonas Bernoulli <jonas@bernoul.li>
To: emacs-orgmode@gnu.org
Cc: kyle@kyleam.com, mail@nicolasgoaziou.fr
Subject: [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx
Date: Sat, 18 Dec 2021 22:40:37 +0100	[thread overview]
Message-ID: <20211218214038.9459-2-jonas@bernoul.li> (raw)
In-Reply-To: <20211218214038.9459-1-jonas@bernoul.li>

* doc/org-manual.org (Plain lists in Texinfo export): Reorder and
document new functionality.
* lisp/ox-texinfo.el (org-texinfo--filter-parse-tree)
(org-texinfo--normalize-items): New functions.
* lisp/ox-texinfo.el (org-texinfo-item): Use @itemx or @item
depending on the used bullet.
---
 doc/org-manual.org | 37 ++++++++++++++++++++++++++-----------
 lisp/ox-texinfo.el | 39 +++++++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 15 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index b65e2f173..b8bb391c2 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
@@ -15262,7 +15279,7 @@ entry in the first column of the table.
 The following example illustrates all the attributes above:
 
 #+begin_example
-,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
+,#+attr_texinfo: :table-type vtable :sep , :indic asis
 - foo, bar :: This is the common text for variables foo and bar.
 #+end_example
 
@@ -15277,18 +15294,16 @@ 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
+In description lists the used bullet is significant when exporting to
+Texinfo; when in doubt, then use =-=.  An item that uses =+= instead
+becomes a new entry in the first column of the table.  The above
+output can also be produced with:
 
 #+begin_example
-#+ATTR_TEXINFO: :enum A
-1. Alpha
-2. Bravo
-3. Charlie
+,#+attr_texinfo: :table-type vtable :indic asis
+- foo ::
++ bar ::
+  This is the common text for foo and bar.
 #+end_example
 
 *** Tables in Texinfo export
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index b0125894a..35862357d 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -418,6 +418,11 @@ (defun org-texinfo--filter-section-blank-lines (headline _backend _info)
   "Filter controlling number of blank lines after a section."
   (replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" "\n\n" headline))
 
+(defun org-texinfo--filter-parse-tree (tree backend info)
+  "Normalize headlines and items."
+  (org-texinfo--normalize-headlines tree backend info)
+  (org-texinfo--normalize-items tree info))
+
 (defun org-texinfo--normalize-headlines (tree _backend info)
   "Normalize headlines in TREE.
 
@@ -443,6 +448,29 @@ (defun org-texinfo--normalize-headlines (tree _backend info)
     info)
   tree)
 
+(defun org-texinfo--normalize-items (tree info)
+  "Normalize items in TREE.
+
+INFO is a plist used as a communication channel.
+
+Items in description lists that use the \"+\" bullet are
+converted to `@itemx'.  If another item is followed by such an
+item, then the first item should not be followed by a space,
+which this function takes care of.
+
+Return new tree."
+  (org-element-map tree 'plain-list
+    (lambda (plain-list)
+      (when (eq (org-element-property :type plain-list) 'descriptive)
+        (let ((contents (org-element-contents plain-list)))
+          (while (setq item (pop contents))
+            (let ((next-item (car contents)))
+              (when (and next-item
+                         (equal (org-element-property :bullet next-item) "+ "))
+                (org-element-put-property item :post-blank 0)))))))
+    info)
+  tree)
+
 (defun org-texinfo--find-verb-separator (s)
   "Return a character not used in string S.
 This is used to choose a separator for constructs like \\verb."
@@ -998,13 +1026,16 @@ (defun org-texinfo-item (item contents info)
 		     (let ((tag (org-export-data tag info)))
 		       (if split
 			   (split-string tag (regexp-quote split) t "[ \t\n]+")
-			 (list tag))))))
+			 (list tag)))))
+         (command (if (equal (org-element-property :bullet item) "+ ")
+                      "@itemx"
+                    "@item")))
     (format "%s\n%s"
 	    (pcase items
-	      (`nil "@item")
-	      (`(,item) (concat "@item " item))
+	      (`nil command)
+	      (`(,item) (concat command " " item))
 	      (`(,item . ,items)
-	       (concat "@item " item "\n"
+	       (concat command " " item "\n"
 		       (mapconcat (lambda (i) (concat "@itemx " i))
 				  items
 				  "\n"))))
-- 
2.34.1



  reply	other threads:[~2021-12-18 21:43 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           ` Jonas Bernoulli [this message]
2021-12-26 21:37             ` [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx 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
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=20211218214038.9459-2-jonas@bernoul.li \
    --to=jonas@bernoul.li \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \
    --cc=mail@nicolasgoaziou.fr \
    --subject='Re: [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx' \
    /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).