update packages

This commit is contained in:
2025-06-22 17:08:08 +02:00
parent 54e5633369
commit 16a0a6db93
558 changed files with 68349 additions and 26568 deletions

View File

@@ -1,9 +1,8 @@
;;; ox-texinfo.el --- Texinfo Back-End for Org Export Engine -*- lexical-binding: t; -*-
;;; ox-texinfo.el --- Texinfo Backend for Org Export Engine -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2023 Free Software Foundation, Inc.
;; Copyright (C) 2012-2025 Free Software Foundation, Inc.
;; Author: Jonathan Leech-Pepin <jonathan.leechpepin at gmail dot com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@@ -31,6 +30,7 @@
(require 'cl-lib)
(require 'ox)
(require 'org-element-ast)
(eval-when-compile (require 'subr-x))
@@ -38,7 +38,7 @@
(defvar org-texinfo-supports-math--cache)
;;; Define Back-End
;;; Define Backend
(org-export-define-backend 'texinfo
'((bold . org-texinfo-bold)
@@ -110,7 +110,8 @@
(:subtitle "SUBTITLE" nil nil parse)
(:subauthor "SUBAUTHOR" nil nil newline)
(:texinfo-dircat "TEXINFO_DIR_CATEGORY" nil nil t)
(:texinfo-dirtitle "TEXINFO_DIR_TITLE" nil nil t)
(:texinfo-dirtitle "TEXINFO_DIR_TITLE" nil nil t) ;Obsolete.
(:texinfo-dirname "TEXINFO_DIR_NAME" nil nil t)
(:texinfo-dirdesc "TEXINFO_DIR_DESC" nil nil t)
(:texinfo-printed-title "TEXINFO_PRINTED_TITLE" nil nil t)
;; Other variables.
@@ -147,12 +148,10 @@
"Default document encoding for Texinfo output.
If nil it will default to `buffer-file-coding-system'."
:group 'org-export-texinfo
:type 'coding-system)
(defcustom org-texinfo-default-class "info"
"The default Texinfo class."
:group 'org-export-texinfo
:type '(string :tag "Texinfo class"))
(defcustom org-texinfo-classes
@@ -205,7 +204,6 @@ The sectioning structure of the class is given by the elements
following the header string. For each sectioning level, a number
of strings is specified. A %s formatter is mandatory in each
section string and will be replaced by the title of the section."
:group 'org-export-texinfo
:version "27.1"
:package-version '(Org . "9.2")
:type '(repeat
@@ -233,7 +231,6 @@ TEXT the main headline text (string).
TAGS the tags as a list of strings (list of strings or nil).
The function result will be used in the section format string."
:group 'org-export-texinfo
:type 'function
:version "26.1"
:package-version '(Org . "8.3"))
@@ -244,38 +241,32 @@ The function result will be used in the section format string."
"Column at which to start the description in the node listings.
If a node title is greater than this length, the description will
be placed after the end of the title."
:group 'org-export-texinfo
:type 'integer)
;;;; Timestamps
(defcustom org-texinfo-active-timestamp-format "@emph{%s}"
"A printf format string to be applied to active timestamps."
:group 'org-export-texinfo
:type 'string)
(defcustom org-texinfo-inactive-timestamp-format "@emph{%s}"
"A printf format string to be applied to inactive timestamps."
:group 'org-export-texinfo
:type 'string)
(defcustom org-texinfo-diary-timestamp-format "@emph{%s}"
"A printf format string to be applied to diary timestamps."
:group 'org-export-texinfo
:type 'string)
;;;; Links
(defcustom org-texinfo-link-with-unknown-path-format "@indicateurl{%s}"
"Format string for links with unknown path type."
:group 'org-export-texinfo
:type 'string)
;;;; Tables
(defcustom org-texinfo-tables-verbatim nil
"When non-nil, tables are exported verbatim."
:group 'org-export-texinfo
:type 'boolean)
(defcustom org-texinfo-table-scientific-notation nil
@@ -285,7 +276,6 @@ The format should have \"%s\" twice, for mantissa and exponent
\(i.e. \"%s\\\\times10^{%s}\").
When nil, no transformation is made."
:group 'org-export-texinfo
:type '(choice
(string :tag "Format string")
(const :tag "No formatting" nil)))
@@ -297,7 +287,6 @@ This should an indicating command, e.g., \"@code\", \"@kbd\" or
\"@samp\".
It can be overridden locally using the \":indic\" attribute."
:group 'org-export-texinfo
:type 'string
:version "26.1"
:package-version '(Org . "9.1")
@@ -323,7 +312,6 @@ to typeset and protects special characters.
When no association is found for a given markup, text is returned
as-is."
:group 'org-export-texinfo
:version "26.1"
:package-version '(Org . "9.1")
:type 'alist
@@ -341,7 +329,6 @@ The function must accept two parameters:
The function should return the string to be exported.
The default function simply returns the value of CONTENTS."
:group 'org-export-texinfo
:version "24.4"
:package-version '(Org . "8.2")
:type 'function)
@@ -361,7 +348,6 @@ The function must accept six parameters:
CONTENTS the contents of the inlinetask, as a string.
The function should return the string to be exported."
:group 'org-export-texinfo
:type 'function)
;;;; LaTeX
@@ -374,7 +360,6 @@ fragments as Texinfo \"@displaymath\" and \"@math\" commands
respectively. Alternatively, when set to `detect', the exporter
does so only if the installed version of Texinfo supports the
necessary commands."
:group 'org-export-texinfo
:package-version '(Org . "9.6")
:type '(choice
(const :tag "Detect" detect)
@@ -391,7 +376,6 @@ 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)
@@ -406,7 +390,6 @@ relative file name, %F by the absolute file name, %b by the file
base name (i.e. without directory and extension parts), %o by the
base directory of the file and %O by the absolute file name of
the output file."
:group 'org-export-texinfo
:version "26.1"
:package-version '(Org . "9.1")
:type '(repeat :tag "Shell command sequence"
@@ -417,7 +400,6 @@ the output file."
"The list of file extensions to consider as Texinfo logfiles.
The logfiles will be remove if `org-texinfo-remove-logfiles' is
non-nil."
:group 'org-export-texinfo
:type '(repeat (string :tag "Extension")))
(defcustom org-texinfo-remove-logfiles t
@@ -486,7 +468,7 @@ If two strings share the same prefix (e.g. \"ISO-8859-1\" and
(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 specifying backend used for export.
INFO is a plist used as a communication channel.
Make sure every headline in TREE contains a section, since those
@@ -501,10 +483,10 @@ Return new tree."
(when contents
(let ((first (org-element-map contents '(headline section)
#'identity info t)))
(unless (eq (org-element-type first) 'section)
(apply #'org-element-set-contents
hl
(cons `(section (:parent ,hl)) contents)))))))
(unless (org-element-type-p first 'section)
(apply #'org-element-set-contents
hl
(org-element-create 'section `(:parent ,hl)) contents))))))
info)
tree)
@@ -559,7 +541,7 @@ node or anchor name is unique."
;; Consequently, we ensure that every parent headline gets
;; its node beforehand. As a recursive operation, this
;; achieves the desired effect.
(let ((parent (org-element-lineage datum '(headline))))
(let ((parent (org-element-lineage datum 'headline)))
(when (and parent (not (assq parent cache)))
(org-texinfo--get-node parent info)
(setq cache (plist-get info :texinfo-node-cache))))
@@ -657,7 +639,7 @@ Return new tree."
(org-texinfo--massage-key-item plain-list item args info))
(push item items)))))
(unless (org-element-contents plain-list)
(org-element-extract-element plain-list)))))
(org-element-extract plain-list)))))
info)
tree)
@@ -687,9 +669,9 @@ specified by CMD and ARGS."
(list :type cmd
:attr_texinfo (list (format ":options %s" args))
:post-blank (if contents 1 0))
(mapc #'org-element-extract-element contents))
(mapc #'org-element-extract contents))
plain-list))
(org-element-extract-element item))
(org-element-extract item))
(defun org-texinfo--split-plain-list (plain-list items)
"Insert a new plain list before the plain list PLAIN-LIST.
@@ -700,7 +682,7 @@ new plain list."
(list :type 'descriptive
:attr_texinfo (org-element-property :attr_texinfo plain-list)
:post-blank 1)
(mapc #'org-element-extract-element items))
(mapc #'org-element-extract items))
plain-list))
(defun org-texinfo--massage-key-item (plain-list item args info)
@@ -747,7 +729,7 @@ INFO is a plist used as a communication channel."
(org-not-nil
(org-export-read-attribute :attr_texinfo plain-list :compact)))
(not (org-element-contents item))
(eq 1 (org-element-property :post-blank item)))
(eq 1 (org-element-post-blank item)))
(org-element-put-property next-item :findex findex)
(org-element-put-property next-item :kindex kindex)
(org-element-put-property item :findex nil)
@@ -815,25 +797,49 @@ holding export options."
(format "@copying\n%s@end copying\n\n"
(org-element-normalize-string
(org-export-data copying info))))
;; Info directory information. Only supply if both title and
;; category are provided.
(let ((dircat (plist-get info :texinfo-dircat))
(dirtitle
(let ((title (plist-get info :texinfo-dirtitle)))
(and title
(string-match "^\\(?:\\* \\)?\\(.*?\\)\\(\\.\\)?$" title)
(format "* %s." (match-string 1 title))))))
(when (and dircat dirtitle)
(concat "@dircategory " dircat "\n"
"@direntry\n"
(let ((dirdesc
(let ((desc (plist-get info :texinfo-dirdesc)))
(cond ((not desc) nil)
((string-suffix-p "." desc) desc)
(t (concat desc "."))))))
(if dirdesc (format "%-23s %s" dirtitle dirdesc) dirtitle))
"\n"
"@end direntry\n\n")))
(let* ((dircat (or (plist-get info :texinfo-dircat) "Misc"))
(file (or (org-strip-quotes (plist-get info :texinfo-filename))
(plist-get info :output-file)))
(file (if file (file-name-sans-extension file)))
(dn (or (plist-get info :texinfo-dirname)
(plist-get info :texinfo-dirtitle))) ;Obsolete name.
;; Strip any terminating `.' from `dn'.
(dn (if (and dn (string-match "\\.\\'" dn)) (substring dn 0 -1) dn))
;; The direntry we need to produce has the shape:
;; * DIRNAME: NODE. DESCRIPTION.
;; where NODE is usually just `(FILENAME)', and where
;; `* FILENAME.' is a shorthand for `* FILENAME: (FILENAME).'
(dirname
(cond
((and dn (string-match
(eval-when-compile
(concat "\\`\\(?:"
"\\* \\(?1:.*\\)" ;Starts with `* ' or
"\\|\\(?1:.*(.*).*\\)" ;contains parens.
"\\)\\'"))
dn))
;; When users provide a `dn' that looks like a complete
;; `* DIRNAME: (FILENAME).' thingy, we just trust them to
;; provide something valid (just making sure it starts
;; with `* ' and ends with `.').
(format "* %s." (match-string 1 dn)))
;; `dn' is presumed to be just the DIRNAME part, so generate
;; either `* DIRNAME: (FILENAME).' or `* FILENAME.', whichever
;; is shortest.
(dn
(format "* %s: (%s)." dn (or file dn)))
(t (format "* (%s)." file)))))
(concat "@dircategory " dircat "\n"
"@direntry\n"
(let ((dirdesc
(let ((desc (or (plist-get info :texinfo-dirdesc)
title)))
(cond ((not desc) nil)
((string-suffix-p "." desc) desc)
(t (concat desc "."))))))
(if dirdesc (format "%-23s %s" dirname dirdesc) dirname))
"\n"
"@end direntry\n\n"))
;; Title
"@finalout\n"
"@titlepage\n"
@@ -1046,7 +1052,7 @@ plist holding contextual information."
;; character before the closing brace. However, when the
;; footnote ends with a paragraph, it is visually pleasing
;; to move the brace right after its end.
(if (eq 'paragraph (org-element-type (org-last contents)))
(if (org-element-type-p (org-last contents) 'paragraph)
(org-trim data)
data))))
@@ -1179,21 +1185,21 @@ contextual information."
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((tag (org-element-property :tag item))
(plain-list (org-element-property :parent item))
(plain-list (org-element-parent item))
(compact (and (eq (org-element-property :type plain-list) 'descriptive)
(or (plist-get info :texinfo-compact-itemx)
(org-not-nil (org-export-read-attribute
:attr_texinfo plain-list :compact)))))
:attr_texinfo plain-list :compact)))))
(previous-item nil))
(when (and compact
(org-export-get-next-element item info)
(not (org-element-contents item))
(eq 1 (org-element-property :post-blank item)))
(eq 1 (org-element-post-blank item)))
(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)))
(eq 0 (org-element-post-blank previous-item)))
(format "@itemx%s\n%s"
(if tag (concat " " (org-export-data tag info)) "")
(or contents ""))
@@ -1320,11 +1326,9 @@ INFO is a plist holding contextual information. See
(desc (and (not (string= desc "")) desc))
(path (org-texinfo--sanitize-content
(cond
((member type '("http" "https" "ftp"))
(concat type ":" raw-path))
((string-equal type "file")
(org-export-file-uri raw-path))
(t raw-path)))))
(t (concat type ":" raw-path))))))
(cond
((org-export-custom-protocol-maybe link desc 'texinfo info))
((org-export-inline-image-p link org-texinfo-inline-image-rules)
@@ -1350,10 +1354,11 @@ INFO is a plist holding contextual information. See
;; @anchor{}, so we refer to the headline parent
;; directly.
(and `target
(guard (eq 'headline
(org-element-type
(org-element-property :parent destination))))))
(let ((headline (org-element-lineage destination '(headline) t)))
(guard
(org-element-type-p
(org-element-parent destination)
'headline))))
(let ((headline (org-element-lineage destination 'headline t)))
(org-texinfo--@ref headline desc info)))
(_ (org-texinfo--@ref destination desc info)))))
((string= type "mailto")
@@ -1371,7 +1376,7 @@ INFO is a plist holding contextual information. See
"Return Texinfo code for an inline image.
LINK is the link pointing to the inline image. INFO is the
current state of the export, as a plist."
(let* ((parent (org-export-get-parent-element link))
(let* ((parent (org-element-parent-element link))
(label (and (org-element-property :name parent)
(org-texinfo--get-node parent info)))
(caption (org-export-get-caption parent))
@@ -1512,7 +1517,12 @@ information."
"Transcode a PARAGRAPH element from Org to Texinfo.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
contents)
;; Ensure that we do not create multiple paragraphs, when a single
;; paragraph is expected.
;; Multiple newlines may appear in CONTENTS, for example, when
;; certain objects are stripped from export, leaving single newlines
;; before and after.
(org-remove-blank-lines contents))
;;;; Plain List
@@ -1590,7 +1600,7 @@ information."
(concat
"@noindent"
(mapconcat
'identity
#'identity
(delq nil
(list
(let ((closed (org-element-property :closed planning)))
@@ -1652,7 +1662,7 @@ contextual information."
"Transcode a SECTION element from Org to Texinfo.
CONTENTS holds the contents of the section. INFO is a plist
holding contextual information."
(let ((parent (org-export-get-parent-headline section)))
(let ((parent (org-element-lineage section 'headline)))
(when parent ;first section is handled in `org-texinfo-template'
(org-trim
(concat contents
@@ -1680,8 +1690,9 @@ as a communication channel."
"Transcode a SRC-BLOCK element from Org to Texinfo.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((lisp (string-match-p "lisp"
(org-element-property :language src-block)))
(let* ((lisp (string-match-p
"lisp"
(or (org-element-property :language src-block) "")))
(code (org-texinfo--sanitize-content
(org-export-format-code-default src-block info)))
(value (format
@@ -1770,8 +1781,8 @@ a communication channel."
;; approximation of the length of the cell in the
;; output. It can sometimes fail (e.g. it considers
;; "/a/" being larger than "ab").
(let ((w (- (org-element-property :contents-end cell)
(org-element-property :contents-begin cell))))
(let ((w (- (org-element-contents-end cell)
(org-element-contents-begin cell))))
(aset widths idx (max w (aref widths idx))))
(cl-incf idx))
info)))
@@ -1809,7 +1820,7 @@ a communication channel."
(let ((rowgroup-tag
(if (and (= 1 (org-export-table-row-group table-row info))
(org-export-table-has-header-p
(org-export-get-parent-table table-row) info))
(org-element-lineage table-row 'table) info))
"@headitem "
"@item ")))
(concat rowgroup-tag contents "\n"))))
@@ -1993,6 +2004,8 @@ command to convert it."
(interactive)
(org-export-replace-region-by 'texinfo))
(defalias 'org-export-region-to-texinfo #'org-texinfo-convert-region-to-texinfo)
(defun org-texinfo-compile (file)
"Compile a texinfo file.
@@ -2024,9 +2037,11 @@ Once computed, the results remain cached."
(unless (boundp 'org-texinfo-supports-math--cache)
(setq org-texinfo-supports-math--cache
(let ((math-example "1 + 1 = 2"))
(let* ((input-file (make-temp-file "test" nil ".info"))
(let* ((input-file (make-temp-file "test" nil ".texi"))
(output-file
(concat (file-name-sans-extension input-file) ".info"))
(input-content (string-join
(list (format "@setfilename %s" input-file)
(list (format "@setfilename %s" output-file)
"@node Top"
"@displaymath"
math-example
@@ -2037,7 +2052,8 @@ Once computed, the results remain cached."
(when-let* ((output-file
;; If compilation fails, consider math to
;; be not supported.
(ignore-errors (org-texinfo-compile input-file)))
(ignore-errors (let ((inhibit-message t))
(org-texinfo-compile input-file))))
(output-content (with-temp-buffer
(insert-file-contents output-file)
(buffer-string))))