Entry
[planner-el.git] / planner-lisp.el
blobb6e7692acc0b1c01d41dd4cb0a3ad3581e9ffb4e
1 ;;; planner-lisp.el --- Interactive Emacs Lisp integration for Planner mode
3 ;; Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc.
5 ;; Author: Sacha Chua <sacha@free.net.ph>
6 ;; Keywords: planner, gnus
7 ;; URL: http://www.wjsullivan.net/PlannerMode.html
9 ;; This file is part of Planner. It is not part of GNU Emacs.
11 ;; Planner is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
16 ;; Planner is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with Planner; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; This file allows you to launch Emacs Lisp functions
29 ;; from a planner page.
31 ;; Example:
32 ;; [[lisp:/plan][Plan]] will be rendered as "Plan". Selecting the link
33 ;; will run the plan function interactively.
35 ;; If the link is a lisp form it is evaluated non-interactively:
36 ;; [[lisp:/(man "bash")][bash manual]] will be rendered as "bash
37 ;; manual". Selecting the link will show the bash man page in Emacs.
39 ;;; Contributors:
41 ;; Gerd Flaig fixed the docstring for `planner-lisp-browse-url'.
43 ;; Jim Ottaway made it such that if the URL like a lisp form, read and
44 ;; evaluate it, otherwise call it interactively as before.
46 ;;; Code:
48 (require 'planner)
50 ;;;###autoload
51 (defun planner-lisp-browse-url (url)
52 "If this is a LISP URL, evaluate it."
53 (when (string-match "\\`lisp:/*\\(.+\\)" url)
54 (let ((form (match-string 1 url)))
55 (if (string-match "\\`\\s-*\\((.+)\\)\\s-*\\'" form)
56 (eval (read (match-string 1 form)))
57 (eval (read (concat "(call-interactively '" form ")")))))
58 t))
60 (planner-add-protocol "lisp:/*" 'planner-lisp-browse-url nil)
62 (provide 'planner-lisp)
64 ;;; planner-lisp.el ends here