Skip to content
Browse files

Added yasnippet.

  • Loading branch information...
1 parent 7f0dd40 commit a20fd2d783afdc1cadf36cea2c945ad681dff1f7 @martinbalfanz committed
Showing with 52 additions and 0 deletions.
  1. +4 −0 .gitmodules
  2. +47 −0 init.el
  3. +1 −0 site-lisp/yasnippet
View
4 .gitmodules
@@ -90,3 +90,7 @@
path = site-lisp/diminish
url = https://github.com/emacsmirror/diminish.git
ignore = dirty
+[submodule "site-lisp/yasnippet"]
+ path = site-lisp/yasnippet
+ url = https://github.com/capitaomorte/yasnippet.git
+ ignore = dirty
View
47 init.el
@@ -713,6 +713,53 @@ prevents using commands with prefix arguments."
;;;;
+;;;; yasnippet
+;;;; some parts from https://github.com/jwiegley/dot-emacs/blob/master/init.el
+;;;;
+
+(use-package yasnippet
+ :if (not noninteractive)
+ :load-path "yasnippet"
+ :commands (yas/minor-mode
+ yas/expand)
+ :mode ("/emacs-config/snippets/" . snippet-mode)
+ :init
+ (progn
+ (mapc (lambda (hook) (add-hook hook (lambda () (yas/minor-mode 1))))
+ '(css-mode-hook
+ html-mode-hook
+ js2-mode-hook)))
+ :config
+ (progn
+ (yas/load-directory (expand-file-name "yasnippet/snippets" user-emacs-directory))
+ ;; (yas/load-directory (expand-file-name "snippets/" user-init-directory))
+
+ (setq yas/prompt-functions '(yas/dropdown-prompt yas/ido-prompt))
+
+ (defun yas/new-snippet (&optional choose-instead-of-guess)
+ (interactive "P")
+ (let ((guessed-directories (yas/guess-snippet-directories)))
+ (switch-to-buffer "*new snippet*")
+ (erase-buffer)
+ (kill-all-local-variables)
+ (snippet-mode)
+ (set (make-local-variable 'yas/guessed-modes)
+ (mapcar #'(lambda (d)
+ (intern (yas/table-name (car d))))
+ guessed-directories))
+ (unless (and choose-instead-of-guess
+ (not (y-or-n-p "Insert a snippet with useful headers? ")))
+ (yas/expand-snippet "\n# -*- mode: snippet -*-\n# name: $1\n# --\n$0"))))
+
+ (bind-key "<tab>" 'yas/next-field-or-maybe-expand yas/keymap)
+ (bind-key "C-c y TAB" 'yas/expand)
+ (bind-key "C-c y n" 'yas/new-snippet)
+ (bind-key "C-c y f" 'yas/find-snippets)
+ (bind-key "C-c y r" 'yas/reload-all)
+ (bind-key "C-c y v" 'yas/visit-snippet-file)))
+
+
+;;;;
;;;; zencoding
;;;;
1 site-lisp/yasnippet
@@ -0,0 +1 @@
+Subproject commit 9503c332f552e874899ea0ce7801516d4b30bba2

0 comments on commit a20fd2d

Please sign in to comment.
Something went wrong with that request. Please try again.