From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcin Borkowski Subject: Re: How to change a link? Date: Sat, 18 Oct 2014 03:44:37 +0200 Message-ID: <87r3y6noca.fsf@wmi.amu.edu.pl> References: <87a94yjia9.fsf@wmi.amu.edu.pl> <87bnpd4ov7.fsf@nicolasgoaziou.fr> <87tx35hvh8.fsf@wmi.amu.edu.pl> <87y4sh2e7c.fsf@nicolasgoaziou.fr> <87mw8vj3vs.fsf@wmi.amu.edu.pl> <87d29ru07w.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfJ4d-0000iE-71 for emacs-orgmode@gnu.org; Fri, 17 Oct 2014 21:44:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XfJ4Z-0004bs-6S for emacs-orgmode@gnu.org; Fri, 17 Oct 2014 21:44:51 -0400 Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:32881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfJ4Y-0004bn-VG for emacs-orgmode@gnu.org; Fri, 17 Oct 2014 21:44:47 -0400 Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 16DAB4144F for ; Sat, 18 Oct 2014 03:44:45 +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 gVCVXU7OpqgX for ; Sat, 18 Oct 2014 03:44:44 +0200 (CEST) Received: from localhost (99-229.echostar.pl [213.156.99.229]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id 8E95E4144E for ; Sat, 18 Oct 2014 03:44:44 +0200 (CEST) In-reply-to: <87d29ru07w.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-17, at 00:19, Thorsten Jolitz wrote: > However, here is a org-dp solution, use 't' instead of 'prepend to > replace the links, and whatever you want instead of "file+emacs" as > replacement. Of course one could easily re-search and replace "[[file:" > in this simple case, but this uses the parser and allows doing more > complex stuff in a clean way too: > > ,---- > | * ORG SCRATCH > | > | ** Level 2 > | > | [[file+emacs:~/junk/org/minimal.org][min.org]] > | > | [[file:~/junk/org/minimal.org][min.org]] > | > | *** Level 3 > | > | [[file+emacs:~/junk/org/trash-me.org][trash.org]] > | > | [[file:~/junk/org/trash-me.org][trash.org]] > | > | > | #+BEGIN_SRC emacs-lisp :results none > | (require 'org-dp) > | (org-dp-map > | '(org-dp-rewire > | 'paragraph > | (lambda (cont elem) > | (let* ((link (car cont)) > | (raw-val (org-element-property :raw-link link)) > | (new-val (mapconcat 'identity > | (cons "file+emacs" > | (cdr > | (split-string > | raw-val ":" t))) > | ":"))) > | (org-element-put-property link :raw-link new-val))) > | 'prepend) > | org-link-re-with-space t) > | #+END_SRC > `---- Hi Thorsten, one thing I don't quite understand yet: why is the first argument to org-dp-rewire `'paragraph'? My intuition says it should rather be 'link, though this doesn't seem to work. How come that you say 'paragraph, but the lambda in the second parameter gets the link data in `cont'? (This might be a stupid question, but I really want to grok this.) Second question: do I get it correctly that `org-element-put-property' returns the "new" version of the element (link, in this case), with everything as it was but the :raw-link property changed? TIA, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University