]> code.delx.au - gnu-emacs-elpa/commitdiff
Make default snippet customizable
authorthisirs <thisirs@gmail.com>
Sun, 4 Aug 2013 22:26:49 +0000 (00:26 +0200)
committerthisirs <thisirs@gmail.com>
Tue, 20 Aug 2013 15:19:35 +0000 (17:19 +0200)
yasnippet.el

index f44a994ba99f0c719cda7546011de51c4097371e..0a94ffb006cff0a718d766808fe89c720a4af1d2 100644 (file)
@@ -187,6 +187,19 @@ as the default for storing the user's new snippets."
 
 (defvaralias 'yas/root-directory 'yas-snippet-dirs)
 
+(defcustom yas-new-snippet-default "\
+# -*- mode: snippet -*-
+# name: $1
+# key: ${2:${1:$(replace-regexp-in-string \"\\\\\\\\(\\\\\\\\w+\\\\\\\\).*\" \"\\\\\\\\1\" yas-text)}}${3:
+# binding: ${4:direct-keybinding}}${5:
+# expand-env: ((${6:some-var} ${7:some-value}))}${8:
+# type: command}
+# --
+$0"
+  "Default snippet to use when creating a new snippet."
+  :type 'string
+  :group 'yasnippet)
+
 (defcustom yas-prompt-functions '(yas-x-prompt
                                   yas-dropdown-prompt
                                   yas-completing-prompt
@@ -2514,15 +2527,7 @@ NO-TEMPLATE is non-nil."
     (set (make-local-variable 'yas--guessed-modes) (mapcar #'(lambda (d)
                                                               (yas--table-mode (car d)))
                                                           guessed-directories))
-    (unless no-template (yas-expand-snippet "\
-# -*- mode: snippet -*-
-# name: $1
-# key: ${2:${1:$(replace-regexp-in-string \"\\\\\\\\(\\\\\\\\w+\\\\\\\\).*\" \"\\\\\\\\1\" yas-text)}}${3:
-# binding: ${4:direct-keybinding}}${5:
-# expand-env: ((${6:some-var} ${7:some-value}))}${8:
-# type: command}
-# --
-$0"))))
+    (unless no-template (yas-expand-snippet yas-new-snippet-default))))
 
 (defun yas--compute-major-mode-and-parents (file)
   "Given FILE, find the nearest snippet directory for a given mode.