Gnus development mailing list
 help / color / mirror / Atom feed
From: Wesley.Hardaker@sphys.unil.ch
Subject: Acronym lookups
Date: 08 Jan 1997 14:48:27 +0100	[thread overview]
Message-ID: <qk220bwth04.fsf@iptsun2.unil.ch> (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


             reply	other threads:[~1997-01-08 13:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-08 13:48 Wesley.Hardaker [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=qk220bwth04.fsf@iptsun2.unil.ch \
    --to=wesley.hardaker@sphys.unil.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).