GNU bug report logs - #56955
[PATCH] .dir-locals.el: Add guix yasnippets.

Previous Next

Package: guix-patches;

Reported by: Andrew Tropin <andrew <at> trop.in>

Date: Wed, 3 Aug 2022 15:03:01 UTC

Severity: normal

Tags: patch

Done: Andrew Tropin <andrew <at> trop.in>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 56955 in the body.
You can then email your comments to 56955 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#56955; Package guix-patches. (Wed, 03 Aug 2022 15:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrew Tropin <andrew <at> trop.in>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 03 Aug 2022 15:03:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: guix-patches <at> gnu.org
Subject: [PATCH] .dir-locals.el: Add guix yasnippets.
Date: Wed, 3 Aug 2022 17:51:48 +0300
[Message part 1 (text/plain, inline)]
* .dir-locals.el (eval): Add guix yasnippets.
---
 .dir-locals.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/.dir-locals.el b/.dir-locals.el
index e4c1da8026..ecaec8de87 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -14,6 +14,15 @@
      (eval . (setq-local guix-directory
                          (locate-dominating-file default-directory
                                                  ".dir-locals.el")))
+     ;; YASnippet
+     (eval . (with-eval-after-load
+                 'yasnippet
+               (add-to-list 'yas-snippet-dirs
+                            (expand-file-name
+                             "etc/snippets"
+                             (locate-dominating-file default-directory
+                                                     ".dir-locals.el")))
+               (yas-reload-all)))
 
      ;; Geiser
      ;; This allows automatically setting the `geiser-guile-load-path'
-- 
2.37.0

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#56955; Package guix-patches. (Wed, 10 Aug 2022 20:27:02 GMT) Full text and rfc822 format available.

Message #8 received at 56955 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Andrew Tropin <andrew <at> trop.in>
Cc: 56955 <at> debbugs.gnu.org
Subject: Re: bug#56955: [PATCH] .dir-locals.el: Add guix yasnippets.
Date: Wed, 10 Aug 2022 16:26:10 -0400
Hi Andrew,

Andrew Tropin <andrew <at> trop.in> writes:

> * .dir-locals.el (eval): Add guix yasnippets.
> ---
>  .dir-locals.el | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/.dir-locals.el b/.dir-locals.el
> index e4c1da8026..ecaec8de87 100644
> --- a/.dir-locals.el
> +++ b/.dir-locals.el
> @@ -14,6 +14,15 @@
>       (eval . (setq-local guix-directory
>                           (locate-dominating-file default-directory
>                                                   ".dir-locals.el")))
> +     ;; YASnippet
> +     (eval . (with-eval-after-load
> +                 'yasnippet
> +               (add-to-list 'yas-snippet-dirs
> +                            (expand-file-name
> +                             "etc/snippets"
> +                             (locate-dominating-file default-directory
> +                                                     ".dir-locals.el")))
> +               (yas-reload-all)))

That's an interesting idea, but wouldn't the `yas-reload-all` be
triggered for every module visited?  That may take some time if a user
has lots of snippets in their collection.

Perhaps what it could do is check if the yas-snippet-dirs already has
the guix snippets directory, and do nothing if it does.

Thanks,

Maxim




Information forwarded to guix-patches <at> gnu.org:
bug#56955; Package guix-patches. (Wed, 17 Aug 2022 05:12:01 GMT) Full text and rfc822 format available.

Message #11 received at 56955 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 56955 <at> debbugs.gnu.org
Subject: Re: bug#56955: [PATCH] .dir-locals.el: Add guix yasnippets.
Date: Wed, 17 Aug 2022 08:11:38 +0300
[Message part 1 (text/plain, inline)]
On 2022-08-10 16:26, Maxim Cournoyer wrote:

> Hi Andrew,
>
> Andrew Tropin <andrew <at> trop.in> writes:
>
>> * .dir-locals.el (eval): Add guix yasnippets.
>> ---
>>  .dir-locals.el | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/.dir-locals.el b/.dir-locals.el
>> index e4c1da8026..ecaec8de87 100644
>> --- a/.dir-locals.el
>> +++ b/.dir-locals.el
>> @@ -14,6 +14,15 @@
>>       (eval . (setq-local guix-directory
>>                           (locate-dominating-file default-directory
>>                                                   ".dir-locals.el")))
>> +     ;; YASnippet
>> +     (eval . (with-eval-after-load
>> +                 'yasnippet
>> +               (add-to-list 'yas-snippet-dirs
>> +                            (expand-file-name
>> +                             "etc/snippets"
>> +                             (locate-dominating-file default-directory
>> +                                                     ".dir-locals.el")))
>> +               (yas-reload-all)))
>
> That's an interesting idea, but wouldn't the `yas-reload-all` be
> triggered for every module visited?  That may take some time if a user
> has lots of snippets in their collection.
>
> Perhaps what it could do is check if the yas-snippet-dirs already has
> the guix snippets directory, and do nothing if it does.

That's right, attaching v2 with the fix.

[v2-0001-.dir-locals.el-Add-guix-yasnippets.patch (text/x-patch, inline)]
From 43ab1f3da75cd8bb719b664c42f23f053b3fbb69 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Wed, 3 Aug 2022 17:51:48 +0300
Subject: [PATCH v2] .dir-locals.el: Add guix yasnippets.

* .dir-locals.el (eval): Add guix yasnippets.
---
 .dir-locals.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/.dir-locals.el b/.dir-locals.el
index e4c1da8026..6fa0ec8bc6 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -14,6 +14,17 @@
      (eval . (setq-local guix-directory
                          (locate-dominating-file default-directory
                                                  ".dir-locals.el")))
+     ;; YASnippet
+     (eval . (with-eval-after-load
+                 'yasnippet
+               (let ((guix-yasnippets
+                      (expand-file-name
+                       "etc/snippets"
+                       (locate-dominating-file default-directory
+                                               ".dir-locals.el"))))
+                 (unless (member guix-yasnippets yas-snippet-dirs)
+                   (add-to-list 'yas-snippet-dirs guix-yasnippets)
+                   (yas-reload-all)))))
 
      ;; Geiser
      ;; This allows automatically setting the `geiser-guile-load-path'
-- 
2.37.1

[Message part 3 (text/plain, inline)]
-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#56955; Package guix-patches. (Thu, 01 Sep 2022 21:19:02 GMT) Full text and rfc822 format available.

Message #14 received at 56955 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Andrew Tropin <andrew <at> trop.in>
Cc: 56955 <at> debbugs.gnu.org
Subject: Re: bug#56955: [PATCH] .dir-locals.el: Add guix yasnippets.
Date: Thu, 01 Sep 2022 17:18:01 -0400
Hi Andrew,

[...]

>> Perhaps what it could do is check if the yas-snippet-dirs already has
>> the guix snippets directory, and do nothing if it does.
>
> That's right, attaching v2 with the fix.
>
> From 43ab1f3da75cd8bb719b664c42f23f053b3fbb69 Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew <at> trop.in>
> Date: Wed, 3 Aug 2022 17:51:48 +0300
> Subject: [PATCH v2] .dir-locals.el: Add guix yasnippets.
>
> * .dir-locals.el (eval): Add guix yasnippets.
> ---
>  .dir-locals.el | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/.dir-locals.el b/.dir-locals.el
> index e4c1da8026..6fa0ec8bc6 100644
> --- a/.dir-locals.el
> +++ b/.dir-locals.el
> @@ -14,6 +14,17 @@
>       (eval . (setq-local guix-directory
>                           (locate-dominating-file default-directory
>                                                   ".dir-locals.el")))
> +     ;; YASnippet
> +     (eval . (with-eval-after-load
> +                 'yasnippet
> +               (let ((guix-yasnippets
> +                      (expand-file-name
> +                       "etc/snippets"
> +                       (locate-dominating-file default-directory
> +                                               ".dir-locals.el"))))
> +                 (unless (member guix-yasnippets yas-snippet-dirs)
> +                   (add-to-list 'yas-snippet-dirs guix-yasnippets)
> +                   (yas-reload-all)))))

Sorry for failing to produce a reply earlier: the above LGTM!

Another small step toward a zero-config Emacs setup for hacking on Guix
:-).

Feel free to push!

Thanks,

Maxim




bug closed, send any further explanations to 56955 <at> debbugs.gnu.org and Andrew Tropin <andrew <at> trop.in> Request was from Andrew Tropin <andrew <at> trop.in> to control <at> debbugs.gnu.org. (Mon, 05 Sep 2022 06:16:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 03 Oct 2022 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 177 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.