Marcin Borkowski <[email protected]> writes:
> OK, it works, but: if the link description is empty, after this change
> it's still empty, so that it becomes the result of concatenation. I'd
> like the link description to stay the same, no matter whether it's empty
> or not. How do I set the /contents/ of a link object (as opposed to a
> property)?
Two examples:
1. with a full AST
(org-with-wide-buffer
(dolist (link (nreverse
(org-element-map (org-element-parse-buffer) 'link
(lambda (l)
(member (org-element-property :type l)
'("custom-id" "fuzzy"))))))
(goto-char (+ (org-element-property :begin link) 2))
(insert "file:path/to/other-file.org::")))
2. working directly on the buffer
(org-with-wide-buffer
(goto-char (point-min))
(while (re-search-forward org-bracket-link-regexp nil t)
(let ((context (org-element-context)))
(when (and (eq (org-element-type context) 'link)
(member (org-element-property :type context)
'("custom-id" "fuzzy")))
(goto-char (+ (org-element-property :begin context) 2))
(insert "file:path/to/other-file.org::")))))
Regards,
--
Nicolas Goaziou