emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] Adding a new url type to planner mode


From: Brad Collins
Subject: [emacs-wiki-discuss] Adding a new url type to planner mode
Date: Thu, 27 May 2004 10:40:59 +0700
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (windows-nt)

I'm writing a planner url resolver which based on planner-bbdb.

The idea is to take a BXID which is a unique id which looks like
`GCH5-7062' and then look up the file associated with it.  BXID's are
always located in a directory based on the id located in a root
directory called a bramble.

So the id `KQU5-2104' would have the following path,

<path-to-bramble-root>/K/Q/U/5/2/1/0/4/KQU5-2104.yml

Because a large part of my work involved creating and editing Yaml
records based on BXIDs, I wanted to be able to include something like
the following in plans:

[[bxid://KQU5-2104][Hanno]], Pope Leo X's White Elephant 1509--1516

When you hit return, the path should be resolved and the default yaml
file opened in another window which is then switched into yaml-mode
for editing the record.

I have hacked together something that works, but I get the following
message:

  browse-url-default-windows-browser: ShellExecute failed: Access is
  denied.

Here is the code for planner-bxid.el.  Please be nice, I'm not much of
a programmer, and it's amazing this mess works at all:

(require 'planner)
(defvar bxpath "d:/bram/") ;; set local bramble root
(defvar bxext ".yml") ;; the default should be a yaml encoded burr

(add-to-list 'planner-resolve-url-table '("bxid:" . planner-bxid-find))
(planner-option-customized 'planner-url-list
                           (append (list "bxid://") planner-url-list))
(add-hook 'planner-browse-url-functions 'planner-bxid-find)

;; this is ugly but for the moment it works -- will eventually rewrite to
;; something less embarrasing..

(defun planner-bxid-thing ()
  "Print out path name for BXID"
  (setq bxx (replace-regexp-in-string "bxid://" "" bxid))
  (setq bx (replace-regexp-in-string "-" ""  bxx))
  (setq brampath (replace-regexp-in-string "\\([A-Z0-9]\\)" "\\1/" bx)))

(defun planner-bxid-find (bxid)
  "Pull out the scope note from a burr and dump into 
   other window"

(when (string-match "^bxid://\\(.+\\)" url)
  (find-file-other-window (concat bxpath (planner-bxid-thing) bxx bxext) nil)
  (yaml-mode)))

(provide 'planner-bxid)

Does anyone have any idea why I'm getting the error and how to get
rid of it?  Obviously browse-url-default-windows-browser is calling
browse-url and fails.  But I'm not sure how or why planner-bbdb calls
the same function and doesn't return an error...

As I said, the hack works, except for the error, but it would be nice
to know what I'm doing wrong.

Any ideas?

Cheers,

b/

--
Brad Collins
Chenla Labs
Bangkok, Thailand





reply via email to

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