From mboxrd@z Thu Jan  1 00:00:00 1970
From: "Paul Sexton" <psexton@xnet.co.nz>
Subject: More wiki-like behaviour
Date: Fri, 6 Feb 2009 08:48:02 +1300
Message-ID: <EBF4915C777B431884526B781E6C3896@quince>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="===============0844164655=="
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1LVAD5-0007Ac-Vn
	for emacs-orgmode@gnu.org; Thu, 05 Feb 2009 14:48:28 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1LVAD4-00079s-Ba
	for emacs-orgmode@gnu.org; Thu, 05 Feb 2009 14:48:27 -0500
Received: from [199.232.76.173] (port=36097 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1LVAD4-00079m-2a
	for emacs-orgmode@gnu.org; Thu, 05 Feb 2009 14:48:26 -0500
Received: from oberon.wxnz.net ([58.28.6.13]:60250)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <psexton@xnet.co.nz>) id 1LVAD2-0000qK-V1
	for emacs-orgmode@gnu.org; Thu, 05 Feb 2009 14:48:25 -0500
Received: from quince (ip-118-90-18-18.xdsl.xnet.co.nz [118.90.18.18])
	by oberon.wxnz.net (Postfix) with ESMTP id EC82A464744
	for <emacs-orgmode@gnu.org>; Fri,  6 Feb 2009 08:48:11 +1300 (NZDT)
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
To: emacs-orgmode@gnu.org

This is a multi-part message in MIME format.

--===============0844164655==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0012_01C98837.9EE9A1A0"

This is a multi-part message in MIME format.

------=_NextPart_000_0012_01C98837.9EE9A1A0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi,
I am interested in using Org mode to create a personal wiki (along the
lines of Wikidpad: http://wikidpad.sourceforge.net/ ), treating top
level headings (one star) as wiki topics.
 
To do this, I have added 2 behaviours to Org-mode.
 
1. Always narrow to subtree after following an internal link (ideally I
would like to only narrow to the relevant one-star heading).
Added to .emacs:
 
(add-hook 'org-follow-link-hook (lambda () (org-narrow-to-subtree)))

2. More difficult: create a new wikiword if the internal link is not
found.
 
In .emacs, add a new function to create the new topic:
 
(defun org-create-new-wikiword (word)
  (interactive "s")
  (widen)
  (end-of-buffer)
  (newline 2)
  (insert (format "* <<<%s>>>" word))  ; create as radio link
  (backward-char 4)
  (org-update-radio-target-regexp)
  (newline 2)
  (org-narrow-to-subtree))
 
 
 
Modification to the (VERY long) function org-open-at-point in org.el:
 
 
       ((string= type "thisfile")
         (if in-emacs
             (switch-to-buffer-other-window
               (org-get-buffer-for-internal-link (current-buffer)))
           (org-mark-ring-push))
        (let ((cmd `(org-link-search
                   ,path
                   ,(cond ((equal in-emacs '(4)) 'occur)
                           ((equal in-emacs '(16)) 'org-occur)
                           (t nil))
                   ,pos)))
           (condition-case nil (eval cmd)
             (error (progn (widen)
             ;; BEGIN CHANGE
                         (condition-case nil (eval cmd)
                           (error
                            (when (yes-or-no-p
                            (format "Topic '%s' not found; create?"
                             path))
                              (org-create-new-wikiword path)))))))))
             ;; END CHANGE
 
I am not the greatest emacs-lisp orgrammer. Is there an easier way to do
this? If not, is it possible to create a 'link-not-found' hook so that I
don't need to modify org.el?
 
Thanks
 
Paul
 
 

------=_NextPart_000_0012_01C98837.9EE9A1A0
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<TITLE>Message</TITLE>

<META content=3D"MSHTML 6.00.6001.18183" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009>Hi,</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>I am =
interested in=20
using Org mode to create a personal wiki (along the lines of Wikidpad: =
<A=20
href=3D"http://wikidpad.sourceforge.net/">http://wikidpad.sourceforge.net=
/</A>&nbsp;),=20
treating top level headings (one star) as wiki =
topics.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>To do =
this,=20
I&nbsp;have added 2&nbsp;behaviours to Org-mode.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>1. =
Always narrow to=20
subtree after following an internal link (ideally I would like to only =
narrow to=20
the relevant one-star heading).</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>Added =
to=20
.emacs:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D444443419-05022009>(add-hook=20
'org-follow-link-hook (lambda ()=20
(org-narrow-to-subtree)))<BR></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>2. =
More difficult:=20
create a new wikiword if the internal link is not =
found.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>In =
.emacs, add a new=20
function to create the new topic:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>(defun =

org-create-new-wikiword (word)<BR>&nbsp; (interactive "s")<BR>&nbsp;=20
(widen)<BR>&nbsp; (end-of-buffer)<BR>&nbsp; (newline 2)<BR>&nbsp; =
(insert=20
(format "* &lt;&lt;&lt;%s&gt;&gt;&gt;" word))&nbsp; ; create as radio=20
link<BR>&nbsp; (backward-char 4)<BR>&nbsp;=20
(org-update-radio-target-regexp)<BR>&nbsp; (newline 2)<BR>&nbsp;=20
(org-narrow-to-subtree))</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D444443419-05022009>Modification to the=20
(VERY long) function org-open-at-point in org.el:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
((string=3D type=20
"thisfile")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if =

in-emacs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;=20
(switch-to-buffer-other-window<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
(org-get-buffer-for-internal-link=20
(current-buffer)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;=20
(org-mark-ring-push))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (let =
((cmd=20
`(org-link-search<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
,path<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
,(cond ((equal in-emacs '(4))=20
'occur)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;=20
((equal in-emacs '(16))=20
'org-occur)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
(t=20
nil))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
(format "Topic '%s' not found;=20
create?"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
path))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
(org-create-new-wikiword=20
path)))))))))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;=20
;; END CHANGE<BR>&nbsp;</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D444443419-05022009>I am =
not the=20
greatest emacs-lisp orgrammer. Is there an easier way to do this? If =
not, is it=20
possible to create a 'link-not-found' hook so that I don't need to =
modify=20
org.el?</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009>Thanks</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009>Paul</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D444443419-05022009>&nbsp;</DIV></SPAN></FONT></BODY></HTML>

------=_NextPart_000_0012_01C98837.9EE9A1A0--




--===============0844164655==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

--===============0844164655==--