From: Ricardo Wurmus <rekado@elephly.net>
To: guix-devel@gnu.org
Subject: Snippets for working on Guix
Date: Fri, 15 Dec 2017 00:48:14 +0100 [thread overview]
Message-ID: <87lgi4vpkx.fsf@elephly.net> (raw)
[-- 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
next reply other threads:[~2017-12-15 0:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 23:48 Ricardo Wurmus [this message]
2017-12-15 14:58 ` Snippets for working on Guix 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lgi4vpkx.fsf@elephly.net \
--to=rekado@elephly.net \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).