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: Marcin Borkowski
Subject: Re: [O] How to change a link?
Date: Sat, 18 Oct 2014 03:44:37 +0200

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



reply via email to

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