0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:36:26 +00:00

Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2017-06-06 02:20:51 +02:00
commit 53011308a5

View file

@ -448,21 +448,25 @@ INFO is a plist used as a communication channel. See
;; Else use format string. ;; Else use format string.
(fmt (format fmt text)))) (fmt (format fmt text))))
(defun org-texinfo--get-node (blob info) (defun org-texinfo--get-node (datum info)
"Return node or anchor associated to BLOB. "Return node or anchor associated to DATUM.
BLOB is an element or object. INFO is a plist used as DATUM is an element or object. INFO is a plist used as
a communication channel. The function guarantees the node or a communication channel. The function guarantees the node or
anchor name is unique." anchor name is unique."
(let ((cache (plist-get info :texinfo-node-cache))) (let ((cache (plist-get info :texinfo-node-cache)))
(or (cdr (assq blob cache)) (or (cdr (assq datum cache))
(let ((name (let* ((salt 0)
(org-texinfo--sanitize-node (basename
(if (eq (org-element-type blob) 'headline) (org-texinfo--sanitize-node
(org-export-data (org-export-get-alt-title blob info) info) (if (eq (org-element-type datum) 'headline)
(org-export-get-reference blob info))))) (org-export-data (org-export-get-alt-title datum info)
;; Ensure NAME is unique. info)
(while (rassoc name cache) (setq name (concat name "x"))) (org-export-get-reference datum info))))
(plist-put info :texinfo-node-cache (cons (cons blob name) cache)) (name basename))
;; Ensure NAME is unique and not reserved node name "Top".
(while (or (equal name "Top") (rassoc name cache))
(setq name (concat basename (number-to-string (cl-incf salt)))))
(plist-put info :texinfo-node-cache (cons (cons datum name) cache))
name)))) name))))
(defun org-texinfo--sanitize-node (title) (defun org-texinfo--sanitize-node (title)
@ -935,9 +939,17 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;;; Link ;;;; Link
(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."
(let ((node-name (org-texinfo--get-node datum info))
(title (org-texinfo--sanitize-node description)))
(if (equal title node-name)
(format "@ref{%s}" node-name)
(format "@ref{%s, , %s}" node-name title))))
(defun org-texinfo-link (link desc info) (defun org-texinfo-link (link desc info)
"Transcode a LINK object from Org to Texinfo. "Transcode a LINK object from Org to Texinfo.
DESC is the description part of the link, or the empty string. DESC is the description part of the link, or the empty string.
INFO is a plist holding contextual information. See INFO is a plist holding contextual information. See
`org-export-data'." `org-export-data'."
@ -957,9 +969,7 @@ INFO is a plist holding contextual information. See
((equal type "radio") ((equal type "radio")
(let ((destination (org-export-resolve-radio-link link info))) (let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) desc (if (not destination) desc
(format "@ref{%s,,%s}" (org-texinfo--@ref destination desc info))))
(org-texinfo--get-node destination info)
desc))))
((member type '("custom-id" "id" "fuzzy")) ((member type '("custom-id" "id" "fuzzy"))
(let ((destination (let ((destination
(if (equal type "fuzzy") (if (equal type "fuzzy")
@ -974,38 +984,27 @@ INFO is a plist holding contextual information. See
(if desc (format "@uref{file://%s,%s}" destination desc) (if desc (format "@uref{file://%s,%s}" destination desc)
(format "@uref{file://%s}" destination))) (format "@uref{file://%s}" destination)))
(`headline (`headline
(let ((node-name (org-texinfo--get-node destination info))) (org-texinfo--@ref
(if desc destination
(format "@ref{%s, , %s}" (or desc
node-name (org-export-data
(org-texinfo--sanitize-node desc)) (org-element-property :title destination) info))
(format "@ref{%s}" node-name)))) info))
(_ (_
(format "@ref{%s,,%s}" (org-texinfo--@ref
(org-texinfo--get-node destination info) destination
(cond (or desc
(desc) (pcase (org-export-get-ordinal destination info)
;; No description is provided: first try to ((and (pred integerp) n) (number-to-string n))
;; associate destination to a number. ((and (pred consp) n) (mapconcat #'number-to-string n "."))
((let ((n (org-export-get-ordinal destination info))) (_ "???"))) ;cannot guess the description
(cond ((not n) nil) info)))))
((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")))))))
((string= type "mailto") ((string= type "mailto")
(format "@email{%s}" (format "@email{%s}"
(concat (org-texinfo--sanitize-content path) (concat (org-texinfo--sanitize-content path)
(and desc (concat "," desc))))) (and desc (concat ", " desc)))))
;; External link with a description part. ;; External link with a description part.
((and path desc) (format "@uref{%s,%s}" path desc)) ((and path desc) (format "@uref{%s, %s}" path desc))
;; External link without a description part. ;; External link without a description part.
(path (format "@uref{%s}" path)) (path (format "@uref{%s}" path))
;; No path, only description. Try to do something useful. ;; No path, only description. Try to do something useful.
@ -1265,7 +1264,7 @@ holding contextual information."
TEXT is the text of the target. INFO is a plist holding TEXT is the text of the target. INFO is a plist holding
contextual information." contextual information."
(format "@anchor{%s}%s" (format "@anchor{%s}%s"
(org-export-get-reference radio-target info) (org-texinfo--get-node radio-target info)
text)) text))
;;;; Section ;;;; Section
@ -1313,7 +1312,7 @@ contextual information."
(org-texinfo--wrap-float value (org-texinfo--wrap-float value
info info
(org-export-translate "Listing" :utf-8 info) (org-export-translate "Listing" :utf-8 info)
(org-export-get-reference src-block info) (org-texinfo--get-node src-block info)
caption caption
shortcaption)))) shortcaption))))
@ -1372,7 +1371,7 @@ contextual information."
(org-texinfo--wrap-float table-str (org-texinfo--wrap-float table-str
info info
(org-export-translate "Table" :utf-8 info) (org-export-translate "Table" :utf-8 info)
(org-export-get-reference table info) (org-texinfo--get-node table info)
caption caption
shortcaption))))) shortcaption)))))
@ -1440,7 +1439,7 @@ a communication channel."
"Transcode a TARGET object from Org to Texinfo. "Transcode a TARGET object from Org to Texinfo.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(format "@anchor{%s}" (org-export-get-reference target info))) (format "@anchor{%s}" (org-texinfo--get-node target info)))
;;;; Timestamp ;;;; Timestamp