emacs: enable yasnippet globally and add a couple of snippets
authorAmin Bandali <bandali@gnu.org>
Sat, 25 May 2019 22:41:22 +0000 (18:41 -0400)
committerAmin Bandali <bandali@gnu.org>
Sat, 25 May 2019 22:41:22 +0000 (18:41 -0400)
.emacs.d/etc/yasnippet/snippets/java-mode/format [new file with mode: 0644]
.emacs.d/etc/yasnippet/snippets/java-mode/new [new file with mode: 0644]
.emacs.d/etc/yasnippet/snippets/java-mode/printf [new file with mode: 0644]
.emacs.d/etc/yasnippet/snippets/java-mode/println [new file with mode: 0644]
.emacs.d/etc/yasnippet/snippets/java-mode/return [new file with mode: 0644]
.emacs.d/init.el

diff --git a/.emacs.d/etc/yasnippet/snippets/java-mode/format b/.emacs.d/etc/yasnippet/snippets/java-mode/format
new file mode 100644 (file)
index 0000000..7620366
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: String.format
+# key: f
+# --
+String.format("$1${2:%n}");$0
\ No newline at end of file
diff --git a/.emacs.d/etc/yasnippet/snippets/java-mode/new b/.emacs.d/etc/yasnippet/snippets/java-mode/new
new file mode 100644 (file)
index 0000000..1ffd2e5
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: new
+# key: new
+# --
+${1:Type} ${2:obj} = new ${3:Constr}(${4:args});$0
\ No newline at end of file
diff --git a/.emacs.d/etc/yasnippet/snippets/java-mode/printf b/.emacs.d/etc/yasnippet/snippets/java-mode/printf
new file mode 100644 (file)
index 0000000..eac39a1
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: printf
+# key: pf
+# --
+System.out.printf("$1${2:%n}");$0
\ No newline at end of file
diff --git a/.emacs.d/etc/yasnippet/snippets/java-mode/println b/.emacs.d/etc/yasnippet/snippets/java-mode/println
new file mode 100644 (file)
index 0000000..7bb944c
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: println
+# key: p
+# --
+System.out.println($1);$0
\ No newline at end of file
diff --git a/.emacs.d/etc/yasnippet/snippets/java-mode/return b/.emacs.d/etc/yasnippet/snippets/java-mode/return
new file mode 100644 (file)
index 0000000..977859e
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- mode: snippet -*-
+# name: return
+# key: r
+# --
+return $1;$0
\ No newline at end of file
index e236f40..42b2c79 100644 (file)
@@ -1508,11 +1508,10 @@ For disabling the behaviour for certain buffers and/or modes."
   :config
   (defconst yas-verbosity-cur yas-verbosity)
   (setq yas-verbosity 2)
-  (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets")
+  (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t)
   (yas-reload-all)
   (setq yas-verbosity yas-verbosity-cur)
-  :hook
-  (text-mode . yas-minor-mode))
+  (yas-global-mode))
 
 (use-package debbugs
   :straight (debbugs