From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: How to change a link? Date: Wed, 15 Oct 2014 12:02:35 +0200 Message-ID: <87iojlzm4k.fsf@gmail.com> References: <87a94yjia9.fsf@wmi.amu.edu.pl> <87zjcxzttn.fsf@gmail.com> <878ukhk6f1.fsf@wmi.amu.edu.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeLPz-00053n-9b for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 06:03:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeLPt-0003q6-RN for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 06:02:54 -0400 Received: from plane.gmane.org ([80.91.229.3]:42926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeLPt-0003np-9U for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 06:02:49 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XeLPp-0005uK-5m for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 12:02:45 +0200 Received: from g231111120.adsl.alicedsl.de ([92.231.111.120]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Oct 2014 12:02:45 +0200 Received: from tjolitz by g231111120.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Oct 2014 12:02:45 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Marcin Borkowski writes: > On 2014-10-15, at 09:16, Thorsten Jolitz wrote: > >> Marcin Borkowski 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