* Snippets for working on Guix
@ 2017-12-14 23:48 Ricardo Wurmus
2017-12-15 14:58 ` Ludovic Courtès
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Ricardo Wurmus @ 2017-12-14 23:48 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]
Hi Guix,
to avoid the need to type out boilerplate I wrote a couple of snippets
that can be used with yasnippet in Emacs, and I thought I should share
them with you.
These snippets are available:
./scheme-mode/guix-package
./scheme-mode/guix-origin
./scheme-mode/guix-git-reference
./scheme-mode/guix-hg-reference
./scheme-mode/guix-cvs-reference
./scheme-mode/guix-svn-reference
./text-mode/guix-commit-message-add-package
./text-mode/guix-commit-message-update-package
The snippets in the “scheme-mode” directory are used to define new
packages. Enable yas-global-mode and type “package...<TAB>” to get a
package skeleton. Hit <TAB> to jump to the next field to complete it.
You can also select a build system from a list.
At last you end up at “origin...”; when you hit <TAB> it will expand
the “guix-origin” snippet, which allows you to select a fetch method
from a list. As the last step you end up at the “uri” field, which may
be further expandable with “guix-git-reference”, “guix-hg-reference”,
“guix-cvs-reference”, or “guix-svn-reference”.
The “text-mode” snippets are for commit messages. They use magit to
get the names of staged files. You can use “add<TAB>” to create a
commit message for adding a package, or “update<TAB>” to create a
message for updating a package.
These commit message snippets aren’t very smart, because it isn’t
trivial to reliably infer the kind of change from just the staged hunk.
With some more work one might be able to detect a version number change
and the name of the package that has been updated.
I hope this is useful for some of you!
[-- Attachment #2: guix-package --]
[-- Type: text/plain, Size: 1560 bytes --]
# -*- mode: snippet -*-
# name: guix-package
# key: package...
# --
(define-public $1
(package
(name "$1")
(version "$2")
(source origin...$0)
(build-system ${3:$$(yas-choose-value "ant-build-system"
"asdf-build-system"
"cargo-build-system"
"cmake-build-system"
"dub-build-system"
"emacs-build-system"
"font-build-system"
"glib-or-gtk-build-system"
"gnu-build-system"
"go-build-system"
"haskell-build-system"
"meson-build-system"
"minify-build-system"
"ocaml-build-system"
"perl-build-system"
"python-build-system"
"r-build-system"
"ruby-build-system"
"texlive-build-system"
"trivial-build-system"
"waf-build-system")})
(home-page "$4")
(synopsis "$5")
(description "$6")
(license $7)))
[-- Attachment #3: guix-origin --]
[-- Type: text/plain, Size: 968 bytes --]
# -*- mode: snippet -*-
# name: guix-origin
# key: origin...
# --
(origin
(method ${1:$$(yas-choose-value "url-fetch"
"url-fetch/tarbomb"
"url-fetch/zipbomb"
"cvs-fetch"
"git-fetch"
"hg-fetch"
"svn-fetch")})
(uri ${1:$(cond ((equal yas-text "git-fetch") "git-reference...")
((equal yas-text "svn-fetch") "svn-reference...")
((equal yas-text "hg-fetch") "hg-reference...")
((equal yas-text "cvs-fetch") "cvs-reference...")
(t "(string-append \\"https://\\" version \\".tar.gz\\")"))}$0)
${1:$(cond ((member yas-text '("git-fetch" "svn-fetch" "hg-fetch" "cvs-fetch"))
"(file-name (string-append name \\"-\\" version \\"-checkout\\"))")
(t ""))}
(sha256
(base32
"$2")))
[-- Attachment #4: guix-git-reference --]
[-- Type: text/plain, Size: 131 bytes --]
# -*- mode: snippet -*-
# name: guix-git-reference
# key: git-reference...
# --
(git-reference
(url "$1")
(commit ${2:commit}))
[-- Attachment #5: guix-svn-reference --]
[-- Type: text/plain, Size: 139 bytes --]
# -*- mode: snippet -*-
# name: guix-svn-reference
# key: svn-reference...
# --
(svn-reference
(url "$1")
(revision ${2:svn-revision}))
[-- Attachment #6: guix-hg-reference --]
[-- Type: text/plain, Size: 134 bytes --]
# -*- mode: snippet -*-
# name: guix-hg-reference
# key: hg-reference...
# --
(hg-reference
(url "$1")
(changeset ${2:changeset}))
[-- Attachment #7: guix-cvs-reference --]
[-- Type: text/plain, Size: 190 bytes --]
# -*- mode: snippet -*-
# name: guix-cvs-reference
# key: cvs-reference...
# --
(cvs-reference
(root-directory "${1:root-directory}")
(module "${2:module}")
(revision "${3:revision}"))
[-- Attachment #8: guix-commit-message-add-package --]
[-- Type: text/plain, Size: 173 bytes --]
# -*- mode: snippet -*-
# name: guix-commit-message-add-package
# key: add
# condition: git-commit-mode
# --
gnu: Add $1.
* `(car (magit-staged-files))` ($1): New variable.
[-- Attachment #9: guix-commit-message-update-package --]
[-- Type: text/plain, Size: 272 bytes --]
# -*- mode: snippet -*-
# name: guix-commit-message-update-package
# key: update
# condition: git-commit-mode
# --
gnu: $1: Update to $2.
* `(car (magit-staged-files))` ($1): Update to $2.$0
`(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")`
[-- Attachment #10: Type: text/plain, Size: 89 bytes --]
--
Ricardo
GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
https://elephly.net
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-14 23:48 Snippets for working on Guix Ricardo Wurmus
@ 2017-12-15 14:58 ` Ludovic Courtès
2017-12-15 16:20 ` Ricardo Wurmus
2017-12-16 6:14 ` Arun Isaac
2017-12-16 3:17 ` Maxim Cournoyer
2017-12-16 8:15 ` Chris Marusich
2 siblings, 2 replies; 10+ messages in thread
From: Ludovic Courtès @ 2017-12-15 14:58 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: guix-devel
Hi!
Ricardo Wurmus <rekado@elephly.net> skribis:
> to avoid the need to type out boilerplate I wrote a couple of snippets
> that can be used with yasnippet in Emacs, and I thought I should share
> them with you.
>
> These snippets are available:
>
> ./scheme-mode/guix-package
> ./scheme-mode/guix-origin
> ./scheme-mode/guix-git-reference
> ./scheme-mode/guix-hg-reference
> ./scheme-mode/guix-cvs-reference
> ./scheme-mode/guix-svn-reference
> ./text-mode/guix-commit-message-add-package
> ./text-mode/guix-commit-message-update-package
That looks really useful!
Do you think we could add them under etc/emacs in the repo, and somehow
have them automatically available? Or should it be in Emacs-Guix?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-15 14:58 ` Ludovic Courtès
@ 2017-12-15 16:20 ` Ricardo Wurmus
2017-12-16 6:14 ` Arun Isaac
1 sibling, 0 replies; 10+ messages in thread
From: Ricardo Wurmus @ 2017-12-15 16:20 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Hi Ludo,
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> to avoid the need to type out boilerplate I wrote a couple of snippets
>> that can be used with yasnippet in Emacs, and I thought I should share
>> them with you.
>>
>> These snippets are available:
>>
>> ./scheme-mode/guix-package
>> ./scheme-mode/guix-origin
>> ./scheme-mode/guix-git-reference
>> ./scheme-mode/guix-hg-reference
>> ./scheme-mode/guix-cvs-reference
>> ./scheme-mode/guix-svn-reference
>> ./text-mode/guix-commit-message-add-package
>> ./text-mode/guix-commit-message-update-package
>
> That looks really useful!
>
> Do you think we could add them under etc/emacs in the repo, and somehow
> have them automatically available? Or should it be in Emacs-Guix?
Sure. To use them you’d only have to add the directory to
“yas-snippets-dirs”. I’ll document this in contributing.texi.
--
Ricardo
GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
https://elephly.net
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-14 23:48 Snippets for working on Guix Ricardo Wurmus
2017-12-15 14:58 ` Ludovic Courtès
@ 2017-12-16 3:17 ` Maxim Cournoyer
2017-12-16 8:15 ` Chris Marusich
2 siblings, 0 replies; 10+ messages in thread
From: Maxim Cournoyer @ 2017-12-16 3:17 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: guix-devel
Hi Ricardo!
Ricardo Wurmus <rekado@elephly.net> writes:
> Hi Guix,
>
> to avoid the need to type out boilerplate I wrote a couple of snippets
> that can be used with yasnippet in Emacs, and I thought I should share
> them with you.
>
> These snippets are available:
>
> ./scheme-mode/guix-package
> ./scheme-mode/guix-origin
> ./scheme-mode/guix-git-reference
> ./scheme-mode/guix-hg-reference
> ./scheme-mode/guix-cvs-reference
> ./scheme-mode/guix-svn-reference
> ./text-mode/guix-commit-message-add-package
> ./text-mode/guix-commit-message-update-package
>
This is pretty fun and useful too! It seems a cleaner approach to the
copy-pasting of previous packages I'm sure many of us are doing ;).
Thanks for sharing!
Maxim
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-15 14:58 ` Ludovic Courtès
2017-12-15 16:20 ` Ricardo Wurmus
@ 2017-12-16 6:14 ` Arun Isaac
2017-12-16 10:21 ` Ricardo Wurmus
1 sibling, 1 reply; 10+ messages in thread
From: Arun Isaac @ 2017-12-16 6:14 UTC (permalink / raw)
To: guix-devel
>> to avoid the need to type out boilerplate I wrote a couple of snippets
>> that can be used with yasnippet in Emacs, and I thought I should share
>> them with you.
>>
>> These snippets are available:
>>
>> ./scheme-mode/guix-package
>> ./scheme-mode/guix-origin
>> ./scheme-mode/guix-git-reference
>> ./scheme-mode/guix-hg-reference
>> ./scheme-mode/guix-cvs-reference
>> ./scheme-mode/guix-svn-reference
>> ./text-mode/guix-commit-message-add-package
>> ./text-mode/guix-commit-message-update-package
>
> That looks really useful!
Indeed, this is very useful! :-)
> Do you think we could add them under etc/emacs in the repo, and somehow
> have them automatically available? Or should it be in Emacs-Guix?
It would be nice if this was available automatically through emacs-guix.
Apart from the snippets, it would also be nice to somehow automatically
update a package definition -- that is, change the version number,
download the new source, and update the hash. I was trying to work this
out. I was able to get the Guix REPL to download the new source tarball,
but couldn't figure out how to retrieve the new hash from the Guix
REPL. Any pointers?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-14 23:48 Snippets for working on Guix Ricardo Wurmus
2017-12-15 14:58 ` Ludovic Courtès
2017-12-16 3:17 ` Maxim Cournoyer
@ 2017-12-16 8:15 ` Chris Marusich
2017-12-16 8:59 ` Ricardo Wurmus
2 siblings, 1 reply; 10+ messages in thread
From: Chris Marusich @ 2017-12-16 8:15 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 619 bytes --]
Ricardo Wurmus <rekado@elephly.net> writes:
> to avoid the need to type out boilerplate I wrote a couple of snippets
> that can be used with yasnippet in Emacs, and I thought I should share
> them with you.
Thank you very much!
> I hope this is useful for some of you!
I am very interested in trying this out. However, as someone who has
never used yasnippet, I think it would be extremely helpful if you could
provide a simple example of what to do in the manual somewhere under the
"Contributing" section. And that way, it's more likely people will
discover and use these snippets.
--
Chris
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-16 8:15 ` Chris Marusich
@ 2017-12-16 8:59 ` Ricardo Wurmus
2017-12-16 9:03 ` Chris Marusich
0 siblings, 1 reply; 10+ messages in thread
From: Ricardo Wurmus @ 2017-12-16 8:59 UTC (permalink / raw)
To: Chris Marusich; +Cc: guix-devel
Chris Marusich <cmmarusich@gmail.com> writes:
> Ricardo Wurmus <rekado@elephly.net> writes:
>
>> to avoid the need to type out boilerplate I wrote a couple of snippets
>> that can be used with yasnippet in Emacs, and I thought I should share
>> them with you.
>
> Thank you very much!
>
>> I hope this is useful for some of you!
>
> I am very interested in trying this out. However, as someone who has
> never used yasnippet, I think it would be extremely helpful if you could
> provide a simple example of what to do in the manual somewhere under the
> "Contributing" section. And that way, it's more likely people will
> discover and use these snippets.
It’s already there, but due to a bug, the manual won’t be rebuilt when
“contributing.texi” has changed. As a work-around just touch
“doc/guix.texi” and then run “make info”.
--
Ricardo
GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
https://elephly.net
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-16 8:59 ` Ricardo Wurmus
@ 2017-12-16 9:03 ` Chris Marusich
0 siblings, 0 replies; 10+ messages in thread
From: Chris Marusich @ 2017-12-16 9:03 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 996 bytes --]
Ricardo Wurmus <rekado@elephly.net> writes:
> Chris Marusich <cmmarusich@gmail.com> writes:
>
>> Ricardo Wurmus <rekado@elephly.net> writes:
>>
>>> to avoid the need to type out boilerplate I wrote a couple of snippets
>>> that can be used with yasnippet in Emacs, and I thought I should share
>>> them with you.
>>
>> Thank you very much!
>>
>>> I hope this is useful for some of you!
>>
>> I am very interested in trying this out. However, as someone who has
>> never used yasnippet, I think it would be extremely helpful if you could
>> provide a simple example of what to do in the manual somewhere under the
>> "Contributing" section. And that way, it's more likely people will
>> discover and use these snippets.
>
> It’s already there, but due to a bug, the manual won’t be rebuilt when
> “contributing.texi” has changed. As a work-around just touch
> “doc/guix.texi” and then run “make info”.
Oh, awesome! I will check it out.
--
Chris
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-16 6:14 ` Arun Isaac
@ 2017-12-16 10:21 ` Ricardo Wurmus
2017-12-16 15:58 ` Arun Isaac
0 siblings, 1 reply; 10+ messages in thread
From: Ricardo Wurmus @ 2017-12-16 10:21 UTC (permalink / raw)
To: Arun Isaac; +Cc: guix-devel
Arun Isaac <arunisaac@systemreboot.net> writes:
>> Do you think we could add them under etc/emacs in the repo, and somehow
>> have them automatically available? Or should it be in Emacs-Guix?
>
> It would be nice if this was available automatically through emacs-guix.
I think snippets should not be available automatically. Some really
hate snippets or prefer a different system over YASnippet. The setup is
*very* simple if you’re already using yasnippet anyway: just add the
directory to “yas-snippet-dirs” and you’re done.
> Apart from the snippets, it would also be nice to somehow automatically
> update a package definition -- that is, change the version number,
> download the new source, and update the hash.
This is implemented as “guix refresh -u foo”. It works for any package
that is covered by an updater.
--
Ricardo
GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
https://elephly.net
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Snippets for working on Guix
2017-12-16 10:21 ` Ricardo Wurmus
@ 2017-12-16 15:58 ` Arun Isaac
0 siblings, 0 replies; 10+ messages in thread
From: Arun Isaac @ 2017-12-16 15:58 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: guix-devel
Ricardo Wurmus <rekado@elephly.net> writes:
> Arun Isaac <arunisaac@systemreboot.net> writes:
>
>>> Do you think we could add them under etc/emacs in the repo, and somehow
>>> have them automatically available? Or should it be in Emacs-Guix?
>>
>> It would be nice if this was available automatically through emacs-guix.
>
> I think snippets should not be available automatically. Some really
> hate snippets or prefer a different system over YASnippet. The setup is
> *very* simple if you’re already using yasnippet anyway: just add the
> directory to “yas-snippet-dirs” and you’re done.
Ok, that makes sense.
>> Apart from the snippets, it would also be nice to somehow automatically
>> update a package definition -- that is, change the version number,
>> download the new source, and update the hash.
>
> This is implemented as “guix refresh -u foo”. It works for any package
> that is covered by an updater.
Oh, I didn't know about this. This is very useful. Thanks!
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-12-16 15:58 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14 23:48 Snippets for working on Guix Ricardo Wurmus
2017-12-15 14:58 ` Ludovic Courtès
2017-12-15 16:20 ` Ricardo Wurmus
2017-12-16 6:14 ` Arun Isaac
2017-12-16 10:21 ` Ricardo Wurmus
2017-12-16 15:58 ` Arun Isaac
2017-12-16 3:17 ` Maxim Cournoyer
2017-12-16 8:15 ` Chris Marusich
2017-12-16 8:59 ` Ricardo Wurmus
2017-12-16 9:03 ` Chris Marusich
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.