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 23:30:11 +0200 Message-ID: <87tx35hvh8.fsf@wmi.amu.edu.pl> References: <87a94yjia9.fsf@wmi.amu.edu.pl> <87bnpd4ov7.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeW9N-0003Bf-Hm for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 17:30:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeW9H-0004N7-Pm for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 17:30:29 -0400 Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:42479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeW9H-0004Mv-He for emacs-orgmode@gnu.org; Wed, 15 Oct 2014 17:30:23 -0400 Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 54D3B5B878 for ; Wed, 15 Oct 2014 23:30:21 +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 PM0etRKnjNRn for ; Wed, 15 Oct 2014 23:30:21 +0200 (CEST) Received: from localhost (99-229.echostar.pl [213.156.99.229]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id EE95E5B874 for ; Wed, 15 Oct 2014 23:30:20 +0200 (CEST) In-reply-to: <87bnpd4ov7.fsf@nicolasgoaziou.fr> 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: org-mode List On 2014-10-15, at 12:19, Nicolas Goaziou wrote: > Hello, > > Marcin Borkowski writes: > >> 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 > > (member (org-element-property :type elt) '("custom-id" "fuzzy")) > >> 2. if it is, change it so that it points to the analogous place in >> another file. > > (org-element-put-property elt :raw-link > (concat "file:path/to/other-file.org::" > (org-element-property :path elt))) Thanks a lot, that was helpful! I'm starting to feel more and more confident with org-element-whatever, that's good. I have one more question. What I'm about to do is (basically) put "file:some-file-name::" in front of the link, without changing the description. I could use `org-element-put-property' and (AFAIU) org-element-link-interpreter to put it into the buffer (and probably delete the old one). It would be much easier (and maybe faster) just to go to the point in the buffer where the link starts, go `(forward-char 2)' (past the brackets) and `(insert (concat "file" name "::"))'. But, is it safe? Wouldn't it break something? And is it considered a good practice? Regards, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University