From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: add-relative-load-path ? Date: Sun, 08 Jan 2012 16:14:29 +0100 Message-ID: <87zkdycjl6.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1326035711 2942 80.91.229.12 (8 Jan 2012 15:15:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Jan 2012 15:15:11 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jan 08 16:14:47 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RjuSI-0001Vd-UP for guile-devel@m.gmane.org; Sun, 08 Jan 2012 16:14:43 +0100 Original-Received: from localhost ([::1]:33805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjuSI-0000jG-Ee for guile-devel@m.gmane.org; Sun, 08 Jan 2012 10:14:42 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjuSF-0000jB-Sp for guile-devel@gnu.org; Sun, 08 Jan 2012 10:14:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjuSB-0006vC-0P for guile-devel@gnu.org; Sun, 08 Jan 2012 10:14:39 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:63649 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjuSA-0006v2-U5 for guile-devel@gnu.org; Sun, 08 Jan 2012 10:14:34 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 70CF073E5 for ; Sun, 8 Jan 2012 10:14:34 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:mime-version:content-type; s=sasl; bh=J JF8t73rpqdj0tBTvXN3cWFmmv0=; b=CbyW1kz21eevQssLz0ULOA+GOhAcAWuUb Ha6PsKGjSxXIuo8oNPVfSvP+4eBXHBXnVkP98fVjugTBa801Ei+W/3rDoY1nGLSk cMxRlDLj2OKB4ks928Z44LkwDJ8GWy+Rhv7eAgSd7fB4KBNCDIR8PYLDbfBbGZCw sD365DOKro= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=sasl; b=TOj MF3J1kJY9O7hCmQ+cmCwFvsXiZ/0cwOZ9YAif5GAbF6OINvUIixc6cb2fgZ9asIi yAqbX/FY3u1r3Qn6eN2PJVvLx+OWjrKUg9BYk5TzynatEY/PibZ+ura7hu/H29j7 C9z4mm/W1Xj3nUXt85NSQ6gJQqoJcLPYuwz916+8= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 6AF1573E4 for ; Sun, 8 Jan 2012 10:14:34 -0500 (EST) Original-Received: from badger (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id C611D73E3 for ; Sun, 8 Jan 2012 10:14:33 -0500 (EST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: 78915CA8-3A0B-11E1-8D13-65B1DE995924-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13440 Archived-At: Hi all, In the following thread: http://thread.gmane.org/gmane.lisp.guile.user/8298/focus=8403 there was a concern that it's difficult to set up the load path for simple one-off scripts. I had a proposal that we add something like this: (define-syntax add-relative-load-path (lambda (x) (syntax-case x () ((_ path) (string? (syntax->datum #'path)) (let* ((src (syntax-source #'x)) (current-file (or (and src (assq-ref src 'filename)) (error "Could not determine current file name"))) (vicinity (dirname (canonicalize-path current-file))) (path-elt (in-vicinity vicinity (syntax->datum #'path)))) #`(eval-when (compile load eval) (set! %load-path (cons #,path-elt %load-path)))))))) Then in your script you would (add-relative-load-path "."). Maybe we need an `add-to-load-path' form that handles the eval-when, actually, so it would be (add-to-load-path (dirname (current-source-filename))) or something like that. (We'd have to define current-source-filename as well, in terms of current-source-location.) What do folks think? Is it work it? Andy -- http://wingolog.org/