emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-orgmode@gnu.org
Subject: Provide sane default for the @direntry
Date: Tue, 27 Feb 2024 19:19:38 -0500	[thread overview]
Message-ID: <jwvwmqpjvhq.fsf-monnier+emacs@gnu.org> (raw)

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

             reply	other threads:[~2024-02-28  0:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  0:19 Stefan Monnier [this message]
2024-02-28 10:35 ` Provide sane default for the @direntry 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwmqpjvhq.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).