Browse Source

ox-texinfo: Allow enabling compact syntax for @itemx per file

* doc/org-manual.org (Plain lists in Texinfo export): Document the
:texinfo-compact-itemx export option and variable
org-texinfo-compact-itemx.
(Texinfo specific properties): Mention new export option and variable.
* lisp/ox-texinfo.el: Add org-texinfo-compact-itemx to the
:options-alist of the texinfo backend.
* lisp/ox-texinfo.el (org-texinfo-compact-itemx): New option.
* lisp/ox-texinfo.el (org-texinfo--massage-key-item): Add INFO
argument and use the :texinfo-compact-itemx export option.
* lisp/ox-texinfo.el (org-texinfo-item): Use the
:texinfo-compact-itemx export option.
Jonas Bernoulli 3 years ago
parent
commit
98588ebfe1
2 changed files with 36 additions and 14 deletions
  1. 9 5
      doc/org-manual.org
  2. 27 9
      lisp/ox-texinfo.el

+ 9 - 5
doc/org-manual.org

@@ -15307,11 +15307,14 @@ example is transcoded to the same output as above.
   This is the common text for variables foo and bar.
   This is the common text for variables foo and bar.
 #+end_example
 #+end_example
 
 
-Likewise, the Texinfo export back-end supports two approaches to
-writing Texinfo definition commands (see [[info:texinfo::Definition
-Commands]]).  One of them uses description lists and is described below,
-the other relies on special blocks (see [[*Special blocks in Texinfo
-export]]).
+Support for this compact syntax can also be enabled for all lists in
+a file using the =compact-itemx= export option, or globally using the
+variable ~org-texinfo-compact-itemx~.
+
+The Texinfo export back-end also supports two approaches to writing
+Texinfo definition commands (see [[info:texinfo::Definition Commands]]).
+One of them uses description lists and is described below, the other
+relies on special blocks (see [[*Special blocks in Texinfo export]]).
 
 
 Items in a description list in a Org file that begin with =Function:=
 Items in a description list in a Org file that begin with =Function:=
 or certain other prefixes are converted using Texinfo definition
 or certain other prefixes are converted using Texinfo definition
@@ -16333,6 +16336,7 @@ Settings]]), however, override everything.
 | ~:texinfo-active-timestamp-format~       | ~org-texinfo-active-timestamp-format~       |
 | ~:texinfo-active-timestamp-format~       | ~org-texinfo-active-timestamp-format~       |
 | ~:texinfo-classes~                       | ~org-texinfo-classes~                       |
 | ~:texinfo-classes~                       | ~org-texinfo-classes~                       |
 | ~:texinfo-class~                         | ~org-texinfo-default-class~                 |
 | ~:texinfo-class~                         | ~org-texinfo-default-class~                 |
+| ~:texinfo-compact-itemx                  | ~org-texinfo-compact-itemx~                 |
 | ~:texinfo-table-default-markup~          | ~org-texinfo-table-default-markup~          |
 | ~:texinfo-table-default-markup~          | ~org-texinfo-table-default-markup~          |
 | ~:texinfo-diary-timestamp-format~        | ~org-texinfo-diary-timestamp-format~        |
 | ~:texinfo-diary-timestamp-format~        | ~org-texinfo-diary-timestamp-format~        |
 | ~:texinfo-filename~                      | ~org-texinfo-filename~                      |
 | ~:texinfo-filename~                      | ~org-texinfo-filename~                      |

+ 27 - 9
lisp/ox-texinfo.el

@@ -119,8 +119,8 @@
     (:texinfo-table-default-markup nil nil org-texinfo-table-default-markup)
     (:texinfo-table-default-markup nil nil org-texinfo-table-default-markup)
     (:texinfo-text-markup-alist nil nil org-texinfo-text-markup-alist)
     (:texinfo-text-markup-alist nil nil org-texinfo-text-markup-alist)
     (:texinfo-format-drawer-function nil nil org-texinfo-format-drawer-function)
     (:texinfo-format-drawer-function nil nil org-texinfo-format-drawer-function)
-    (:texinfo-format-inlinetask-function nil nil org-texinfo-format-inlinetask-function)))
-
+    (:texinfo-format-inlinetask-function nil nil org-texinfo-format-inlinetask-function)
+    (:texinfo-compact-itemx nil "compact-itemx" org-texinfo-compact-itemx)))
 
 
 
 
 ;;; User Configurable Variables
 ;;; User Configurable Variables
@@ -355,6 +355,20 @@ The function should return the string to be exported."
   :group 'org-export-texinfo
   :group 'org-export-texinfo
   :type 'function)
   :type 'function)
 
 
+;;;; Itemx
+
+(defcustom org-texinfo-compact-itemx nil
+  "Non-nil means certain items in description list become `@itemx'.
+
+If this 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'.  See info node `(org)Plain lists in
+Texinfo export' for how to enable this for individual lists."
+  :package-version '(Org . "9.6")
+  :group 'org-export-texinfo
+  :type 'boolean
+  :safe t)
+
 ;;;; Compilation
 ;;;; Compilation
 
 
 (defcustom org-texinfo-info-process '("makeinfo --no-split %f")
 (defcustom org-texinfo-info-process '("makeinfo --no-split %f")
@@ -614,7 +628,7 @@ Return new tree."
 		(org-texinfo--split-definition plain-list item cmd args))
 		(org-texinfo--split-definition plain-list item cmd args))
 	       (t
 	       (t
 		(when args
 		(when args
-		  (org-texinfo--massage-key-item plain-list item args))
+		  (org-texinfo--massage-key-item plain-list item args info))
 		(push item items)))))
 		(push item items)))))
 	  (unless (org-element-contents plain-list)
 	  (unless (org-element-contents plain-list)
 	    (org-element-extract-element plain-list)))))
 	    (org-element-extract-element plain-list)))))
@@ -663,7 +677,7 @@ new plain list."
 	  (mapc #'org-element-extract-element items))
 	  (mapc #'org-element-extract-element items))
    plain-list))
    plain-list))
 
 
-(defun org-texinfo--massage-key-item (plain-list item args)
+(defun org-texinfo--massage-key-item (plain-list item args info)
   "In PLAIN-LIST modify ITEM based on ARGS.
   "In PLAIN-LIST modify ITEM based on ARGS.
 
 
 Reformat ITEM's tag property and determine the arguments for the
 Reformat ITEM's tag property and determine the arguments for the
@@ -674,7 +688,9 @@ If PLAIN-LIST is a description list whose `:compact' attribute is
 non-nil and ITEM has no content but is followed by another item,
 non-nil and ITEM has no content but is followed by another item,
 then store the `@findex' and `@kindex' values in the next item.
 then store the `@findex' and `@kindex' values in the next item.
 If the previous item stored its respecive values in this item,
 If the previous item stored its respecive values in this item,
-then move them to the next item."
+then move them to the next item.
+
+INFO is a plist used as a communication channel."
   (let ((key nil)
   (let ((key nil)
 	(cmd nil))
 	(cmd nil))
     (if (string-match (rx (+ " ")
     (if (string-match (rx (+ " ")
@@ -701,8 +717,9 @@ then move them to the next item."
 	(setq kindex (nconc kindex (list key))))
 	(setq kindex (nconc kindex (list key))))
       (cond
       (cond
        ((and next-item
        ((and next-item
-	     (org-not-nil
-	      (org-export-read-attribute :attr_texinfo plain-list :compact))
+             (or (plist-get info :texinfo-compact-itemx)
+	         (org-not-nil
+	          (org-export-read-attribute :attr_texinfo plain-list :compact)))
 	     (not (org-element-contents item))
 	     (not (org-element-contents item))
 	     (eq 1 (org-element-property :post-blank item)))
 	     (eq 1 (org-element-property :post-blank item)))
 	(org-element-put-property next-item :findex findex)
 	(org-element-put-property next-item :findex findex)
@@ -1138,8 +1155,9 @@ contextual information."
   (let* ((tag (org-element-property :tag item))
   (let* ((tag (org-element-property :tag item))
          (plain-list (org-element-property :parent item))
          (plain-list (org-element-property :parent item))
          (compact (and (eq (org-element-property :type plain-list) 'descriptive)
          (compact (and (eq (org-element-property :type plain-list) 'descriptive)
-                       (org-not-nil (org-export-read-attribute
-                                     :attr_texinfo plain-list :compact))))
+                       (or (plist-get info :texinfo-compact-itemx)
+                           (org-not-nil (org-export-read-attribute
+                                         :attr_texinfo plain-list :compact)))))
          (previous-item nil))
          (previous-item nil))
     (when (and compact
     (when (and compact
                (org-export-get-next-element item info)
                (org-export-get-next-element item info)