all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Provide sane default for the @direntry
@ 2024-02-28  0:19 Stefan Monnier
  2024-02-28 10:35 ` Ihor Radchenko
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2024-02-28  0:19 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org.patch --]
[-- Type: text/x-diff, Size: 1864 bytes --]

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)))

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-03-08 10:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28  0:19 Provide sane default for the @direntry Stefan Monnier
2024-02-28 10:35 ` Ihor Radchenko
2024-03-02 20:01   ` Stefan Monnier
2024-03-04 11:09     ` Ihor Radchenko
2024-03-04 16:16       ` Stefan Monnier
2024-03-05 12:49         ` Ihor Radchenko
2024-03-05 19:27           ` Stefan Monnier
2024-03-06 11:17             ` Ihor Radchenko
2024-03-06 15:00               ` Stefan Monnier
2024-03-07 13:46                 ` Ihor Radchenko
2024-03-08  8:09                   ` Stefan Monnier
2024-03-08 10:49                     ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.