From db16370c0bc112a1193c0f49233bec999528bf2d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 4 Nov 2017 21:48:09 +0100 Subject: [PATCH] ox-texinfo: Fix @ref without description * lisp/ox-texinfo.el (org-texinfo--@ref): Prefer @ref{} with a single argument when no description is provided. --- lisp/ox-texinfo.el | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 3df4ced4b..60618c1c3 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -1035,15 +1035,17 @@ CONTENTS is nil. INFO is a plist holding contextual information." (defun org-texinfo--@ref (datum description info) "Return @ref command for element or object DATUM. -DESCRIPTION is the name of the section to print, as a string." +DESCRIPTION is the printed name of the section, as a string, or +nil." (let ((node-name (org-texinfo--get-node datum info)) ;; Sanitize DESCRIPTION for cross-reference use. In - ;; particular, remove colons as they seem to cause (even - ;; within @asis{...} to the Texinfo reader. - (title (replace-regexp-in-string - "[ \t]*:+" "" - (replace-regexp-in-string "," "@comma{}" description)))) - (if (equal title node-name) + ;; particular, remove colons as they seem to cause pain (even + ;; within @asis{...}) to the Texinfo reader. + (title (and description + (replace-regexp-in-string + "[ \t]*:+" "" + (replace-regexp-in-string "," "@comma{}" description))))) + (if (or (not title) (equal title node-name)) (format "@ref{%s}" node-name) (format "@ref{%s, , %s}" node-name title)))) @@ -1091,20 +1093,8 @@ INFO is a plist holding contextual information. See (org-element-type (org-element-property :parent destination)))))) (let ((headline (org-element-lineage destination '(headline) t))) - (org-texinfo--@ref - headline - (or desc (org-texinfo--sanitize-title - (org-element-property :title headline) info)) - info))) - (_ - (org-texinfo--@ref - destination - (or desc - (pcase (org-export-get-ordinal destination info) - ((and (pred integerp) n) (number-to-string n)) - ((and (pred consp) n) (mapconcat #'number-to-string n ".")) - (_ "???"))) ;cannot guess the description - info))))) + (org-texinfo--@ref headline desc info))) + (_ (org-texinfo--@ref destination desc info))))) ((string= type "mailto") (format "@email{%s}" (concat (org-texinfo--sanitize-content path)