[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] How to change a link?
From: |
Nicolas Goaziou |
Subject: |
Re: [O] How to change a link? |
Date: |
Mon, 20 Oct 2014 15:02:41 +0200 |
Marcin Borkowski <address@hidden> 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
- Re: [O] How to change a link?, (continued)
- Re: [O] How to change a link?, Thorsten Jolitz, 2014/10/16
- Re: [O] How to change a link?, Marcin Borkowski, 2014/10/17
- Re: [O] How to change a link?, Nick Dokos, 2014/10/17
- Re: [O] How to change a link?, Thorsten Jolitz, 2014/10/18
- Re: [O] How to change a link?, Marcin Borkowski, 2014/10/17
- Re: [O] How to change a link?, Thorsten Jolitz, 2014/10/18
Re: [O] How to change a link?, Marcin Borkowski, 2014/10/19