Thanks for the pointer, p4bl0. Unfortunately, this only works on a real OS; Windows uses a completely different method. See http://kb.mozillazine.org/Register_protocol for more details.
But, of course, you provided me with the beginning I needed, so thank you so much!
Here is the solution for Windows:
First you need to configure the registry correctly to handle this new type of URL. To do this, save the following in a file, edit it according to your environment, save it and double-click on it:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\emacs] @="URL:Emacs Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\emacs\shell] [HKEY_CLASSES_ROOT\emacs\shell\open] [HKEY_CLASSES_ROOT\emacs\shell\open\command] @="\"c:\\product\\emacs\\bin\\emacsclientw.exe\" --no-wait -e \"(emacs-uri-handler \\\"%1\\\")\""
This is not as reliable as the p4bl0 shell script, because it does not guarantee that Emacs will work in the first place. Then add the following to the .emacs file:
(defun emacs-uri-handler (uri) "Handles emacs URIs in the form: emacs:///path/to/file/LINENUM" (save-match-data (if (string-match "emacs://\\(.*\\)/\\([0-9]+\\)$" uri) (let ((filename (match-string 1 uri)) (linenum (match-string 2 uri))) (with-current-buffer (find-file filename) (goto-line (string-to-number linenum)))) (beep) (message "Unable to parse the URI <%s>" uri))))
The above code will not check to make sure that the file exists, and error handling is rudimentary at best. But it works!
Then create an HTML file with the following lines:
<a href="emacs://c:/temp/my.log/60">file: c:/temp/my.log, line: 60</a>
and then click the link.
Post Script:
I recently switched to Linux (Ubuntu 9.10), and here is what I did for this OS:
$ gconftool -s /desktop/gnome/url-handlers/emacs/command '/usr/bin/emacsclient --no-wait -e "(emacs-uri-handler \"%s\")"' --type String $ gconftool -s /desktop/gnome/url-handlers/emacs/enabled --type Boolean true
Using the same emacs-uri-handler on top.