diff options
| author | Stefan Monnier | 2024-03-02 14:48:29 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2024-03-03 16:57:56 -0500 |
| commit | 5254c582efb3e7171e955dde653e7530d2d3ffef (patch) | |
| tree | 3d3ba6364d647e6f06db272d481f3062da4c2b37 | |
| parent | db7b87867b3002d72444f06110e3625aa8de680e (diff) | |
| download | emacs-5254c582efb3e7171e955dde653e7530d2d3ffef.tar.gz emacs-5254c582efb3e7171e955dde653e7530d2d3ffef.zip | |
ox-texinfo:: Require only TEXINFO_DIR_CATEGORY
Until now @dircategory/@direntry entries were added only if
both TEXINFO_DIR_CATEGORY and TEXINFO_DIR_TITLE were set.
And the setting of TEXINFO_DIR_TITLE had to be careful to
provide exactly the right syntax.
This patch changes various things in this regard:
- Only require TEXINFO_DIR_CATEGORY in order to generate
`@dircategory` and `@direntry`.
- Use the document title by default if TEXINFO_DIR_DESC is missing.
- Use the filename by default when TEXINFO_DIR_TITLE is missing.
- Try and make it harder to provide a direntry that does not
have the right format or refers to a different filename than
the one we're outputting to.
* lisp/org/ox-texinfo.el: Remove redundant `:group` arguments.
Prefer #' to quote function names.
(org-texinfo-template): Use sane defaults for `@direntry`.
* doc/misc/org.org (Texinfo specific export settings): Adjust accordingly.
| -rw-r--r-- | doc/misc/org.org | 11 | ||||
| -rw-r--r-- | lisp/org/ox-texinfo.el | 58 |
2 files changed, 37 insertions, 32 deletions
diff --git a/doc/misc/org.org b/doc/misc/org.org index 05ab5b36ca0..f4590525892 100644 --- a/doc/misc/org.org +++ b/doc/misc/org.org | |||
| @@ -15322,11 +15322,18 @@ the general options (see [[*Export Settings]]). | |||
| 15322 | 15322 | ||
| 15323 | #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword | 15323 | #+cindex: @samp{TEXINFO_DIR_TITLE}, keyword |
| 15324 | The directory title of the document. | 15324 | The directory title of the document. |
| 15325 | This is the short name under which the ~m~ command will find your | ||
| 15326 | manual in the main Info directory. It defaults to the base name of | ||
| 15327 | the Texinfo file. | ||
| 15328 | |||
| 15329 | If you need more control, it can also be the full entry using the | ||
| 15330 | syntax ~* TITLE: (FILENAME).~. | ||
| 15325 | 15331 | ||
| 15326 | - =TEXINFO_DIR_DESC= :: | 15332 | - =TEXINFO_DIR_DESC= :: |
| 15327 | 15333 | ||
| 15328 | #+cindex: @samp{TEXINFO_DIR_DESC}, keyword | 15334 | #+cindex: @samp{TEXINFO_DIR_DESC}, keyword |
| 15329 | The directory description of the document. | 15335 | The directory description of the document. |
| 15336 | Defaults to the title of the document. | ||
| 15330 | 15337 | ||
| 15331 | - =TEXINFO_PRINTED_TITLE= :: | 15338 | - =TEXINFO_PRINTED_TITLE= :: |
| 15332 | 15339 | ||
| @@ -15422,7 +15429,7 @@ Here is an example that writes to the Info directory file: | |||
| 15422 | 15429 | ||
| 15423 | #+begin_example | 15430 | #+begin_example |
| 15424 | ,#+TEXINFO_DIR_CATEGORY: Emacs | 15431 | ,#+TEXINFO_DIR_CATEGORY: Emacs |
| 15425 | ,#+TEXINFO_DIR_TITLE: Org Mode: (org) | 15432 | ,#+TEXINFO_DIR_TITLE: Org Mode |
| 15426 | ,#+TEXINFO_DIR_DESC: Outline-based notes management and organizer | 15433 | ,#+TEXINFO_DIR_DESC: Outline-based notes management and organizer |
| 15427 | #+end_example | 15434 | #+end_example |
| 15428 | 15435 | ||
| @@ -15830,7 +15837,7 @@ Texinfo code. | |||
| 15830 | ,#+TEXINFO_HEADER: @syncodeindex pg cp | 15837 | ,#+TEXINFO_HEADER: @syncodeindex pg cp |
| 15831 | 15838 | ||
| 15832 | ,#+TEXINFO_DIR_CATEGORY: Texinfo documentation system | 15839 | ,#+TEXINFO_DIR_CATEGORY: Texinfo documentation system |
| 15833 | ,#+TEXINFO_DIR_TITLE: sample: (sample) | 15840 | ,#+TEXINFO_DIR_TITLE: sample |
| 15834 | ,#+TEXINFO_DIR_DESC: Invoking sample | 15841 | ,#+TEXINFO_DIR_DESC: Invoking sample |
| 15835 | 15842 | ||
| 15836 | ,#+TEXINFO_PRINTED_TITLE: GNU Sample | 15843 | ,#+TEXINFO_PRINTED_TITLE: GNU Sample |
diff --git a/lisp/org/ox-texinfo.el b/lisp/org/ox-texinfo.el index 84313645e6e..5065c3fb63c 100644 --- a/lisp/org/ox-texinfo.el +++ b/lisp/org/ox-texinfo.el | |||
| @@ -110,6 +110,10 @@ | |||
| 110 | (:subtitle "SUBTITLE" nil nil parse) | 110 | (:subtitle "SUBTITLE" nil nil parse) |
| 111 | (:subauthor "SUBAUTHOR" nil nil newline) | 111 | (:subauthor "SUBAUTHOR" nil nil newline) |
| 112 | (:texinfo-dircat "TEXINFO_DIR_CATEGORY" nil nil t) | 112 | (:texinfo-dircat "TEXINFO_DIR_CATEGORY" nil nil t) |
| 113 | ;; FIXME: The naming of these options is unsatisfactory: | ||
| 114 | ;; TEXINFO_DIR_DESC corresponds (and defaults) to the document's | ||
| 115 | ;; title, whereas TEXINFO_DIR_TITLE corresponds (and defaults) to | ||
| 116 | ;; its filename. | ||
| 113 | (:texinfo-dirtitle "TEXINFO_DIR_TITLE" nil nil t) | 117 | (:texinfo-dirtitle "TEXINFO_DIR_TITLE" nil nil t) |
| 114 | (:texinfo-dirdesc "TEXINFO_DIR_DESC" nil nil t) | 118 | (:texinfo-dirdesc "TEXINFO_DIR_DESC" nil nil t) |
| 115 | (:texinfo-printed-title "TEXINFO_PRINTED_TITLE" nil nil t) | 119 | (:texinfo-printed-title "TEXINFO_PRINTED_TITLE" nil nil t) |
| @@ -147,12 +151,10 @@ | |||
| 147 | "Default document encoding for Texinfo output. | 151 | "Default document encoding for Texinfo output. |
| 148 | 152 | ||
| 149 | If nil it will default to `buffer-file-coding-system'." | 153 | If nil it will default to `buffer-file-coding-system'." |
| 150 | :group 'org-export-texinfo | ||
| 151 | :type 'coding-system) | 154 | :type 'coding-system) |
| 152 | 155 | ||
| 153 | (defcustom org-texinfo-default-class "info" | 156 | (defcustom org-texinfo-default-class "info" |
| 154 | "The default Texinfo class." | 157 | "The default Texinfo class." |
| 155 | :group 'org-export-texinfo | ||
| 156 | :type '(string :tag "Texinfo class")) | 158 | :type '(string :tag "Texinfo class")) |
| 157 | 159 | ||
| 158 | (defcustom org-texinfo-classes | 160 | (defcustom org-texinfo-classes |
| @@ -205,7 +207,6 @@ The sectioning structure of the class is given by the elements | |||
| 205 | following the header string. For each sectioning level, a number | 207 | following the header string. For each sectioning level, a number |
| 206 | of strings is specified. A %s formatter is mandatory in each | 208 | of strings is specified. A %s formatter is mandatory in each |
| 207 | section string and will be replaced by the title of the section." | 209 | section string and will be replaced by the title of the section." |
| 208 | :group 'org-export-texinfo | ||
| 209 | :version "27.1" | 210 | :version "27.1" |
| 210 | :package-version '(Org . "9.2") | 211 | :package-version '(Org . "9.2") |
| 211 | :type '(repeat | 212 | :type '(repeat |
| @@ -233,7 +234,6 @@ TEXT the main headline text (string). | |||
| 233 | TAGS the tags as a list of strings (list of strings or nil). | 234 | TAGS the tags as a list of strings (list of strings or nil). |
| 234 | 235 | ||
| 235 | The function result will be used in the section format string." | 236 | The function result will be used in the section format string." |
| 236 | :group 'org-export-texinfo | ||
| 237 | :type 'function | 237 | :type 'function |
| 238 | :version "26.1" | 238 | :version "26.1" |
| 239 | :package-version '(Org . "8.3")) | 239 | :package-version '(Org . "8.3")) |
| @@ -244,38 +244,32 @@ The function result will be used in the section format string." | |||
| 244 | "Column at which to start the description in the node listings. | 244 | "Column at which to start the description in the node listings. |
| 245 | If a node title is greater than this length, the description will | 245 | If a node title is greater than this length, the description will |
| 246 | be placed after the end of the title." | 246 | be placed after the end of the title." |
| 247 | :group 'org-export-texinfo | ||
| 248 | :type 'integer) | 247 | :type 'integer) |
| 249 | 248 | ||
| 250 | ;;;; Timestamps | 249 | ;;;; Timestamps |
| 251 | 250 | ||
| 252 | (defcustom org-texinfo-active-timestamp-format "@emph{%s}" | 251 | (defcustom org-texinfo-active-timestamp-format "@emph{%s}" |
| 253 | "A printf format string to be applied to active timestamps." | 252 | "A printf format string to be applied to active timestamps." |
| 254 | :group 'org-export-texinfo | ||
| 255 | :type 'string) | 253 | :type 'string) |
| 256 | 254 | ||
| 257 | (defcustom org-texinfo-inactive-timestamp-format "@emph{%s}" | 255 | (defcustom org-texinfo-inactive-timestamp-format "@emph{%s}" |
| 258 | "A printf format string to be applied to inactive timestamps." | 256 | "A printf format string to be applied to inactive timestamps." |
| 259 | :group 'org-export-texinfo | ||
| 260 | :type 'string) | 257 | :type 'string) |
| 261 | 258 | ||
| 262 | (defcustom org-texinfo-diary-timestamp-format "@emph{%s}" | 259 | (defcustom org-texinfo-diary-timestamp-format "@emph{%s}" |
| 263 | "A printf format string to be applied to diary timestamps." | 260 | "A printf format string to be applied to diary timestamps." |
| 264 | :group 'org-export-texinfo | ||
| 265 | :type 'string) | 261 | :type 'string) |
| 266 | 262 | ||
| 267 | ;;;; Links | 263 | ;;;; Links |
| 268 | 264 | ||
| 269 | (defcustom org-texinfo-link-with-unknown-path-format "@indicateurl{%s}" | 265 | (defcustom org-texinfo-link-with-unknown-path-format "@indicateurl{%s}" |
| 270 | "Format string for links with unknown path type." | 266 | "Format string for links with unknown path type." |
| 271 | :group 'org-export-texinfo | ||
| 272 | :type 'string) | 267 | :type 'string) |
| 273 | 268 | ||
| 274 | ;;;; Tables | 269 | ;;;; Tables |
| 275 | 270 | ||
| 276 | (defcustom org-texinfo-tables-verbatim nil | 271 | (defcustom org-texinfo-tables-verbatim nil |
| 277 | "When non-nil, tables are exported verbatim." | 272 | "When non-nil, tables are exported verbatim." |
| 278 | :group 'org-export-texinfo | ||
| 279 | :type 'boolean) | 273 | :type 'boolean) |
| 280 | 274 | ||
| 281 | (defcustom org-texinfo-table-scientific-notation nil | 275 | (defcustom org-texinfo-table-scientific-notation nil |
| @@ -285,7 +279,6 @@ The format should have \"%s\" twice, for mantissa and exponent | |||
| 285 | \(i.e. \"%s\\\\times10^{%s}\"). | 279 | \(i.e. \"%s\\\\times10^{%s}\"). |
| 286 | 280 | ||
| 287 | When nil, no transformation is made." | 281 | When nil, no transformation is made." |
| 288 | :group 'org-export-texinfo | ||
| 289 | :type '(choice | 282 | :type '(choice |
| 290 | (string :tag "Format string") | 283 | (string :tag "Format string") |
| 291 | (const :tag "No formatting" nil))) | 284 | (const :tag "No formatting" nil))) |
| @@ -297,7 +290,6 @@ This should an indicating command, e.g., \"@code\", \"@kbd\" or | |||
| 297 | \"@samp\". | 290 | \"@samp\". |
| 298 | 291 | ||
| 299 | It can be overridden locally using the \":indic\" attribute." | 292 | It can be overridden locally using the \":indic\" attribute." |
| 300 | :group 'org-export-texinfo | ||
| 301 | :type 'string | 293 | :type 'string |
| 302 | :version "26.1" | 294 | :version "26.1" |
| 303 | :package-version '(Org . "9.1") | 295 | :package-version '(Org . "9.1") |
| @@ -323,7 +315,6 @@ to typeset and protects special characters. | |||
| 323 | 315 | ||
| 324 | When no association is found for a given markup, text is returned | 316 | When no association is found for a given markup, text is returned |
| 325 | as-is." | 317 | as-is." |
| 326 | :group 'org-export-texinfo | ||
| 327 | :version "26.1" | 318 | :version "26.1" |
| 328 | :package-version '(Org . "9.1") | 319 | :package-version '(Org . "9.1") |
| 329 | :type 'alist | 320 | :type 'alist |
| @@ -341,7 +332,6 @@ The function must accept two parameters: | |||
| 341 | The function should return the string to be exported. | 332 | The function should return the string to be exported. |
| 342 | 333 | ||
| 343 | The default function simply returns the value of CONTENTS." | 334 | The default function simply returns the value of CONTENTS." |
| 344 | :group 'org-export-texinfo | ||
| 345 | :version "24.4" | 335 | :version "24.4" |
| 346 | :package-version '(Org . "8.2") | 336 | :package-version '(Org . "8.2") |
| 347 | :type 'function) | 337 | :type 'function) |
| @@ -361,7 +351,6 @@ The function must accept six parameters: | |||
| 361 | CONTENTS the contents of the inlinetask, as a string. | 351 | CONTENTS the contents of the inlinetask, as a string. |
| 362 | 352 | ||
| 363 | The function should return the string to be exported." | 353 | The function should return the string to be exported." |
| 364 | :group 'org-export-texinfo | ||
| 365 | :type 'function) | 354 | :type 'function) |
| 366 | 355 | ||
| 367 | ;;;; LaTeX | 356 | ;;;; LaTeX |
| @@ -374,7 +363,6 @@ fragments as Texinfo \"@displaymath\" and \"@math\" commands | |||
| 374 | respectively. Alternatively, when set to `detect', the exporter | 363 | respectively. Alternatively, when set to `detect', the exporter |
| 375 | does so only if the installed version of Texinfo supports the | 364 | does so only if the installed version of Texinfo supports the |
| 376 | necessary commands." | 365 | necessary commands." |
| 377 | :group 'org-export-texinfo | ||
| 378 | :package-version '(Org . "9.6") | 366 | :package-version '(Org . "9.6") |
| 379 | :type '(choice | 367 | :type '(choice |
| 380 | (const :tag "Detect" detect) | 368 | (const :tag "Detect" detect) |
| @@ -391,7 +379,6 @@ body but is followed by another item, then the second item is | |||
| 391 | transcoded to `@itemx'. See info node `(org)Plain lists in | 379 | transcoded to `@itemx'. See info node `(org)Plain lists in |
| 392 | Texinfo export' for how to enable this for individual lists." | 380 | Texinfo export' for how to enable this for individual lists." |
| 393 | :package-version '(Org . "9.6") | 381 | :package-version '(Org . "9.6") |
| 394 | :group 'org-export-texinfo | ||
| 395 | :type 'boolean | 382 | :type 'boolean |
| 396 | :safe t) | 383 | :safe t) |
| 397 | 384 | ||
| @@ -406,7 +393,6 @@ relative file name, %F by the absolute file name, %b by the file | |||
| 406 | base name (i.e. without directory and extension parts), %o by the | 393 | base name (i.e. without directory and extension parts), %o by the |
| 407 | base directory of the file and %O by the absolute file name of | 394 | base directory of the file and %O by the absolute file name of |
| 408 | the output file." | 395 | the output file." |
| 409 | :group 'org-export-texinfo | ||
| 410 | :version "26.1" | 396 | :version "26.1" |
| 411 | :package-version '(Org . "9.1") | 397 | :package-version '(Org . "9.1") |
| 412 | :type '(repeat :tag "Shell command sequence" | 398 | :type '(repeat :tag "Shell command sequence" |
| @@ -416,8 +402,8 @@ the output file." | |||
| 416 | '("aux" "toc" "cp" "fn" "ky" "pg" "tp" "vr") | 402 | '("aux" "toc" "cp" "fn" "ky" "pg" "tp" "vr") |
| 417 | "The list of file extensions to consider as Texinfo logfiles. | 403 | "The list of file extensions to consider as Texinfo logfiles. |
| 418 | The logfiles will be remove if `org-texinfo-remove-logfiles' is | 404 | The logfiles will be remove if `org-texinfo-remove-logfiles' is |
| 405 | |||
| 419 | non-nil." | 406 | non-nil." |
| 420 | :group 'org-export-texinfo | ||
| 421 | :type '(repeat (string :tag "Extension"))) | 407 | :type '(repeat (string :tag "Extension"))) |
| 422 | 408 | ||
| 423 | (defcustom org-texinfo-remove-logfiles t | 409 | (defcustom org-texinfo-remove-logfiles t |
| @@ -815,19 +801,31 @@ holding export options." | |||
| 815 | (format "@copying\n%s@end copying\n\n" | 801 | (format "@copying\n%s@end copying\n\n" |
| 816 | (org-element-normalize-string | 802 | (org-element-normalize-string |
| 817 | (org-export-data copying info)))) | 803 | (org-export-data copying info)))) |
| 818 | ;; Info directory information. Only supply if both title and | 804 | ;; Info directory information. Only supply if category is provided. |
| 819 | ;; category are provided. | 805 | ;; FIXME: A Texinfo doc without a direntry is significantly less useful |
| 820 | (let ((dircat (plist-get info :texinfo-dircat)) | 806 | ;; since it won't appear in the main Info-directory, so maybe we should |
| 821 | (dirtitle | 807 | ;; use a default category like "misc"? |
| 822 | (let ((title (plist-get info :texinfo-dirtitle))) | 808 | (let* ((dircat (plist-get info :texinfo-dircat)) |
| 823 | (and title | 809 | (dt (plist-get info :texinfo-dirtitle)) |
| 824 | (string-match "^\\(?:\\* \\)?\\(.*?\\)\\(\\.\\)?$" title) | 810 | (file (file-name-sans-extension |
| 825 | (format "* %s." (match-string 1 title)))))) | 811 | (or (org-strip-quotes (plist-get info :texinfo-filename)) |
| 826 | (when (and dircat dirtitle) | 812 | (plist-get info :output-file)))) |
| 813 | (dirtitle | ||
| 814 | (cond | ||
| 815 | ((and dt | ||
| 816 | (or (string-match "\\`\\* \\(.*?\\)\\(\\.\\)?\\'" dt) | ||
| 817 | (string-match "\\`\\(.*(.*)\\)\\(\\.\\)?\\'" dt))) | ||
| 818 | ;; `dt' is already "complete". | ||
| 819 | (format "* %s." (match-string 1 dt))) | ||
| 820 | ((and dt (not (equal dt file))) | ||
| 821 | (format "* %s: (%s)." dt file)) | ||
| 822 | (t (format "* %s." file))))) | ||
| 823 | (when dircat | ||
| 827 | (concat "@dircategory " dircat "\n" | 824 | (concat "@dircategory " dircat "\n" |
| 828 | "@direntry\n" | 825 | "@direntry\n" |
| 829 | (let ((dirdesc | 826 | (let ((dirdesc |
| 830 | (let ((desc (plist-get info :texinfo-dirdesc))) | 827 | (let ((desc (or (plist-get info :texinfo-dirdesc) |
| 828 | title))) | ||
| 831 | (cond ((not desc) nil) | 829 | (cond ((not desc) nil) |
| 832 | ((string-suffix-p "." desc) desc) | 830 | ((string-suffix-p "." desc) desc) |
| 833 | (t (concat desc ".")))))) | 831 | (t (concat desc ".")))))) |
| @@ -1590,7 +1588,7 @@ information." | |||
| 1590 | (concat | 1588 | (concat |
| 1591 | "@noindent" | 1589 | "@noindent" |
| 1592 | (mapconcat | 1590 | (mapconcat |
| 1593 | 'identity | 1591 | #'identity |
| 1594 | (delq nil | 1592 | (delq nil |
| 1595 | (list | 1593 | (list |
| 1596 | (let ((closed (org-element-property :closed planning))) | 1594 | (let ((closed (org-element-property :closed planning))) |