emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to change a link?


From: Thorsten Jolitz
Subject: Re: [O] How to change a link?
Date: Wed, 15 Oct 2014 12:02:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Marcin Borkowski <address@hidden> writes:

> On 2014-10-15, at 09:16, Thorsten Jolitz wrote:
>
>> Marcin Borkowski <address@hidden> writes:
>>
>>> Hi list,
>>>
>>> assume that I have a link object (e.g., I'm in the ellipsis part of
>>> this:
>>>
>>> (org-element-map (org-element-parse-buffer 'object) 'link
>>>   (lambda (elt) ... ))
>>>
>>> What I want to do is this:
>>> 1. check whether it is an internal link, and
>>> 2. if it is, change it so that it points to the analogous place in
>>> another file.
>>>
>>> Any hints about how to do these things?
>>>
>>> (The rationale is that I'm writing a function which splits a single Org
>>> file into a bunch of smaller ones, and I want to preserve links.)
>>
>> [[http:www.orgmode.org][Org-mode]]
>>
>> #+BEGIN_SRC emacs-lisp :results raw
>> (save-excursion
>>  (re-search-backward org-link-re-with-space)
>>  (goto-char (match-beginning 0))
>>  (org-dp-contents (org-element-at-point)))
>> #+END_SRC
>>
>> #+results:
>> ((link
>>   (:type "http" :path "www.orgmode.org" :raw-link "http:www.orgmode.org"
>>   :application nil :search-option nil :begin 609 :end 643
>>   :contents-begin 633 :contents-end 641 :post-blank 0 :parent ...)))
>>
>> so these
>>
>> ,----
>> | :type "http" :path "www.orgmode.org" :raw-link "http:www.orgmode.org"
>> `----
>>
>> are your candidates for getting and setting with
>> 'org-element-property' and 'org-element-put-property'.
>
> Thanks, but...
>
> 1. I have no org-dp-contents function in my Org.  (Org-mode version
> 8.2.5f (8.2.5f-elpa @ /home/marcin/.emacs.d/elpa/org-20140116/)).

org-dp.el (and org-dp-lib.el) are libraries of mine that aim to make
local programming with org-elements (org-element-at-point) as convenient
as global programming (org-element-parse-buffer), see
https://github.com/tj64/org-dp. I find them very useful, unfortunately
they have been widely ignored so far ;)

> 2. What about internal links like
>
> [[My Target][Find my target]]
>
> (taken from the manual)?
>
> In fact, I don't care about /external/ links at all; I'm /only/
> interested in links pointing to the file they are in.

This was just an example (using local parsing for convenience), giving
the hint that you could put some links of interest in an Org file, parse
it, and look at the (link (:type ...)) alists in the parse tree to see
the properties you need to get and set. The internal link representation
is the same for all types anyway.

-- 
cheers,
Thorsten




reply via email to

[Prev in Thread] Current Thread [Next in Thread]