From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Paul Sexton" Subject: More wiki-like behaviour Date: Fri, 6 Feb 2009 08:48:02 +1300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0844164655==" Return-path: 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 ) 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 ; Fri, 6 Feb 2009 08:48:11 +1300 (NZDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Message
Hi,
I am = interested in=20 using Org mode to create a personal wiki (along the lines of Wikidpad: = http://wikidpad.sourceforge.net= / ),=20 treating top level headings (one star) as wiki = topics.
 
To do = this,=20 I have added 2 behaviours to Org-mode.
 
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).
Added = to=20 .emacs:
 
(add-hook=20 'org-follow-link-hook (lambda ()=20 (org-narrow-to-subtree)))
2. = More difficult:=20 create a new wikiword if the internal link is not = found.
 
In = .emacs, add a new=20 function to create the new topic:
 
(defun = org-create-new-wikiword (word)
  (interactive "s")
 =20 (widen)
  (end-of-buffer)
  (newline 2)
  = (insert=20 (format "* <<<%s>>>" word))  ; create as radio=20 link
  (backward-char 4)
 =20 (org-update-radio-target-regexp)
  (newline 2)
 =20 (org-narrow-to-subtree))
 
 
 
Modification to the=20 (VERY long) function org-open-at-point in org.el:
 
 
       = ((string=3D type=20 "thisfile")
         (if = in-emacs
        =     =20 (switch-to-buffer-other-window
     =20         =20 (org-get-buffer-for-internal-link=20 (current-buffer)))
        =   =20 (org-mark-ring-push))
        (let = ((cmd=20 `(org-link-search
        &nbs= p;         =20 ,path
          &nbs= p;       =20 ,(cond ((equal in-emacs '(4))=20 'occur)
          &n= bsp;           &nb= sp;   =20 ((equal in-emacs '(16))=20 'org-occur)
         &nbs= p;            = ;    =20 (t=20 nil))
          &nbs= p;       =20 ,pos)))
          =20 (condition-case nil (eval=20 cmd)
           = ; =20 (error (progn=20 (widen)
          &n= bsp; =20 ;; BEGIN=20 CHANGE
          &nb= sp;           &nbs= p; =20 (condition-case nil (eval=20 cmd)
           = ;            =    =20 (error
          &nb= sp;           &nbs= p;    =20 (when=20 (yes-or-no-p
         &nb= sp;           &nbs= p;     =20 (format "Topic '%s' not found;=20 create?"
          &= nbsp;           &n= bsp;     =20 path))
          &nb= sp;           &nbs= p;      =20 (org-create-new-wikiword=20 path)))))))))
         &n= bsp;  =20 ;; END CHANGE
 
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?
 
Thanks
 
Paul
 
 
------=_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==--