emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Rudolf Adamkovič" <rudolf@adamkovic.org>
To: emacs-orgmode@gnu.org
Cc: "Rudolf Adamkovič" <rudolf@adamkovic.org>
Subject: [PATCH] ox-texinfo: Fix automatic @ref titles
Date: Thu, 12 Sep 2024 00:19:55 +0200	[thread overview]
Message-ID: <20240911221955.88397-1-rudolf@adamkovic.org> (raw)

* lisp/ox-texinfo.el (org-texinfo--@ref): Fix an incorrect assumption
that Texinfo uses node names for automatic link text.  It does not.
Instead, it uses the corresponding section title.  For example, if a
node is named `a' its section is named `A', the Org link to the node
`a' written as `[[...][xxx]]' ends up being rendered as "A", which
means the link description the Org user provided is ignored.
---
 lisp/ox-texinfo.el              |  2 +-
 testing/lisp/test-ox-texinfo.el | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 6adee9fca..2da90ca0f 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -1311,7 +1311,7 @@ nil."
 		    (replace-regexp-in-string
 		     "[ \t]*:+" ""
 		     (replace-regexp-in-string "," "@comma{}" description)))))
-    (if (or (not title) (equal title node-name))
+    (if (not title)
 	(format "@ref{%s}" node-name)
       (format "@ref{%s, , %s}" node-name title))))
 
diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el
index b16a344e7..d4552459d 100644
--- a/testing/lisp/test-ox-texinfo.el
+++ b/testing/lisp/test-ox-texinfo.el
@@ -345,5 +345,34 @@ body
        (should-not (org-element-contents section))
        (should (eq first-heading (org-element-parent section)))))))
 
+\f
+;;; References
+
+(ert-deftest test-ox-texinfo/references ()
+  "Test references with manual and automatic descriptions."
+  (should
+   (org-test-with-temp-text
+       (string-join
+        (list "* A"
+              ":PROPERTIES:"
+              ":ALT_TITLE: B"
+              ":END:"
+              "[[A]]"
+              "[[A][B]]"
+              "[[A][C]]"
+              "  ....")
+        "\n")
+     (let ((export-buffer "*Test Texinfo Export*")
+           (org-export-show-temporary-export-buffer nil))
+       (org-export-to-buffer 'texinfo export-buffer
+         nil nil nil nil nil
+         #'texinfo-mode)
+       (with-current-buffer export-buffer
+         (goto-char (point-min))
+         (and
+          (re-search-forward "@ref{B}")
+          (re-search-forward "@ref{B, , B}")
+          (re-search-forward "@ref{B, , C}")))))))
+
 (provide 'test-ox-texinfo)
 ;;; test-ox-texinfo.el end here
-- 
2.46.0



             reply	other threads:[~2024-09-11 22:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11 22:19 Rudolf Adamkovič [this message]
2024-09-15 12:12 ` [PATCH] ox-texinfo: Fix automatic @ref titles 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=20240911221955.88397-1-rudolf@adamkovic.org \
    --to=rudolf@adamkovic.org \
    --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).