From 5e63d35acecb1fd85da84447c670fc2f29bc55c3 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 30 May 2015 13:52:26 +0200 Subject: [PATCH] ox-texinfo: Change output for links to targets with no description * lisp/ox-texinfo.el (org-texinfo-link): Change output for links to targets with no description. See . --- lisp/ox-texinfo.el | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 259cc6146..d7a48b756 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -996,22 +996,25 @@ INFO is a plist holding contextual information. See (t (org-export-data (org-element-property :title destination) info))))) (otherwise - (let ((topic - (or desc - (if (and (eq (org-element-type destination) 'headline) - (not (org-export-numbered-headline-p - destination info))) - (org-export-data - (org-element-property :title destination) info)) - (let ((n (org-export-get-ordinal destination info))) - (cond - ((not n) nil) - ((integerp n) n) - (t (mapconcat #'number-to-string n "."))))))) - (when topic - (format "@ref{%s,,%s}" - (org-texinfo--get-node destination info) - topic))))))) + (format "@ref{%s,,%s}" + (org-texinfo--get-node destination info) + (cond + (desc) + ;; No description is provided: first try to + ;; associate destination to a number. + ((let ((n (org-export-get-ordinal destination info))) + (cond ((not n) nil) + ((integerp n) n) + (t (mapconcat #'number-to-string n "."))))) + ;; Then grab title of headline containing + ;; DESTINATION. + ((let ((h (org-element-lineage destination '(headline) t))) + (and h + (org-export-data + (org-element-property :title destination) info)))) + ;; Eventually, just return "Top" to refer to the + ;; beginning of the info file. + (t "Top"))))))) ((equal type "info") (let* ((info-path (split-string path "[:#]")) (info-manual (car info-path))