From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/9301 Path: main.gmane.org!not-for-mail From: Wesley.Hardaker@sphys.unil.ch Newsgroups: gmane.emacs.gnus.general Subject: Acronym lookups Date: 08 Jan 1997 14:48:27 +0100 Organization: Universite de Lausanne, BSP Sender: whardake@iptsun2.unil.ch Message-ID: NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035149346 17616 80.91.224.250 (20 Oct 2002 21:29:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 21:29:06 +0000 (UTC) Return-Path: Original-Received: from ifi.uio.no (0@ifi.uio.no [129.240.64.2]) by deanna.miranova.com (8.8.4/8.8.4) with SMTP id GAA02667 for ; Wed, 8 Jan 1997 06:22:06 -0800 Original-Received: from unilmta3.unil.ch (cisun29a.unil.ch [130.223.27.29]) by ifi.uio.no with SMTP (8.6.11/ifi2.4) id for ; Wed, 8 Jan 1997 14:50:22 +0100 Original-Received: from iptsun2.unil.ch by unilmta3.unil.ch with SMTP inbound; Wed, 8 Jan 1997 14:50:05 +0100 Original-Received: by iptsun2.unil.ch (5.x/Unil-3.1/) id AA05755; Wed, 8 Jan 1997 14:48:29 +0100 Original-To: ding@ifi.uio.no X-Face: #qW^}a%m*T^{A:Cp}$R\"38+d}41-Z}uU8,r%F#c#s:~Nzp0G9](s?,K49KJ]s"*7gvRgA SrAvQc4@/}L7Qc=w{)]ACO\R{LF@S{pXfojjjGg6c;q6{~C}CxC^^&~(F]`1W)%9j/iS/ IM",B1M.?{w8ckLTYD'`|kTr\i\cgY)P4 X-Url: http://www.ece.ucdavis.edu/~hardaker Original-Lines: 77 X-Mailer: Red Gnus v0.79/XEmacs 19.14 Xref: main.gmane.org gmane.emacs.gnus.general:9301 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:9301 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 ;; 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 "
" 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 "
" 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