Gnus development mailing list
 help / color / mirror / Atom feed
* Acronym lookups
@ 1997-01-08 13:48 Wesley.Hardaker
  1997-01-09 11:03 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 16+ messages in thread
From: Wesley.Hardaker @ 1997-01-08 13:48 UTC (permalink / raw)



Cough cough, I uh...  got most of the stuff done on my todo list, and
therefore decided that I shouldn't be any more productive today...  I
succeeded...

I was trying to keep up with the heavy acronym usage on
alt.fan.warlord and wanted to, uh, look them up automagically.  So,
uh, I wrote probably the most shamefully stupid code of my life.  Its
enclosed below, in case anyone wants to include it in, say, a gnus
release...

Wes

;;; acronym.el --- Look up an acronym from a file database or the web.
;; Copyright (C) 1997 Free Software Foundation, Inc.

;; Author: Wes Hardaker <Wesley.Hardaker@sphys.unil.ch>
;; Keywords: fun

(require 'url)

(defvar acronym-database "~/lib/acronyms.txt"
  "Text file containing acroynms to serve as a lookup database.
The format of this file is simply an acronym on one line followed by a 
line defining it.")

(defvar acronym-sleep-for-time 2
  "Length of time to sleep when displaying an acronym in the mini-buffer.")

(defvar acronym-web-address "http://www.ucc.ie/cgi-bin/acronym?"
  "http address to query for acronyms if appended with an acronym.")

(defun acronym-lookup (&optional lets)
  "Look up an acronym from a file database or the web."
  (interactive "sAcronym: ")
  (save-excursion
    (let ((buf (current-buffer)) beg)
      (cond
       ;; check local file database first.
       ((and (file-exists-p acronym-database)
	     (bufferp (set-buffer (find-file-noselect acronym-database t)))
	     (goto-char (point-min))
	     (search-forward-regexp (concat "^" lets) nil t))
	(sit-for 1)
	(next-line 1)
	(beginning-of-line)
	(setq beg (point))
	(end-of-line)      
	(message (concat lets ": " (buffer-substring beg (point))))
	(sit-for acronym-sleep-for-time))
       ;; check web database for acronym.
       ((progn
	  (set-buffer (setq buf (generate-new-buffer " *acro-tmp*")))
	  (url-insert-file-contents 
	   (concat acronym-web-address lets))
	  (let* ((results (search-forward-regexp "<dd>" nil t))
		 (ret 
		  (if results
		      (progn
			(while results
			  (setq beg (point))
			  (end-of-line)
			  (message 
			   (concat lets ": " 
				   (buffer-substring beg (- (point) 5))))
			  (setq results (search-forward-regexp "<dd>" nil t))
			  (sit-for acronym-sleep-for-time))
			t)
		    nil)))
		 (set-buffer-modified-p nil)
		 (kill-buffer buf)
		 ret)))
	  (t (message (format "Acronym %s not found" lets)))))))

(provide 'acronym)

;;; acronym.el ends here


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~1997-01-10  9:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-08 13:48 Acronym lookups Wesley.Hardaker
1997-01-09 11:03 ` Lars Magne Ingebrigtsen
1997-01-09 11:29   ` Per Abrahamsen
1997-01-09 16:38     ` Wesley.Hardaker
1997-01-09 17:17       ` David Moore
1997-01-09 19:28       ` William M. Perry
1997-01-09 20:38         ` Steinar Bang
1997-01-09 20:49         ` Lars Magne Ingebrigtsen
1997-01-09 23:31           ` William M. Perry
1997-01-09 23:35           ` Steven L Baur
1997-01-10  0:15             ` Sudish Joseph
1997-01-10  8:03           ` Steinar Bang
1997-01-09 21:51         ` Karl Kleinpaste
1997-01-10  9:01         ` Wesley.Hardaker
1997-01-09 12:49   ` Lars Balker Rasmussen
1997-01-09 16:35   ` Wesley.Hardaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).