>>>> "Stephen" == Stephen J Turnbull
<turnbull(a)sk.tsukuba.ac.jp> writes:
Stephen> Here's a little utility to add a
list-archive.xemacs.org
Stephen> URL when you have a Message ID and want to provide a
Stephen> hyperlink.
Hi Stephen,
I have a small patch for this. The version you sent has never been run.
diff -u c:\Users\AichnerAd\el\sjt-message-id-to-url.el~
c:\Users\AichnerAd\el\sjt-message-id-to-url.el
--- c:\Users\AichnerAd\el\sjt-message-id-to-url.el~ Sun Apr 29 17:26:49 2001
+++ c:\Users\AichnerAd\el\sjt-message-id-to-url.el Sun Apr 29 17:26:49 2001
@@ -15,7 +15,7 @@
The wilma search engine at
list-archive.xemacs.org doesn't like long queries
(or maybe just long words in the queries). The default is 24, but some
-queries seem to work better with even less."
+queries seem to work better with even less.")
(defvar sjt/parse-url-regexp
"<A HREF=\"/cgi-bin/wilma_hiliter\\(/.*\\.html\\)\\?"
Stephen> I'm sure other people have written utilities like this,
Stephen> but I haven't seen any published. I finally got around
Stephen> to writing my own (I needed to learn about w3/url.el
Stephen> anyway, so it wasn't a waste of time).
The query length limitation is in glimpse, not wilma:
http://www.webglimpse.org/glimpsehelp.html#sect14
Stephen, I would like my release-mail-to-html.el to use this utility.
What do you suggest:
1. Include this in release-mail-to-html.el
2. Find a name for your utility, put it in xemacsweb and have
release-mail-to-html.el (require ...) it.
I vote for 2.
Please advise.
Best regards,
Adrian
Stephen> ; Copyright 2001 Stephen Turnbull
Stephen> ; Maintained by Code That Sucks, Ltd.
Stephen> ; Licensed under the GNU GPL. Warranty? Heaven forbid!
Stephen> ; I keep the working buffer open in a short window. Normally only
Stephen> ; about 5 lines are needed.
Stephen> (defvar sjt/working-buffer-name "sjt/temp-url"
Stephen> "Working buffer to hold fetched documents.")
Stephen> (defvar sjt/verbose t
Stephen> "Non-nil enables verbose messages.")
Stephen> (defvar sjt/truncate-id-length 24
Stephen> "Truncate query strings to this length.
Stephen> The wilma search engine at
list-archive.xemacs.org doesn't like long
queries
Stephen> (or maybe just long words in the queries). The default is 24, but some
Stephen> queries seem to work better with even less."
Stephen> (defvar sjt/parse-url-regexp
Stephen> "<A HREF=\"/cgi-bin/wilma_hiliter\\(/.*\\.html\\)\\?"
Stephen> "Regexp to parse part of the URL, expected to be in group
1.")
Stephen> (defvar sjt/parse-url-format "http://list-archive.xemacs.org%s"
Stephen> "Format string to make a valid URL from the first match group of
Stephen> `sjt/parse-url-regexp'.")
Stephen> (defun sjt/wrap-link-around-message-id (begin end)
Stephen> "Wrap an HTML HREF around a Message ID, doing a web search for the
URL.
Stephen> Leaves point at beginning and mark at end of the original text, "
Stephen> (interactive "r")
Stephen> (let ((url (buffer-substring begin end)))
Stephen> (setq end (set-marker (make-marker) end))
Stephen> (goto-char begin)
Stephen> (insert "<a href=\"")
Stephen> (insert (sjt/message-id-to-url url
Stephen> ""
Stephen> "xemacs-beta"
Stephen> "xemacs-nt"
Stephen> "xemacs-patches"))
Stephen> (insert "\">")
Stephen> (setq begin (point))
Stephen> (setq end (marker-position end)) ; freeze end
Stephen> (goto-char end)
Stephen> (insert "</a>")
Stephen> (move-marker (mark-marker t) end)
Stephen> (goto-char begin)))
Stephen> (defun sjt/message-id-to-url (id &optional auth &rest lists)
Stephen> "Return URL corresponding to message-id ID posted to LISTS.
Stephen> AUTH is an authorization in the form USER:PASSWORD. It has no default.
Stephen> LISTS defaults to (\"xemacs-beta\" \"xemacs-nt\"
\"xemacs-patches\"); each
Stephen> is tried in order and the URL corresponding to the first match is
returned."
Stephen> (interactive (let ((args (list (if (region-active-p)
Stephen> (buffer-substring (region-beginning)
Stephen> (region-end))
Stephen> (read-string "Message-ID:
"))
Stephen> (read-string "User:Password:
"))))
Stephen> (let ((l (read-string "List (null to terminate):
")))
Stephen> (while (> (length l) 0)
Stephen> (setq args (nconc args (list l)))
Stephen> (setq l (read-string "List (null to
terminate): "))))
Stephen> args))
Stephen> (setq auth (cond ((null auth) "")
Stephen> ((> (length auth) 0) (concat auth "@"))
Stephen> (t auth)))
Stephen> (setq lists (or (and lists (> (length (car lists)) 0) lists)
Stephen> '("xemacs-beta" "xemacs-nt"
"xemacs-patches")))
Stephen> (if sjt/verbose (message id))
Stephen> ;; wilma doesn't like long queries
Stephen> (let ((id (substring id 0 (min (length id) sjt/truncate-id-length)))
Stephen> url)
Stephen> (save-excursion ; url-retrieve leaves you in the buffer
Stephen> (while lists
Stephen> (let ((url-working-buffer sjt/working-buffer-name)
Stephen> (ml (car lists)))
Stephen> (url-retrieve
Stephen> (concat "http://"
Stephen> auth
Stephen> "list-archive.xemacs.org"
Stephen> "/cgi-bin/wilma_glimpse/"
Stephen> ml
Stephen> "?query="
Stephen> (url-hexify-string id)
Stephen> "&partial=on")))
Stephen> (setq url (sjt/parse-url-from-response))
Stephen> (if sjt/verbose (message url))
Stephen> (if url
Stephen> (setq lists nil)
Stephen> (setq lists (cdr lists)))))
Stephen> url))
Stephen> (defun sjt/parse-url-from-response ()
Stephen> "Parse an URL from the HTML returned by a web search on
message-id.
Stephen> Expects to be called in the HTML buffer."
Stephen> (goto-char (point-min))
Stephen> (if (let ((case-fold-search t))
Stephen> (search-forward "Message-ID" nil t))
Stephen> (let ((eol (progn (end-of-line) (point))))
Stephen> (beginning-of-line)
Stephen> (re-search-forward sjt/parse-url-regexp eol)
Stephen> (format sjt/parse-url-format
Stephen> (match-string 1)))))
Stephen> --
Stephen> University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573
JAPAN
Stephen> Institute of Policy and Planning Sciences Tel/fax: +81 (298)
53-5091
Stephen> _________________ _________________ _________________
_________________
Stephen> What are those straight lines for? "XEmacs rules."
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/