[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: requested feature
From: |
David Maus |
Subject: |
[Orgmode] Re: requested feature |
Date: |
Mon, 15 Nov 2010 19:02:54 +0100 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/23.2 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
At Mon, 15 Nov 2010 15:01:09 +0000,
Paul Mead wrote:
>
>
> This looks pretty interesting to me, but how would you change this so
> that it used the whole heading text, not just one word?
It's basically the same, only difference is finding the headline text
and making the headline text link-safe:
(defun dmj:turn-headline-into-org-mode-link ()
"Replace word at point by an Org mode link."
(interactive)
(when (org-at-heading-p)
(let ((hl-text (nth 4 (org-heading-components))))
(unless (or (null hl-text)
(org-string-match-p "^[ \t]*:[^:]+:$" hl-text))
(beginning-of-line)
(search-forward hl-text (point-at-eol))
(replace-string
hl-text
(format "[[file:%s.org][%s]]"
(org-link-escape hl-text)
(org-link-escape hl-text '((?\] . "%5D") (?\[ . "%5B"))))
nil (- (point) (length hl-text)) (point))))))
Best,
-- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... address@hidden
Email..... address@hidden
pgp7MHNvPJ3_a.pgp
Description: PGP signature