From c4acaf412064568a546034871a9e0d3888aa7937 Mon Sep 17 00:00:00 2001 From: Nicolas Graves Date: Fri, 12 Aug 2022 10:58:48 +0200 Subject: etc: Add tempel snippets. * etc/snippets/tempel/scheme-mode: New file. * etc/snippets/tempel/text-mode: New file. * etc/snippets/scheme-mode: Moved from here... * etc/snippets/yas/scheme-mode: ... to here. * etc/snippets/text-mode: Moved from here... * etc/snippets/yas/text-mode: ... to here. * doc/contributing.texi ("The Perfect Setup"): Adjust yasnippet setup accordingly. Add tempel setup. Signed-off-by: Liliana Marie Prikler --- doc/contributing.texi | 18 +++- etc/snippets/scheme-mode/guix-bzr-reference | 7 -- etc/snippets/scheme-mode/guix-cvs-reference | 8 -- etc/snippets/scheme-mode/guix-git-reference | 7 -- etc/snippets/scheme-mode/guix-hg-reference | 7 -- etc/snippets/scheme-mode/guix-origin | 29 ------ etc/snippets/scheme-mode/guix-package | 46 ---------- etc/snippets/scheme-mode/guix-svn-reference | 7 -- etc/snippets/tempel/scheme-mode | 80 ++++++++++++++++ etc/snippets/tempel/text-mode | 101 +++++++++++++++++++++ .../text-mode/guix-commit-message-add-cl-package | 15 --- .../text-mode/guix-commit-message-add-package | 13 --- .../text-mode/guix-commit-message-remove-package | 13 --- .../text-mode/guix-commit-message-rename-package | 20 ---- .../text-mode/guix-commit-message-update-package | 26 ------ .../guix-commit-message-use-https-home-page | 9 -- etc/snippets/yas/scheme-mode/guix-bzr-reference | 7 ++ etc/snippets/yas/scheme-mode/guix-cvs-reference | 8 ++ etc/snippets/yas/scheme-mode/guix-git-reference | 7 ++ etc/snippets/yas/scheme-mode/guix-hg-reference | 7 ++ etc/snippets/yas/scheme-mode/guix-origin | 29 ++++++ etc/snippets/yas/scheme-mode/guix-package | 46 ++++++++++ etc/snippets/yas/scheme-mode/guix-svn-reference | 7 ++ .../text-mode/guix-commit-message-add-cl-package | 15 +++ .../yas/text-mode/guix-commit-message-add-package | 13 +++ .../text-mode/guix-commit-message-remove-package | 13 +++ .../text-mode/guix-commit-message-rename-package | 20 ++++ .../text-mode/guix-commit-message-update-package | 26 ++++++ .../guix-commit-message-use-https-home-page | 9 ++ 29 files changed, 402 insertions(+), 211 deletions(-) delete mode 100644 etc/snippets/scheme-mode/guix-bzr-reference delete mode 100644 etc/snippets/scheme-mode/guix-cvs-reference delete mode 100644 etc/snippets/scheme-mode/guix-git-reference delete mode 100644 etc/snippets/scheme-mode/guix-hg-reference delete mode 100644 etc/snippets/scheme-mode/guix-origin delete mode 100644 etc/snippets/scheme-mode/guix-package delete mode 100644 etc/snippets/scheme-mode/guix-svn-reference create mode 100644 etc/snippets/tempel/scheme-mode create mode 100644 etc/snippets/tempel/text-mode delete mode 100644 etc/snippets/text-mode/guix-commit-message-add-cl-package delete mode 100644 etc/snippets/text-mode/guix-commit-message-add-package delete mode 100644 etc/snippets/text-mode/guix-commit-message-remove-package delete mode 100644 etc/snippets/text-mode/guix-commit-message-rename-package delete mode 100644 etc/snippets/text-mode/guix-commit-message-update-package delete mode 100644 etc/snippets/text-mode/guix-commit-message-use-https-home-page create mode 100644 etc/snippets/yas/scheme-mode/guix-bzr-reference create mode 100644 etc/snippets/yas/scheme-mode/guix-cvs-reference create mode 100644 etc/snippets/yas/scheme-mode/guix-git-reference create mode 100644 etc/snippets/yas/scheme-mode/guix-hg-reference create mode 100644 etc/snippets/yas/scheme-mode/guix-origin create mode 100644 etc/snippets/yas/scheme-mode/guix-package create mode 100644 etc/snippets/yas/scheme-mode/guix-svn-reference create mode 100644 etc/snippets/yas/text-mode/guix-commit-message-add-cl-package create mode 100644 etc/snippets/yas/text-mode/guix-commit-message-add-package create mode 100644 etc/snippets/yas/text-mode/guix-commit-message-remove-package create mode 100644 etc/snippets/yas/text-mode/guix-commit-message-rename-package create mode 100644 etc/snippets/yas/text-mode/guix-commit-message-update-package create mode 100644 etc/snippets/yas/text-mode/guix-commit-message-use-https-home-page diff --git a/doc/contributing.texi b/doc/contributing.texi index 02c7c5ae59..b1d236c011 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -320,15 +320,25 @@ s-expression, etc. @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{https://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 +be used to expand short trigger strings to interactive text snippets. If +you use @url{https://joaotavora.github.io/yasnippet/, YASnippet}, you +may want to add the @file{etc/snippets/yas} snippets directory to the +@var{yas-snippet-dirs} variable. If you use +@url{https://github.com/minad/tempel/, Tempel}, you may want to add the +@file{etc/snippets/tempel/*} path to the @var{tempel-path} variable in Emacs. @lisp ;; @r{Assuming the Guix checkout is in ~/src/guix.} +;; @r{Yasnippet configuration} (with-eval-after-load 'yasnippet - (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets")) + (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets/yas")) +;; @r{Tempel configuration} +(with-eval-after-load 'tempel + ;; Ensure tempel-path is a list -- it may also be a string. + (unless (listp 'tempel-path) + (setq tempel-path (list tempel-path))) + (add-to-list 'tempel-path "~/src/guix/etc/snippets/tempel/*")) @end lisp The commit message snippets depend on @url{https://magit.vc/, Magit} to diff --git a/etc/snippets/scheme-mode/guix-bzr-reference b/etc/snippets/scheme-mode/guix-bzr-reference deleted file mode 100644 index a801cc36f2..0000000000 --- a/etc/snippets/scheme-mode/guix-bzr-reference +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-bzr-reference -# key: bzr-reference... -# -- -(bzr-reference - (url "$1") - (revision ${2:ref})) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-cvs-reference b/etc/snippets/scheme-mode/guix-cvs-reference deleted file mode 100644 index fbc5034b66..0000000000 --- a/etc/snippets/scheme-mode/guix-cvs-reference +++ /dev/null @@ -1,8 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-cvs-reference -# key: cvs-reference... -# -- -(cvs-reference - (root-directory "${1:root-directory}") - (module "${2:module}") - (revision "${3:revision}")) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-git-reference b/etc/snippets/scheme-mode/guix-git-reference deleted file mode 100644 index 29ca6a9c54..0000000000 --- a/etc/snippets/scheme-mode/guix-git-reference +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-git-reference -# key: git-reference... -# -- -(git-reference - (url "$1") - (commit ${2:commit})) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-hg-reference b/etc/snippets/scheme-mode/guix-hg-reference deleted file mode 100644 index 95de16daae..0000000000 --- a/etc/snippets/scheme-mode/guix-hg-reference +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-hg-reference -# key: hg-reference... -# -- -(hg-reference - (url "$1") - (changeset ${2:changeset})) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-origin b/etc/snippets/scheme-mode/guix-origin deleted file mode 100644 index eb0cdc8242..0000000000 --- a/etc/snippets/scheme-mode/guix-origin +++ /dev/null @@ -1,29 +0,0 @@ -# -*- 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" - "bzr-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...") - ((equal yas-text "bzr-fetch") "bzr-reference...") - (t "(string-append \\"https://\\" version \\".tar.gz\\")"))}$0) - ${1:$(cond ((equal yas-text "git-fetch") - "(file-name (git-file-name name version))") - ((equal yas-text "hg-fetch") - "(file-name (hg-file-name name version))") - ((member yas-text '("svn-fetch" "cvs-fetch" "bzr-fetch")) - "(file-name (string-append name \\"-\\" version \\"-checkout\\"))") - (t ""))} - (sha256 - (base32 - "$2"))) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-package b/etc/snippets/scheme-mode/guix-package deleted file mode 100644 index 9ff6f997d1..0000000000 --- a/etc/snippets/scheme-mode/guix-package +++ /dev/null @@ -1,46 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-package -# key: package... -# -- -(define-public $1 - (package - (name "$1") - (version "$2") - (source origin...$0) - (build-system ${3:$$(yas-choose-value "android-ndk-build-system" - "ant-build-system" - "asdf-build-system" - "cargo-build-system" - "clojure-build-system" - "cmake-build-system" - "copy-build-system" - "dub-build-system" - "dune-build-system" - "emacs-build-system" - "font-build-system" - "glib-or-gtk-build-system" - "gnu-build-system" - "go-build-system" - "guile-build-system" - "haskell-build-system" - "julia-build-system" - "linux-module-build-system" - "maven-build-system" - "meson-build-system" - "minify-build-system" - "node-build-system" - "ocaml-build-system" - "perl-build-system" - "python-build-system" - "qt-build-system" - "r-build-system" - "rakudo-build-system" - "ruby-build-system" - "scons-build-system" - "texlive-build-system" - "trivial-build-system" - "waf-build-system")}) - (home-page "$4") - (synopsis "$5") - (description "$6") - (license $7))) \ No newline at end of file diff --git a/etc/snippets/scheme-mode/guix-svn-reference b/etc/snippets/scheme-mode/guix-svn-reference deleted file mode 100644 index 7d897dc690..0000000000 --- a/etc/snippets/scheme-mode/guix-svn-reference +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-svn-reference -# key: svn-reference... -# -- -(svn-reference - (url "$1") - (revision ${2:svn-revision})) \ No newline at end of file diff --git a/etc/snippets/tempel/scheme-mode b/etc/snippets/tempel/scheme-mode new file mode 100644 index 0000000000..74157e098a --- /dev/null +++ b/etc/snippets/tempel/scheme-mode @@ -0,0 +1,80 @@ +-*- mode: lisp-data -*- + +scheme-mode + +(package... + "(define-public " (s name) + n> "(package" + n > "(name \"" (s name) "\")" + n > "(version \"" p "\")" + n > "(source origin...)" + n > "(build-system " (p "gnu") "-build-system)" + n > "(home-page \"" p "\")" + n > "(synopsis \"" p "\")" + n > "(description \"" p "\")" + n > "(license license:" (p "unknown") ")))" n) + +(origin... + "(origin" + n> "(method " (p "url-fetch" method) ")" + n> "(uri " (cl-case (and method (intern method)) + ('git-fetch "git-reference...") + ('svn-fetch "svn-reference...") + ('hg-fetch "hg-reference...") + ('cvs-fetch "cvs-reference...") + ('bzr-fetch "bzr-reference...") + (t "\"https://...\"")) + ")" + n> + (cl-case (and method (intern method)) + ('git-fetch + (insert "(file-name (git-file-name name version))") + (newline) + (indent-according-to-mode)) + ('hg-fetch + (insert "(file-name (hg-file-name name version))") + (newline) + (indent-according-to-mode)) + ('svn-fetch + (insert "(file-name (string-append name \"-\" version \"-checkout\"))") + (newline) + (indent-according-to-mode)) + ('cvs-fetch + (insert "(file-name (string-append name \"-\" version \"-checkout\"))") + (newline) + (indent-according-to-mode)) + ('bzr-fetch + (insert "(file-name (string-append name \"-\" version \"-checkout\"))") + (newline) + (indent-according-to-mode)) + (t "")) + > "(sha256" + n > "(base32 \"" + ;; hash of an empty directory + (p "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5") "\")))") + +(git-reference... + "(git-reference" + n> "(url \"" p "\")" + n> "(commit \"" p "\"))") + +(svn-reference... + "(svn-reference" + n> "(url \"" p "\")" + n> "(revision \"" p "\"))") + +(cvs-reference... + "(cvs-reference" + n> "(root-directory \"" p "\")" + n> "(module \"" p "\")" + n> "(revision \"" p "\"))") + +(hg-reference... + "(hg-reference" + n> "(url \"" p "\")" + n> "(changeset \"" p "\"))") + +(bzr-reference... + "(bzr-reference" + n> "(url \"" p "\")" + n> "(revision \"" p "\"))") diff --git a/etc/snippets/tempel/text-mode b/etc/snippets/tempel/text-mode new file mode 100644 index 0000000000..a1400aac69 --- /dev/null +++ b/etc/snippets/tempel/text-mode @@ -0,0 +1,101 @@ +-*- mode: lisp-data -*- + +text-mode :when (and (fboundp 'git-commit-mode) (git-commit-mode)) + +(add\ + "gnu: Add " + (p + (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (when (re-search-forward "\\+(define-public \\(\\S-+\\)" nil 'noerror) + (match-string-no-properties 1))) + var ) "." n n + "* " (car (magit-staged-files)) " (" (s var ) "): New variable.") + +(remove\ + "gnu: Remove " + (p (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (when (re-search-forward "\\-(define-public \\(\\S-+\\)" nil 'noerror) + (match-string-no-properties 1))) + var) "." n n + "* " (car (magit-staged-files)) " (" (s var) "): Delete variable.") + +(rename\ + "gnu: " + (p (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (when (search-forward "-(define-public " nil 'noerror) + (thing-at-point 'sexp 'no-properties))) + prev-var) + ": Rename package to " + (p (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (when (search-forward "+(define-public " nil 'noerror) + (thing-at-point 'sexp 'no-properties))) + new-var) "." n n + "* " (car (magit-staged-files)) " (" (s prev-var) "): Define in terms of" n + "'deprecated-package'." n + "(" (s new-var) "): New variable, formerly known as \"" (s prev-var) "\".") + +(update\ + "gnu: " + (p (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)" nil 'noerror) + (match-string-no-properties 1))) + var) + ": Update to " + (p (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (search-forward "name" nil 'noerror) + (search-forward "+" nil 'noerror) ; first change + (when (and (search-forward "version " nil 'noerror) + (looking-at-p "\"")) + (let ((end (save-excursion (search-forward "\")" nil 'noerror)))) + (when end + (forward-char) + (buffer-substring-no-properties (point) (- end 2)))))) + version) "." n n + "* " (car (magit-staged-files)) " (" (s var) "): Update to " (s version) "." + (mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files))) n) + +(addcl\ + "gnu: Add cl-" + (p (replace-regexp-in-string + "^cl-" "" (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (when (search-forward "+(define-public " nil 'noerror) + (replace-regexp-in-string + "^sbcl-" "" + (thing-at-point 'sexp 'no-properties))))) + var) "." n n + "* " (car (magit-staged-files)) + " (cl-" (s var) ", ecl-" (s var) ", sbcl-" (s var) "): New variables.") + +(https\ + "gnu: " + (p (with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)" nil 'noerror) + (match-string-no-properties 1))) + var) + ": Use HTTPS home page." n n + "* " (car (magit-staged-files)) " (" (s var) ")[home-page]: Use HTTPS." n + (mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files))) n) diff --git a/etc/snippets/text-mode/guix-commit-message-add-cl-package b/etc/snippets/text-mode/guix-commit-message-add-cl-package deleted file mode 100644 index e255736b05..0000000000 --- a/etc/snippets/text-mode/guix-commit-message-add-cl-package +++ /dev/null @@ -1,15 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-commit-message-add-cl-package -# key: addcl -# condition: git-commit-mode -# -- -gnu: Add ${1:`(with-temp-buffer - (magit-git-wash #'magit-diff-wash-diffs - "diff" "--staged") - (beginning-of-buffer) - (when (search-forward "+(define-public " nil 'noerror) - (replace-regexp-in-string - "^sbcl-" "" - (thing-at-point 'sexp 'no-properties))))`}. - -* `(car (magit-staged-files))` (cl-${1:$(replace-regexp-in-string "^cl-" "" yas-text)}, ecl-$1, sbcl-$1): New variables. \ No newline at end of file diff --git a/etc/snippets/text-mode/guix-commit-message-add-package b/etc/snippets/text-mode/guix-commit-message-add-package deleted file mode 100644 index 7cebd4023a..0000000000 --- a/etc/snippets/text-mode/guix-commit-message-add-package +++ /dev/null @@ -1,13 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-commit-message-add-package -# key: add -# condition: git-commit-mode -# -- -gnu: Add ${1:`(with-temp-buffer - (magit-git-wash #'magit-diff-wash-diffs - "diff" "--staged") - (goto-char (point-min)) - (when (re-search-forward "\\+(define-public \\(\\S-+\\)" nil 'noerror) - (match-string-no-properties 1)))`}. - -* `(car (magit-staged-files))` ($1): New variable. \ No newline at end of file diff --git a/etc/snippets/text-mode/guix-commit-message-remove-package b/etc/snippets/text-mode/guix-commit-message-remove-package deleted file mode 100644 index 0c1050f4fe..0000000000 --- a/etc/snippets/text-mode/guix-commit-message-remove-package +++ /dev/null @@ -1,13 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-commit-message-remove-package -# key: remove -# condition: git-commit-mode -# -- -gnu: Remove ${1:`(with-temp-buffer - (magit-git-wash #'magit-diff-wash-diffs - "diff" "--staged") - (goto-char (point-min)) - (when (re-search-forward "\\-(define-public \\(\\S-+\\)" nil 'noerror) - (match-string-no-properties 1)))`}. - -* `(car (magit-staged-files))` ($1): Delete variable. diff --git a/etc/snippets/text-mode/guix-commit-message-rename-package b/etc/snippets/text-mode/guix-commit-message-rename-package deleted file mode 100644 index 9695ca1b3d..0000000000 --- a/etc/snippets/text-mode/guix-commit-message-rename-package +++ /dev/null @@ -1,20 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-commit-message-rename-package -# key: rename -# condition: git-commit-mode -# -- -gnu: ${1:`(with-temp-buffer - (magit-git-wash #'magit-diff-wash-diffs - "diff" "--staged") - (beginning-of-buffer) - (when (search-forward "-(define-public " nil 'noerror) - (thing-at-point 'sexp 'no-properties)))`}: Rename package to ${2:`(with-temp-buffer - (magit-git-wash #'magit-diff-wash-diffs - "diff" "--staged") - (beginning-of-buffer) - (when (search-forward "+(define-public " nil 'noerror) - (thing-at-point 'sexp 'no-properties)))`}. - -* `(car (magit-staged-files))` ($1): Define in terms of -'deprecated-package'. -($2): New variable, formerly known as "$1". \ No newline at end of file diff --git a/etc/snippets/text-mode/guix-commit-message-update-package b/etc/snippets/text-mode/guix-commit-message-update-package deleted file mode 100644 index b08df74a0b..0000000000 --- a/etc/snippets/text-mode/guix-commit-message-update-package +++ /dev/null @@ -1,26 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-commit-message-update-package -# key: update -# condition: git-commit-mode -# -- - -gnu: ${1:`(with-temp-buffer - (magit-git-wash #'magit-diff-wash-diffs - "diff" "--staged") - (goto-char (point-min)) - (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)" nil 'noerror) - (match-string-no-properties 1)))`}: Update to ${2:`(with-temp-buffer - (magit-git-wash #'magit-diff-wash-diffs - "diff" "--staged") - (goto-char (point-min)) - (search-forward "name" nil 'noerror) - (search-forward "+" nil 'noerror) ; first change - (when (and (search-forward "version " nil 'noerror) - (looking-at-p "\"")) - (let ((end (save-excursion (search-forward "\")" nil 'noerror)))) - (when end - (forward-char) - (buffer-substring-no-properties (point) (- end 2))))))`}. - -* `(car (magit-staged-files))` ($1): Update to $2.$0 -`(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")` \ No newline at end of file diff --git a/etc/snippets/text-mode/guix-commit-message-use-https-home-page b/etc/snippets/text-mode/guix-commit-message-use-https-home-page deleted file mode 100644 index df20d31a80..0000000000 --- a/etc/snippets/text-mode/guix-commit-message-use-https-home-page +++ /dev/null @@ -1,9 +0,0 @@ -# -*- mode: snippet -*- -# name: guix-commit-message-use-https-home-page -# key: https -# condition: git-commit-mode -# -- -gnu: $1: Use HTTPS home page URI. - -* `(car (magit-staged-files))` ($1)[home-page]: Use HTTPS URI. -`(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")` \ No newline at end of file diff --git a/etc/snippets/yas/scheme-mode/guix-bzr-reference b/etc/snippets/yas/scheme-mode/guix-bzr-reference new file mode 100644 index 0000000000..a801cc36f2 --- /dev/null +++ b/etc/snippets/yas/scheme-mode/guix-bzr-reference @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: guix-bzr-reference +# key: bzr-reference... +# -- +(bzr-reference + (url "$1") + (revision ${2:ref})) \ No newline at end of file diff --git a/etc/snippets/yas/scheme-mode/guix-cvs-reference b/etc/snippets/yas/scheme-mode/guix-cvs-reference new file mode 100644 index 0000000000..fbc5034b66 --- /dev/null +++ b/etc/snippets/yas/scheme-mode/guix-cvs-reference @@ -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}")) \ No newline at end of file diff --git a/etc/snippets/yas/scheme-mode/guix-git-reference b/etc/snippets/yas/scheme-mode/guix-git-reference new file mode 100644 index 0000000000..29ca6a9c54 --- /dev/null +++ b/etc/snippets/yas/scheme-mode/guix-git-reference @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: guix-git-reference +# key: git-reference... +# -- +(git-reference + (url "$1") + (commit ${2:commit})) \ No newline at end of file diff --git a/etc/snippets/yas/scheme-mode/guix-hg-reference b/etc/snippets/yas/scheme-mode/guix-hg-reference new file mode 100644 index 0000000000..95de16daae --- /dev/null +++ b/etc/snippets/yas/scheme-mode/guix-hg-reference @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: guix-hg-reference +# key: hg-reference... +# -- +(hg-reference + (url "$1") + (changeset ${2:changeset})) \ No newline at end of file diff --git a/etc/snippets/yas/scheme-mode/guix-origin b/etc/snippets/yas/scheme-mode/guix-origin new file mode 100644 index 0000000000..eb0cdc8242 --- /dev/null +++ b/etc/snippets/yas/scheme-mode/guix-origin @@ -0,0 +1,29 @@ +# -*- 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" + "bzr-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...") + ((equal yas-text "bzr-fetch") "bzr-reference...") + (t "(string-append \\"https://\\" version \\".tar.gz\\")"))}$0) + ${1:$(cond ((equal yas-text "git-fetch") + "(file-name (git-file-name name version))") + ((equal yas-text "hg-fetch") + "(file-name (hg-file-name name version))") + ((member yas-text '("svn-fetch" "cvs-fetch" "bzr-fetch")) + "(file-name (string-append name \\"-\\" version \\"-checkout\\"))") + (t ""))} + (sha256 + (base32 + "$2"))) \ No newline at end of file diff --git a/etc/snippets/yas/scheme-mode/guix-package b/etc/snippets/yas/scheme-mode/guix-package new file mode 100644 index 0000000000..9ff6f997d1 --- /dev/null +++ b/etc/snippets/yas/scheme-mode/guix-package @@ -0,0 +1,46 @@ +# -*- mode: snippet -*- +# name: guix-package +# key: package... +# -- +(define-public $1 + (package + (name "$1") + (version "$2") + (source origin...$0) + (build-system ${3:$$(yas-choose-value "android-ndk-build-system" + "ant-build-system" + "asdf-build-system" + "cargo-build-system" + "clojure-build-system" + "cmake-build-system" + "copy-build-system" + "dub-build-system" + "dune-build-system" + "emacs-build-system" + "font-build-system" + "glib-or-gtk-build-system" + "gnu-build-system" + "go-build-system" + "guile-build-system" + "haskell-build-system" + "julia-build-system" + "linux-module-build-system" + "maven-build-system" + "meson-build-system" + "minify-build-system" + "node-build-system" + "ocaml-build-system" + "perl-build-system" + "python-build-system" + "qt-build-system" + "r-build-system" + "rakudo-build-system" + "ruby-build-system" + "scons-build-system" + "texlive-build-system" + "trivial-build-system" + "waf-build-system")}) + (home-page "$4") + (synopsis "$5") + (description "$6") + (license $7))) \ No newline at end of file diff --git a/etc/snippets/yas/scheme-mode/guix-svn-reference b/etc/snippets/yas/scheme-mode/guix-svn-reference new file mode 100644 index 0000000000..7d897dc690 --- /dev/null +++ b/etc/snippets/yas/scheme-mode/guix-svn-reference @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: guix-svn-reference +# key: svn-reference... +# -- +(svn-reference + (url "$1") + (revision ${2:svn-revision})) \ No newline at end of file diff --git a/etc/snippets/yas/text-mode/guix-commit-message-add-cl-package b/etc/snippets/yas/text-mode/guix-commit-message-add-cl-package new file mode 100644 index 0000000000..e255736b05 --- /dev/null +++ b/etc/snippets/yas/text-mode/guix-commit-message-add-cl-package @@ -0,0 +1,15 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-add-cl-package +# key: addcl +# condition: git-commit-mode +# -- +gnu: Add ${1:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (when (search-forward "+(define-public " nil 'noerror) + (replace-regexp-in-string + "^sbcl-" "" + (thing-at-point 'sexp 'no-properties))))`}. + +* `(car (magit-staged-files))` (cl-${1:$(replace-regexp-in-string "^cl-" "" yas-text)}, ecl-$1, sbcl-$1): New variables. \ No newline at end of file diff --git a/etc/snippets/yas/text-mode/guix-commit-message-add-package b/etc/snippets/yas/text-mode/guix-commit-message-add-package new file mode 100644 index 0000000000..7cebd4023a --- /dev/null +++ b/etc/snippets/yas/text-mode/guix-commit-message-add-package @@ -0,0 +1,13 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-add-package +# key: add +# condition: git-commit-mode +# -- +gnu: Add ${1:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (when (re-search-forward "\\+(define-public \\(\\S-+\\)" nil 'noerror) + (match-string-no-properties 1)))`}. + +* `(car (magit-staged-files))` ($1): New variable. \ No newline at end of file diff --git a/etc/snippets/yas/text-mode/guix-commit-message-remove-package b/etc/snippets/yas/text-mode/guix-commit-message-remove-package new file mode 100644 index 0000000000..0c1050f4fe --- /dev/null +++ b/etc/snippets/yas/text-mode/guix-commit-message-remove-package @@ -0,0 +1,13 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-remove-package +# key: remove +# condition: git-commit-mode +# -- +gnu: Remove ${1:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (when (re-search-forward "\\-(define-public \\(\\S-+\\)" nil 'noerror) + (match-string-no-properties 1)))`}. + +* `(car (magit-staged-files))` ($1): Delete variable. diff --git a/etc/snippets/yas/text-mode/guix-commit-message-rename-package b/etc/snippets/yas/text-mode/guix-commit-message-rename-package new file mode 100644 index 0000000000..9695ca1b3d --- /dev/null +++ b/etc/snippets/yas/text-mode/guix-commit-message-rename-package @@ -0,0 +1,20 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-rename-package +# key: rename +# condition: git-commit-mode +# -- +gnu: ${1:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (when (search-forward "-(define-public " nil 'noerror) + (thing-at-point 'sexp 'no-properties)))`}: Rename package to ${2:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (beginning-of-buffer) + (when (search-forward "+(define-public " nil 'noerror) + (thing-at-point 'sexp 'no-properties)))`}. + +* `(car (magit-staged-files))` ($1): Define in terms of +'deprecated-package'. +($2): New variable, formerly known as "$1". \ No newline at end of file diff --git a/etc/snippets/yas/text-mode/guix-commit-message-update-package b/etc/snippets/yas/text-mode/guix-commit-message-update-package new file mode 100644 index 0000000000..b08df74a0b --- /dev/null +++ b/etc/snippets/yas/text-mode/guix-commit-message-update-package @@ -0,0 +1,26 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-update-package +# key: update +# condition: git-commit-mode +# -- + +gnu: ${1:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)" nil 'noerror) + (match-string-no-properties 1)))`}: Update to ${2:`(with-temp-buffer + (magit-git-wash #'magit-diff-wash-diffs + "diff" "--staged") + (goto-char (point-min)) + (search-forward "name" nil 'noerror) + (search-forward "+" nil 'noerror) ; first change + (when (and (search-forward "version " nil 'noerror) + (looking-at-p "\"")) + (let ((end (save-excursion (search-forward "\")" nil 'noerror)))) + (when end + (forward-char) + (buffer-substring-no-properties (point) (- end 2))))))`}. + +* `(car (magit-staged-files))` ($1): Update to $2.$0 +`(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")` \ No newline at end of file diff --git a/etc/snippets/yas/text-mode/guix-commit-message-use-https-home-page b/etc/snippets/yas/text-mode/guix-commit-message-use-https-home-page new file mode 100644 index 0000000000..df20d31a80 --- /dev/null +++ b/etc/snippets/yas/text-mode/guix-commit-message-use-https-home-page @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: guix-commit-message-use-https-home-page +# key: https +# condition: git-commit-mode +# -- +gnu: $1: Use HTTPS home page URI. + +* `(car (magit-staged-files))` ($1)[home-page]: Use HTTPS URI. +`(mapconcat (lambda (file) (concat "* " file)) (cdr (magit-staged-files)) "\n")` \ No newline at end of file -- cgit 1.4.1