From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcin Borkowski Subject: Re: How to change a link? Date: Wed, 15 Oct 2014 11:50:58 +0200 Message-ID: <878ukhk6f1.fsf@wmi.amu.edu.pl> References: <87a94yjia9.fsf@wmi.amu.edu.pl> <87zjcxzttn.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeLEq-00066d-6Q for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 05:51:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeLEl-0007Wk-CH for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 05:51:24 -0400 Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:50274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeLEl-0007WL-5k for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 05:51:19 -0400 Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 640BF5B870 for ; Wed, 15 Oct 2014 11:51:17 +0200 (CEST) Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ewSZ+074CZYt for ; Wed, 15 Oct 2014 11:51:17 +0200 (CEST) Received: from localhost (99-229.echostar.pl [213.156.99.229]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id EF21A400BC for ; Wed, 15 Oct 2014 11:51:16 +0200 (CEST) In-reply-to: <87zjcxzttn.fsf@gmail.com> 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 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/)). 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. Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University