me
/
guix
Archived
1
0
Fork 0

etc: Add snippets.

* etc/snippets/scheme-mode/guix-cvs-reference,
etc/snippets/scheme-mode/guix-git-reference,
etc/snippets/scheme-mode/guix-hg-reference,
etc/snippets/scheme-mode/guix-origin,
etc/snippets/scheme-mode/guix-package,
etc/snippets/scheme-mode/guix-svn-reference,
etc/snippets/text-mode/guix-commit-message-add-package,
etc/snippets/text-mode/guix-commit-message-update-package: New files.
* doc/contributing.texi (The Perfect Setup): Document snippets.
master
Ricardo Wurmus 2017-12-15 23:10:54 +01:00
parent 7683bf1183
commit 42cdcdff19
No known key found for this signature in database
GPG Key ID: 197A5888235FACAC
9 changed files with 131 additions and 0 deletions

View File

@ -193,6 +193,34 @@ facilities to directly operate on the syntax tree, such as raising an
s-expression or wrapping it, swallowing or rejecting the following s-expression or wrapping it, swallowing or rejecting the following
s-expression, etc. s-expression, etc.
@cindex code snippets
@cindex templates
@cindex reducing boilerplate
We also provide templates for common git commit messages and package
definitions in the @file{etc/snippets} directory. These templates can
be used with @url{http://joaotavora.github.io/yasnippet/, YASnippet} to
expand short trigger strings to interactive text snippets. You may want
to add the snippets directory to the @var{yas-snippet-dirs} variable in
Emacs.
@lisp
;; @r{Assuming the Guix checkout is in ~/src/guix.}
(with-eval-after-load 'yasnippet
(add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets"))
@end lisp
The commit message snippets depend on @url{https://magit.vc/, Magit} to
display staged files. When editing a commit message type @code{add}
followed by @kbd{TAB} to insert a commit message template for adding a
package; type @code{update} followed by @kbd{TAB} to insert a template
for updating a package.
The main snippet for @code{scheme-mode} is triggered by typing
@code{package...} followed by @kbd{TAB}. This snippet also inserts the
trigger string @code{origin...}, which can be expanded further. The
@code{origin} snippet in turn may insert other trigger strings ending on
@code{...}, which also can be expanded further.
@node Coding Style @node Coding Style
@section Coding Style @section Coding Style

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: guix-cvs-reference
# key: cvs-reference...
# --
(cvs-reference
(root-directory "${1:root-directory}")
(module "${2:module}")
(revision "${3:revision}"))

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: guix-git-reference
# key: git-reference...
# --
(git-reference
(url "$1")
(commit ${2:commit}))

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: guix-hg-reference
# key: hg-reference...
# --
(hg-reference
(url "$1")
(changeset ${2:changeset}))

View File

@ -0,0 +1,23 @@
# -*- 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")))

View File

@ -0,0 +1,34 @@
# -*- 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)))

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: guix-svn-reference
# key: svn-reference...
# --
(svn-reference
(url "$1")
(revision ${2:svn-revision}))

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: guix-commit-message-add-package
# key: add
# condition: git-commit-mode
# --
gnu: Add $1.
* `(car (magit-staged-files))` ($1): New variable.

View File

@ -0,0 +1,9 @@
# -*- 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")`