From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: M Jared Finder Newsgroups: gmane.emacs.devel Subject: Re: relative load-file Date: Sun, 15 Nov 2009 13:59:10 -0800 Message-ID: References: <6cd6de210911110901v24307163i253e69e89c72c9e@mail.gmail.com> <6cd6de210911140744t75b84417udfa6921cc8fe424f@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1258322398 18066 80.91.229.12 (15 Nov 2009 21:59:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Nov 2009 21:59:58 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 15 22:59:51 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N9n8O-00085d-4X for ged-emacs-devel@m.gmane.org; Sun, 15 Nov 2009 22:59:48 +0100 Original-Received: from localhost ([127.0.0.1]:33583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N9n8N-0000Up-H9 for ged-emacs-devel@m.gmane.org; Sun, 15 Nov 2009 16:59:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N9n8I-0000US-Fx for emacs-devel@gnu.org; Sun, 15 Nov 2009 16:59:42 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N9n8D-0000Tf-Rp for emacs-devel@gnu.org; Sun, 15 Nov 2009 16:59:41 -0500 Original-Received: from [199.232.76.173] (port=52178 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N9n8D-0000Tc-Mf for emacs-devel@gnu.org; Sun, 15 Nov 2009 16:59:37 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:35299) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N9n8C-0002u9-F9 for emacs-devel@gnu.org; Sun, 15 Nov 2009 16:59:36 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1N9n8A-00080b-91 for emacs-devel@gnu.org; Sun, 15 Nov 2009 22:59:34 +0100 Original-Received: from c-98-248-42-158.hsd1.ca.comcast.net ([98.248.42.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 15 Nov 2009 22:59:34 +0100 Original-Received: from jared by c-98-248-42-158.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 15 Nov 2009 22:59:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 98 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-98-248-42-158.hsd1.ca.comcast.net User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) In-Reply-To: <6cd6de210911140744t75b84417udfa6921cc8fe424f@mail.gmail.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:117016 Archived-At: Let me state this clearly, because I'm not sure you're getting it. A function that is being defined does not necessarily get defined from a file. For example, you can send code directly to the interpreter. Like this: (eval '(defun foo () (message "Hello"))) What should __FILE__ return in this case? eval-current-buffer and friends all are using this code path. require uses load which is why load-file-name and #$ work. Oh and by the way, (car-safe current-load-list) doesn't do anything useful in Emacs 22. -- MJF Rocky Bernstein wrote: > > > On Sat, Nov 14, 2009 at 6:24 AM, Richard Stallman > wrote: > > The basic idea of `require' is that you specify a feature which gets > found through a search of all libraries. The idea is that these are > general features which anything might want to use. > > > Require has/ two/ parts which are distinct. One part has the searching > for a file in it. The other part is the conditional load depending on > whether or not a feature has already been loaded > > > You want something different: > > That is, one wants to > load an Emacs Lisp file relative the file that issues the load > which is > often in the same directory or a nearby directory. > > It seems to me that this is useful only for loading other parts of one > single multi-file program. > > > No. A large modular program can be composed of other smaller modular > programs. In theory, one can package each file or subsets of files as > their own package, but often those smaller modules may be custom enough > that it doesn't make sense to do so. Or at least not initially. > > However when developing or working on the program, one wants may want to > work with each of the subparts independently. > > Here's an example that no doubt you are familiar with: a compile has a > parser, code generator and code optimizer. In a well-written modular > compiler one may want to work on and test the parser as an independent > unit even though I'm not sure you would want to package the front-end > for a specific language independently. > > So what require-relative and load-relative allow one to do is create > these little independent units without the overhead of using a more > elaborate packaging systems. require/provide in fact does this too. > However it pulls in file searching which is not desired here. Instead, > what we want to do in a program built of custom modules but is just > change how the file searching is managed. > > The second benefit of this is that we can develop out of the source tree > (that is without having to "install" the submodules) and have another > version or many versions "installed" at the same time. Starting with a > member of each version stays within that version of the code. > > > If you have a program which is in multiple files, you can write a > function similar to `require' which searches for files in any way you > like, and then you can use it. The function can be in your program; > it does not need to be built-in. It can load the chosen file using > `load'. > > > The files should each use `provide' in the usual way, and your > function should use the variable `features' to see if the desired > feature has already been loaded. The only difference would be in > choosing which file to load. > > > > That's in fact what I have done > . The only "primitive" > needed is Ruby's __FILE__ which is the same thing as the C > preprocessor __FILE__. > > $# and load-file-name are close; better is (car-safe current-load-list). > How these differ, and where __FILE__ is better, is that a macro > substitution of the file name is done at compile time inside the code > the if compiled, or at eval time if not. >