From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harry Putnam Newsgroups: gmane.emacs.help Subject: Re: test for presence of library Date: Fri, 19 Feb 2010 16:19:36 -0600 Organization: Still searching... Message-ID: <873a0wq35z.fsf@newsguy.com> References: <87mxz6116b.fsf@galatea.lan.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1266618038 10311 80.91.229.12 (19 Feb 2010 22:20:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Feb 2010 22:20:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 19 23:20:31 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NibD4-0001tj-G6 for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Feb 2010 23:20:30 +0100 Original-Received: from localhost ([127.0.0.1]:58307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NibD3-0002s5-T4 for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Feb 2010 17:20:29 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NibCh-0002s0-Q7 for help-gnu-emacs@gnu.org; Fri, 19 Feb 2010 17:20:07 -0500 Original-Received: from [140.186.70.92] (port=33685 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NibCg-0002rs-T1 for help-gnu-emacs@gnu.org; Fri, 19 Feb 2010 17:20:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NibCf-00025a-P6 for help-gnu-emacs@gnu.org; Fri, 19 Feb 2010 17:20:06 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:58369) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NibCf-00025R-Eq for help-gnu-emacs@gnu.org; Fri, 19 Feb 2010 17:20:05 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NibCb-0001US-0I for help-gnu-emacs@gnu.org; Fri, 19 Feb 2010 23:20:01 +0100 Original-Received: from c-98-215-178-110.hsd1.in.comcast.net ([98.215.178.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Feb 2010 23:20:00 +0100 Original-Received: from reader by c-98-215-178-110.hsd1.in.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Feb 2010 23:20:00 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 81 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-98-215-178-110.hsd1.in.comcast.net User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:BOYNyXKb8mzDgwRqtoudtjQxHNw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71964 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) writes: [...] Harry wrote: >> The lisp equivalent of: >> >> if some-lib >> then >> (require some-lib) >> fi > > > require does the test itself! > > C-h f require RET > > > Now, assume that we wrote: > > (when (library-exists-p 'some-lib) > (require 'some-lib)) > > and that just after your emacs executed (library-exists-p 'some-lib) > and returned true, some other process would delete that some-lib.el > file. What would happen to your (require 'some-lib)? > > > That is, basically, your above shell script with if [ -f /my/file ] is > just WRONG! If you see such tests in scripts, you are allowed to think > poorly of their authors. Don't hold back, in this case you are allowed and really forced to think poorly of the author who admits to having literally hundreds of such tests scattered thru a 10yr accumulation of various scripts in various scripting languages. I'm a known dimwit... its even ok to use the `R' word... I doubt (Sarah Palin reads this group) It's ok, I've learned to live with it. Now lets assume further that we instead say simply: (require 'some-lib) After patting myself on the back for such a wise solution to getting a needed library loaded, I move to a different and new machine where I've carted my every ready .emacs file with me. I start emacs with `emacs /some/path/file'.... but whoops, since `some-lib' is not in the path in this environment... my emacs blows up a bit. It throws up a confusing buffer full of various leads to information, but none of it appears to bear directly on the job at hand. .. Not even any indication of what the problem is. I finally noticed at the bottom, a place to dismiss this interruption and get back to work. I'd like to avoid that even though its not really an earth shaking problem. My first thought, being a dunce and all, was to test for the presence of the library before requiring it, thereby smoothing out the work flow and interruptions. I wasn't sure how that would be done, hence the question here. But looking at the suggested documentation I'm left non the wiser: (require FEATURE &optional FILENAME NOERROR) That isn't going to get it for me.. I've tried a few arrangements but being an idiot and all, I have no idea how something optional is introduced into the require. What do you recommend to a simpleton regarding how to avoid the interruption? Just make sure all is perfect before starting emacs? Or maybe spend a day or two figuring out how to apply the codified documentation.... again... thats' a hard pull for the intellectually crippled.