From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id ODJ6Fuhill8CBQAA0tVLHw (envelope-from ) for ; Mon, 26 Oct 2020 05:47:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 4MxKEuhill8yXQAA1q6Kng (envelope-from ) for ; Mon, 26 Oct 2020 05:47:20 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 87E8D9403E8 for ; Mon, 26 Oct 2020 05:47:19 +0000 (UTC) Received: from localhost ([::1]:40268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWvLi-0000pO-EG for larch@yhetil.org; Mon, 26 Oct 2020 01:47:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWvLZ-0000pH-Nq for guix-devel@gnu.org; Mon, 26 Oct 2020 01:47:09 -0400 Received: from mail-il1-x143.google.com ([2607:f8b0:4864:20::143]:42259) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kWvLX-0003O4-LM for guix-devel@gnu.org; Mon, 26 Oct 2020 01:47:09 -0400 Received: by mail-il1-x143.google.com with SMTP id c11so4077203iln.9 for ; Sun, 25 Oct 2020 22:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=OZE+RAllcChwunLh4As97a/tdrzivoWb4TqAb47YpfI=; b=uqF2UhQwiOLXaUJs+XOQ34P0sOvxSt7d5KfJJUMomSEYZG3HfDB9auHae146+xbvmq qPc9/UJyoQ/nOpCVteT5c7X2k5Dc6g2bqR/VCt0/Wbd7vBqwJHQCTRdeqvuKmIBalC/M MKm714msmxuQYFc0stSxRgm9r7aXIgjIPuED0KeuoZwDxGKZTE17iK0Cb1uTNEcOvltm ccSwEbL8YXBBn1tLQx1EFjStjlo2gzhhPeVYPx4ryWf8u0fF8k6sKK79lixSbfBXfC0F MrPZlDoAzVrjQiFnMSjAY2r2ofyVkzMDY83cJw53KRw2E9USeUhL1VpfMu+utJrt3CUX EclA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=OZE+RAllcChwunLh4As97a/tdrzivoWb4TqAb47YpfI=; b=X0aWi2ec7yT9ogWk16n0BQIjgREd1/JkUqQOfN7yAhbvo6GLfCtramJaJJ+Ak86sMJ UEXFfAW7K6su7m0y3VUR7Ioe4YHK2sYFQe81S6z3AuQrgCEv4pEmfxrApFN0V3jiribA LNaO4aKdrv3wG7f5o/zw7k/OKc35sPHOlSiTsUuHy3vMuNJ+6v2pJCxISevgGusHSdu7 GWJgPKUhV6R7mc3P34O1s8d72Qt0U0P0R+gAeOJCESeg7xcuNNTetulra5fqcJqmeNaA t5D+hNt7Wy8mLL+nkj8txK+78qImM7YAallv1xkQezgynKUTQ7+6FJ2jCl6HHjHnCyM+ NCIA== X-Gm-Message-State: AOAM532c5PzWWfFexahkBspLbRHOAu4lIYSTtsj1bbVZLYt+xOKK8cPA vQHJSCNek3rFfRDOKVcOiXElqomK8+0= X-Google-Smtp-Source: ABdhPJzbaC+DcWF+UMVO9i77y2cG3zdjFbPG6lqTSM2bHYnVkK0WgqtR0yMt0srCA/ZvVpr5PhcNnQ== X-Received: by 2002:a05:6e02:786:: with SMTP id q6mr1362887ils.208.1603691226206; Sun, 25 Oct 2020 22:47:06 -0700 (PDT) Received: from hurd (dsl-10-129-233.b2b2c.ca. [72.10.129.233]) by smtp.gmail.com with ESMTPSA id d14sm5601917ila.42.2020.10.25.22.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 22:47:05 -0700 (PDT) From: Maxim Cournoyer To: Miguel =?utf-8?Q?=C3=81ngel?= Arruga Vivas Subject: Re: [PATCH] .dir-locals.el: Automatically set the GEISER-GUILE-LOAD-PATH variable. References: <87tuuixjno.fsf@gmail.com> <20201025184228.2460-1-maxim.cournoyer@gmail.com> <87o8kqowa5.fsf@gmail.com> Date: Mon, 26 Oct 2020 01:47:04 -0400 In-Reply-To: <87o8kqowa5.fsf@gmail.com> ("Miguel =?utf-8?Q?=C3=81ngel?= Arruga Vivas"'s message of "Sun, 25 Oct 2020 22:01:05 +0100") Message-ID: <87d015y1wn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::143; envelope-from=maxim.cournoyer@gmail.com; helo=mail-il1-x143.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=uqF2UhQw; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: y7h5tdrtdWtY Hello Miguel! Miguel =C3=81ngel Arruga Vivas writes: > Hi! > > I think that geiser should use something (project.el, wink wink) to fill > load-path automatically when that's possible. Nevertheless, I have some > comments for this. > > Maxim Cournoyer writes: >> + >> + ;; Emacs-Guix >> + (eval . (setq guix-directory >> + (locate-dominating-file default-directory ".dir-loca= ls.el"))) >> + >> + ;; Geiser >> + ;; This allows automatically setting the `geiser-guile-load-path' >> + ;; variable when using various Guix checkouts (e.g., via git workt= rees). >> + ;; The checkout root directory name should be prefixed by "guix" f= or it >> + ;; to work correctly. >> + (eval . (let* ((root-dir (expand-file-name >> + (locate-dominating-file >> + default-directory ".dir-locals.el"))) >> + ;; Workaround for bug https://issues.guix.gnu.org/4= 3818. >> + (root-dir* (if (string-suffix-p "/" root-dir) >> + (substring root-dir 0 -1) >> + root-dir)) > > This is already implemented by directory-file-name. Neat! >> + (clean-geiser-guile-load-path >> + (seq-remove (lambda (x) >> + (string-match "/guix" x)) >> + geiser-guile-load-path))) > > This fails if geiser-guile-load-path does not exist (void-variable). > The cleanup removes other guixes, isn't it? I suggest making the > variable buffer-local and forget about hard-coded names. :-) That's a good suggestion! I toyed with it and it's a bit tricky but I think the v2 patch I'll send as a follow-up does the trick. My concern was also supporting when a user has previously set geiser-guile-load-path in their .emacs init file, e.g.: --8<---------------cut here---------------start------------->8--- (setq geiser-guile-load-path (list (expand-file-name "~/src/guix") (expand-file-name "~/src/shepherd"))) --8<---------------cut here---------------end--------------->8--- That would mean their entries don't get cleaned up (it seems this doesn't matter in my latest tests with the v2 patch though!). >> + (setq geiser-guile-load-path + (cons root-dir* >> clean-geiser-guile-load-path)))))) > > This becomes a push with a local variable. Like this: > > (eval . (setq guix-directory > (locate-dominating-file default-directory ".dir-locals.el"))) > (eval . (when (boundp 'geiser-guile-load-path) This check makes it so that if geiser-guile-load-path is not already defined, nothing happens. It is likely that this is the case, as when relying on just Geiser's autoloads, it is not loaded. The user would have to either set explicitly before hand or call (require 'geiser-guile), which we can't rely on. But we can drop this check. > (make-local-variable 'geiser-guile-load-path) (push > (directory-file-name (expand-file-name > (locate-dominating-file default-directory > ".dir-locals.el"))) geiser-guile-load-path)) I ended up using `cl-pushnew' here instead of push, as otherwise repeated entries were accumulated. One thing that worried me was the %load-compiled-path not appearing in the order defined from guile-geiser-load-path, but in my latest tests as mentioned above it didn't matter. Below, the %load-path and %load-compiled-path variables with this patch, when geiser-guile-load-path is predefined with '("/home/maxim/src/shepherd" "/home/maxim/src/guix") from my .emacs file: ;; scheme@(guile-user)> %load-path ;; $2 =3D ("/home/maxim/src/guix-core-updates" "/gnu/store/...-emacs-geiser-0.12/share/geiser/guile/" "/home/maxim/src/guix" "/home/maxim/src/shepherd"=20 [...]) ;; scheme@(guile-user)> %load-compiled-path ;; $3 =3D ("/home/maxim/src/shepherd" "/home/maxim/src/guix" "/home/maxim/src/guix-core-updates" [...]) Patch v2 incoming. Thank you, Maxim