From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: taashlo@sandia.gov Newsgroups: gmane.emacs.help Subject: Re: Elisp: Search a File Without Visiting? Date: 17 Jun 2003 11:04:24 -0600 Organization: Sandia National Laboratories, Albuquerque, NM USA Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <5l4r2pde2e.fsf@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1055870384 21245 80.91.224.249 (17 Jun 2003 17:19:44 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 17 Jun 2003 17:19:44 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 17 19:19:43 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19SK5T-0005JH-00 for ; Tue, 17 Jun 2003 19:17:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19SK3U-0006QN-Gz for gnu-help-gnu-emacs@m.gmane.org; Tue, 17 Jun 2003 13:15:36 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!news.sandia.gov!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 52 Original-NNTP-Posting-Host: sadl10553.sandia.gov Original-X-Trace: sass2141.sandia.gov 1055869449 15038 134.253.225.126 (17 Jun 2003 17:04:09 GMT) Original-X-Complaints-To: usenet@sass2141.sandia.gov Original-NNTP-Posting-Date: Tue, 17 Jun 2003 17:04:09 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-Xref: shelby.stanford.edu gnu.emacs.help:114521 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:11013 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11013 "Stefan Monnier" writes: > > My question: is it possible (using elisp) to search the contents of > > the thesaurus file *without* loading it into a buffer? > > Nope. How would it work ? > I guess what you're thinking about is not "without loading it" but > "without loading it all at once". In which case, yes, you can use > the BEG and END args of insert-file-contents to load only a part > of the file, so you can search the file 1MB at a time (for instance). > > But maybe you'll be better off using something like grep on > your thesaurus and then fetching the relevant part. > > Stefan Yeah, Kai Großjohann posted a similar response. I was too focused on my original solution to see the right way of getting this problem solved. Anyway, I've got the code working as I like: 1) It can pickup the word or phrase to search for from the cursor or the mark. 2) It can prompt you to input the word or phrase to search for. 3) It keeps a history of what you searched for. 4) It will preferentially find the word/phrase in the root position. 5) If not found as a root, it will seach for the word/phrase in the list of synonyms and related words. 6) With the results of a previous thesaurus search, you can perform a subsequent thesaurus search, a dictionary lookup (see dictionary-1.8.4.tar.gz), copy, cut & paste, etc. There's just one minor little nit that is bugging me. After formatting the "*Thesaurus Search Results*" buffer, I call forward-line to position the cursor on a blank line. This works fine if the "Results" window is buried or non-existant, but if it is still visible from a previous search, the cursor is always ends up located at the beginning of the buffer after the call to display-buffer. If you would like, I will post the code (to gnu.emacs.sources), or I can try to make a small example that demonstrates the problem. (I'm using Gnu Emacs 21.3.1 on Windows NT 4.0 SP 6.) But before I do that, I want to check that this isn't a known problem. Thanks, Tad Ashlock