From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Ekstrand Newsgroups: gmane.emacs.help Subject: Re: how to check if xyz-mode is on load path? Date: Mon, 02 Mar 2009 07:12:47 -0600 Organization: Aioe.org NNTP Server Message-ID: <87fxhwhxv4.fsf@jehiel.elehack.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1236001316 16881 80.91.229.12 (2 Mar 2009 13:41:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Mar 2009 13:41:56 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 02 14:43:12 2009 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.50) id 1Le8QE-0001n1-CW for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Mar 2009 14:43:06 +0100 Original-Received: from localhost ([127.0.0.1]:56322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Le8Ot-0000Cu-3u for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Mar 2009 08:41:43 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!aioe.org!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 32 Original-NNTP-Posting-Host: 3k4OpuCxx2rBT/R1RUDefw.user.aioe.org Original-X-Complaints-To: abuse@aioe.org Original-NNTP-Posting-Date: Mon, 2 Mar 2009 13:14:41 +0000 (UTC) X-Notice: Filtered by postfilter v. 0.7.7 Cancel-Lock: sha1:MxEocP5PJdULAdqVgd3FnzYjxz8= sha1:r/WJESHs4xrIMVTRtRpI8KZkJGw= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:167222 comp.emacs:97899 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:62521 Archived-At: Xah Lee writes: > how can i check if a package already exists in the load path? > > what i want to do is to put a package into autoload, but don't do that > if that package is already included in user's load path (e.g. either > the package is included in the emacs version she's got, or she already > installed it herself). > > e.g. pseudo code: > > (when > (not (isPackageInstalledQ "ocaml-mode")) > (autoload ocaml-mode "~/xahdir/ocaml-mode" ) > ) locate-library will tell you if the library is available on the load path; it will return a file name or nil. featurep (on the package's primary provided feature) or fboundp (on some relevant function's symbol) can be used to test if it has already been loaded. I would also pair the tests such that locate-library failing results in the package being added to the load path, and featurep/fboundp results in loading. The package existing in the load path does not mean it has been loaded/autoloaded, so just testing with locate-library in your code above can result in the package not being loaded. - Michael -- mouse, n: A device for pointing at the xterm in which you want to type. Confused by the strange files? I cryptographically sign my messages. For more information see .