From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel Subject: Re: Trouble using (current-filename) Date: Tue, 21 Feb 2012 20:48:57 +0000 Message-ID: <87aa4bdi9y.fsf@neil-laptop.ossau.uklinux.net> References: <87d39h451b.fsf@netris.org> <87zkcjloqu.fsf@pobox.com> <871upu5unw.fsf@gnu.org> <878vk2pgaf.fsf@pobox.com> <87wr7l13eh.fsf@gnu.org> <87y5rz26zz.fsf@pobox.com> <87fwe6ykw2.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1329857360 17826 80.91.229.3 (21 Feb 2012 20:49:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 21 Feb 2012 20:49:20 +0000 (UTC) Cc: Andy Wingo , guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Feb 21 21:49:17 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rzwe8-0006uL-Ep for guile-devel@m.gmane.org; Tue, 21 Feb 2012 21:49:12 +0100 Original-Received: from localhost ([::1]:52101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rzwe8-0006XL-0N for guile-devel@m.gmane.org; Tue, 21 Feb 2012 15:49:12 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rzwe2-0006X5-FL for guile-devel@gnu.org; Tue, 21 Feb 2012 15:49:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rzwdy-0004ru-Du for guile-devel@gnu.org; Tue, 21 Feb 2012 15:49:06 -0500 Original-Received: from out1.ip08ir2.opaltelecom.net ([62.24.128.244]:14253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rzwdy-0004rk-6E; Tue, 21 Feb 2012 15:49:02 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EAOUCRE9OlcyG/2dsb2JhbABDhROtL4EIgXMBAQQBIzMjBQsIAxoCBSECAg8BBCU3G4dlA6YZkjiBL4p2BRYBCQIWAwKDXwIBgmCBFgSoJQ X-IronPort-AV: E=Sophos;i="4.73,459,1325462400"; d="scan'208";a="518187582" Original-Received: from host-78-149-204-134.as13285.net (HELO arudy) ([78.149.204.134]) by out1.ip08ir2.opaltelecom.net with ESMTP; 21 Feb 2012 20:48:59 +0000 Original-Received: from neil-laptop.ossau.uklinux.net.ossau.homelinux.net (host-78-149-204-134.as13285.net [78.149.204.134]) by arudy (Postfix) with ESMTPA id A92A338037; Tue, 21 Feb 2012 20:48:58 +0000 (GMT) In-Reply-To: <87fwe6ykw2.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sun, 19 Feb 2012 15:10:05 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 62.24.128.244 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:13917 Archived-At: Sorry for chipping in late to this discussion. ludo@gnu.org (Ludovic Court=C3=A8s) writes: > I think it=E2=80=99s often undesirable. > > Suppose you want to use =E2=80=98current-filename=E2=80=99 in an =E2=80= =98assert=E2=80=99 macro, for > instance: what you want is a hint, not an absolute path, since that path > is likely to be invalid at the time you see it (for instance, it could > point to the source tree on a build machine of your distro.) Or suppose that a script and accompanying module set is compiled in the build tree, then installed or relocated elsewhere. In this case, what I'd be looking for, with this (add-to-load-path ...) stuff, would be to discover the location of the running script file _now_, and to construct a load path element relative to that. If I'm understanding correctly, 'current-filename' would give me the wrong answer in that case too, because it would have the pre-install/relocation location. Perhaps after all the right thing, for my use case, is something based on (car (command-line)) and (getcwd). I currently have this 'compatibility definition' for Guile 1.8.x: (define (current-filename) (let* ((script (car (command-line))) (scriptdir (dirname script)) (absdir (cond ((string=3D? scriptdir ".") (getcwd)) ((string-match "^/" scriptdir) scriptdir) (else (in-vicinity (getcwd) scriptdir))))) (in-vicinity scriptdir (basename script)))) But maybe that's the better solution for 2.x as well. Regards, Neil