[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Provide sane default for the @direntry
From: |
Stefan Monnier |
Subject: |
Provide sane default for the @direntry |
Date: |
Tue, 27 Feb 2024 19:19:38 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
When exporting to Texinfo, the patch below makes it easier to generate
a good `@direntry` by using sane defaults.
For most files, you'll just need
#+TEXINFO_DIR_CATEGORY: {my-category}
I believe it also makes it a bit harder to shoot oneself in the foot and
generate an invalid entry (e.g. with a missing or wrong file name).
Stefan
diff --git a/lisp/org/ox-texinfo.el b/lisp/org/ox-texinfo.el
index 84313645e6e..beea7aacab7 100644
--- a/lisp/org/ox-texinfo.el
+++ b/lisp/org/ox-texinfo.el
@@ -817,17 +799,27 @@ org-texinfo-template
(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)
+ (let* ((dircat (plist-get info :texinfo-dircat))
+ (dt (plist-get info :texinfo-dirtitle))
+ (file (file-name-sans-extension
+ (or (org-strip-quotes (plist-get info :texinfo-filename))
+ (plist-get info :output-file))))
+ (dirtitle
+ (cond
+ ((and dt
+ (or (string-match "\\`\\* \\(.*?\\)\\(\\.\\)?\\'" dt)
+ (string-match "\\`\\(.*(.*)\\)\\(\\.\\)?\\'" dt)))
+ ;; `dt' is already "complete".
+ (format "* %s." (match-string 1 dt)))
+ ((and dt (not (equal dt file)))
+ (format "* %s: (%s)." dt file))
+ (t (format "* %s." file)))))
+ (when dircat
(concat "@dircategory " dircat "\n"
"@direntry\n"
(let ((dirdesc
- (let ((desc (plist-get info :texinfo-dirdesc)))
+ (let ((desc (or (plist-get info :texinfo-dirdesc)
+ title)))
(cond ((not desc) nil)
((string-suffix-p "." desc) desc)
(t (concat desc "."))))))
@@ -1590,7 +1582,7 @@ org-texinfo-planning
(concat
"@noindent"
(mapconcat
- 'identity
+ #'identity
(delq nil
(list
(let ((closed (org-element-property :closed planning)))
- Provide sane default for the @direntry,
Stefan Monnier <=