From 6f79151a2a5c67199335c0efa824f30bab630d16 Mon Sep 17 00:00:00 2001 From: "Nicolas G. Querol" Date: Fri, 11 May 2012 18:51:19 +0200 Subject: [PATCH 01/46] added octopress snippets for markdown files --- snippets/markdown.snippets | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/snippets/markdown.snippets b/snippets/markdown.snippets index b69e135..e0a614f 100644 --- a/snippets/markdown.snippets +++ b/snippets/markdown.snippets @@ -1,5 +1,7 @@ # Markdown +# Includes octopress (http://octopress.org/) snippets + snippet [ [${1:text}](http://${2:address} "${3:title}") snippet [* @@ -28,3 +30,50 @@ snippet --- `repeat('-', strlen(getline(line(".") - 1)))` ${1} + +snippet blockquote + {% blockquote %} + ${1:quote} + {% endblockquote %} + +snippet blockquote-author + {% blockquote ${1:author}, ${2:title} %} + ${3:quote} + {% endblockquote %} + +snippet blockquote-link + {% blockquote ${1:author} ${2:URL} ${3:link_text} %} + ${4:quote} + {% endblockquote %} + +snippet bt-codeblock-short + ``` + ${1:code_snippet} + ``` + +snippet bt-codeblock-full + ``` ${1:language} ${2:title} ${3:URL} ${4:link_text} + ${5:code_snippet} + ``` + +snippet codeblock-short + {% codeblock %} + ${1:code_snippet} + {% endcodeblock %} + +snippet codeblock-full + {% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %} + ${5:code_snippet} + {% endcodeblock %} + +snippet gist-full + {% gist ${1:gist_id} ${2:filename} %} + +snippet gist-short + {% gist ${1:gist_id} %} + +snippet img + {% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${6:alt_text} %} + +snippet youtube + {% youtube ${1:video_id} %} From adfd3f4ab80966e6b024770410ba6eb175e9959d Mon Sep 17 00:00:00 2001 From: "Nicolas G. Querol" Date: Sat, 12 May 2012 02:30:24 +0200 Subject: [PATCH 02/46] added pullquote snippet --- snippets/markdown.snippets | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/snippets/markdown.snippets b/snippets/markdown.snippets index e0a614f..e4efd3c 100644 --- a/snippets/markdown.snippets +++ b/snippets/markdown.snippets @@ -77,3 +77,11 @@ snippet img snippet youtube {% youtube ${1:video_id} %} + +# The quote should appear only once in the text. It is inherently part of it. +# See http://octopress.org/docs/plugins/pullquote/ for more info. + +snippet pullquote + {% pullquote %} + ${1:text} {" ${2:quote} "} ${3:text} + {% endpullquote %} From 8f7419c9d00b180c88a4a37f084ba550c40b83c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Vatn?= Date: Wed, 16 May 2012 12:49:23 +0200 Subject: [PATCH 03/46] First go at adding clojure support --- snippets/clojure.snippets | 74 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 snippets/clojure.snippets diff --git a/snippets/clojure.snippets b/snippets/clojure.snippets new file mode 100644 index 0000000..f476168 --- /dev/null +++ b/snippets/clojure.snippets @@ -0,0 +1,74 @@ +snippet comm + (comment + ${1} + ) +snippet condp + (condp ${1:pred} ${2:expr} + ${3}) +snippet def + (def ${1}) +snippet defm + (defmethod ${1:name} ${2:match} [${3:args}] + ${4}) +snippet defmm + (defmulti ${1:name} ${2:dispatch-fn}) +snippet defn + (defn ${1:name} ${2:"${3:doc-string}"}[${4:arg-list}] + ${5}) +snippet defp + (defprotocol ${1:name} + ${2}) +snippet defr + (defrecord ${1:name} [${2:fields}] + ${3:protocol} + ${4}) +snippet deft + (deftest ${1:name} + (is (= ${2:assertion}))) + ${3}) +snippet is + (is (= ${1} ${2})) +snippet defty + (deftype ${1:Name} [${2:fields}] + ${3:Protocol} + ${4}) +snippet doseq + (doseq [${1:elem} ${2:coll}] + ${3}) +snippet fn + (fn [${1:arg-list}] ${2}) +snippet if + (if ${1:test-expr} + ${2:then-expr} + ${3:else-expr}) +snippet imp + (:import [${1:package}]) + & {:keys [${1:keys}] :or {${2:defaults}}} +snippet let + (let [${1}]) +snippet letfn + (letfn [(${1:name) [${2:args}] + ${3})]) +snippet map + (map ${1:func} ${2:coll}) +snippet mapl + (map #(${1:lambda}) ${2:coll}) +snippet met + (${1:name} [${2:this} ${3:args}] + ${4}) +snippet ns + (ns ${1:name} + ${2}) +snippet dotimes + (dotimes [_ 10] + (time + (dotimes [_ ${1:times}] + ${2}))) +snippet pmethod + (${1:name} [${2:this} ${3:args}]) +snippet refer + (:refer-clojure :exclude [${1}]) +snippet req + (:require [${1:namespace} :as [${2}]]) +snippet use + (:use [${1:namespace} :only [${2}]]) From 37a7869d0a993a3811a65ab7dab854b21e45e928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Vatn?= Date: Wed, 16 May 2012 13:39:20 +0200 Subject: [PATCH 04/46] Small cleanups to clojure.snippet --- snippets/clojure.snippets | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/snippets/clojure.snippets b/snippets/clojure.snippets index f476168..d0c6267 100644 --- a/snippets/clojure.snippets +++ b/snippets/clojure.snippets @@ -8,13 +8,15 @@ snippet condp snippet def (def ${1}) snippet defm - (defmethod ${1:name} ${2:match} [${3:args}] - ${4}) -snippet defmm - (defmulti ${1:name} ${2:dispatch-fn}) -snippet defn - (defn ${1:name} ${2:"${3:doc-string}"}[${4:arg-list}] + (defmethod ${1:name} "${2:doc-string}" ${3:match} [${4:args}] ${5}) +snippet defmm + (defmulti ${1:name} "${2:doc-string}" ${3:dispatch-fn}) +snippet defma + (defmacro ${1:name} "${2:doc-string}" ${3:dispatch-fn}) +snippet defn + (defn ${1:name} "${2:doc-string}" [${3:arg-list}] + ${4}) snippet defp (defprotocol ${1:name} ${2}) @@ -41,11 +43,16 @@ snippet if (if ${1:test-expr} ${2:then-expr} ${3:else-expr}) +snippet if-let + (if-let [${1:result} ${2:test-expr}] + (${3:then-expr} $1) + (${4:else-expr})) snippet imp (:import [${1:package}]) & {:keys [${1:keys}] :or {${2:defaults}}} snippet let - (let [${1}]) + (let [${1:name} ${2:expr}] + ${3}) snippet letfn (letfn [(${1:name) [${2:args}] ${3})]) @@ -68,7 +75,16 @@ snippet pmethod (${1:name} [${2:this} ${3:args}]) snippet refer (:refer-clojure :exclude [${1}]) -snippet req +snippet require (:require [${1:namespace} :as [${2}]]) snippet use (:use [${1:namespace} :only [${2}]]) +snippet print + (println ${1}) +snippet reduce + (reduce ${1:(fn [p n] ${3})} ${2}) +snippet when + (when ${1:test} ${2:body}) +snippet when-let + (when-let [${1:result} ${2:test}] + ${3:body}) From 5e83faeed004820511a84c2cbabc184528d6d91d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Vatn?= Date: Wed, 16 May 2012 19:44:15 +0200 Subject: [PATCH 05/46] Small fix of defmethod --- snippets/clojure.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/clojure.snippets b/snippets/clojure.snippets index d0c6267..e247deb 100644 --- a/snippets/clojure.snippets +++ b/snippets/clojure.snippets @@ -8,7 +8,7 @@ snippet condp snippet def (def ${1}) snippet defm - (defmethod ${1:name} "${2:doc-string}" ${3:match} [${4:args}] + (defmethod ${1:multifn} "${2:doc-string}" ${3:dispatch-val} [${4:args}] ${5}) snippet defmm (defmulti ${1:name} "${2:doc-string}" ${3:dispatch-fn}) From 273bd9197a21ee9362876988d12ea76b9ebc27c3 Mon Sep 17 00:00:00 2001 From: Steven Oliver Date: Sat, 19 May 2012 21:00:06 -0400 Subject: [PATCH 06/46] Remove licenses since they're now in the global snippets --- snippets/falcon.snippets | 64 ---------------------------------------- 1 file changed, 64 deletions(-) diff --git a/snippets/falcon.snippets b/snippets/falcon.snippets index 2d12df3..d8674a9 100644 --- a/snippets/falcon.snippets +++ b/snippets/falcon.snippets @@ -44,67 +44,3 @@ snippet while while ${1:conidition} ${2:/* code */} end - -#==================================== -# Common Licenses -#==================================== -# GPL -snippet gpl - /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version ${3:version} of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -# APLv2 -snippet apache - /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -# BSD -snippet bsd - /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ From 33972c2b4f5a60e3968a1e96a115998c60b48502 Mon Sep 17 00:00:00 2001 From: Steven Oliver Date: Sat, 19 May 2012 21:05:21 -0400 Subject: [PATCH 07/46] Add switch case and select statements --- snippets/falcon.snippets | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/snippets/falcon.snippets b/snippets/falcon.snippets index d8674a9..85fb918 100644 --- a/snippets/falcon.snippets +++ b/snippets/falcon.snippets @@ -1,23 +1,28 @@ snippet #! #!/usr/bin/env falcon + # Import snippet imp import ${1:module} + # Function snippet fun function ${2:function_name}(${3}) ${4:/* code */} end + # Class snippet class class ${1:class_name}(${2:class_params}) ${3:/* members/methods */} end + # If snippet if if ${1:condition} ${2:/* code */} end + # If else snippet ife if ${1:condition} @@ -25,20 +30,40 @@ snippet ife else ${1} end + # If else if snippet elif elif ${1:condition} ${2:/* code */} + +# Switch case +snippet switch + switch ${1:expression} + case ${2:item} + case ${3:item} + default + end + +# Select +snippet select + select ${1:variable} + case ${2:TypeSpec} + case ${3:TypeSpec} + default + end + # For/in Loop snippet forin for ${1:element} in ${2:container} ${3:/* code */} end + # For/to Loop snippet forto for ${1:lowerbound} to ${2:upperbound} ${3:/* code */} end + # While Loop snippet while while ${1:conidition} From 4123ca93606ba773b9c95121a7e099a744ec3879 Mon Sep 17 00:00:00 2001 From: Leandro Moreira Date: Mon, 21 May 2012 02:50:00 -0300 Subject: [PATCH 08/46] add one more snippet for junit 4 with @Test support. --- snippets/java.snippets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/java.snippets b/snippets/java.snippets index 784153d..6996782 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -65,6 +65,9 @@ snippet tc public class ${1:`Filename()`} extends ${2:TestCase} snippet t public void test${1:Name}() throws Exception ${2} +snippet test + @Test + public void test${1:Name}() throws Exception ${2} snippet cl class ${1:`Filename("", "untitled")`} ${2} snippet in From 5d11f493b70759e5ae1c0e855c7abeed787c984a Mon Sep 17 00:00:00 2001 From: Leandro Moreira Date: Mon, 21 May 2012 23:17:30 -0300 Subject: [PATCH 09/46] little refactoring over the test for junit4 and previous version --- snippets/java.snippets | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snippets/java.snippets b/snippets/java.snippets index 6996782..19a2420 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -64,10 +64,14 @@ snippet cs snippet tc public class ${1:`Filename()`} extends ${2:TestCase} snippet t - public void test${1:Name}() throws Exception ${2} + public void test${1:Name}() throws Exception { + ${2} + } snippet test @Test - public void test${1:Name}() throws Exception ${2} + public void test${1:Name}() throws Exception { + ${2} + } snippet cl class ${1:`Filename("", "untitled")`} ${2} snippet in From 54ed56d76f60012b080f92c9e270d7dad5440050 Mon Sep 17 00:00:00 2001 From: tormaroe Date: Wed, 23 May 2012 13:07:22 +0200 Subject: [PATCH 10/46] Added erlang fun snippet (anonymous function) --- snippets/erlang.snippets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index e44bf5e..9a85215 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -33,6 +33,9 @@ snippet case ${2:pattern} -> ${3:body}; end +# anonymous function +snippet fun + fun (${1:Parameters}) -> ${2:body} end${3} # record directive snippet rec -record(${1:record}, { From f121becfcb57b2162d47caaff2405fa4928c8167 Mon Sep 17 00:00:00 2001 From: tormaroe Date: Wed, 23 May 2012 13:08:13 +0200 Subject: [PATCH 11/46] Added erlang try snippet with a catch-all --- snippets/erlang.snippets | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index 9a85215..c9a43e5 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -36,6 +36,13 @@ snippet case # anonymous function snippet fun fun (${1:Parameters}) -> ${2:body} end${3} +# try...catch +snippet try + try + ${1} + catch + ${2:_:_} -> ${3:got_some_exception} + end # record directive snippet rec -record(${1:record}, { From debb550e1f1840bc4b231cc6256413059031f3bb Mon Sep 17 00:00:00 2001 From: tormaroe Date: Wed, 23 May 2012 13:39:38 +0200 Subject: [PATCH 12/46] Added OTP gen_server template following normal conventions --- snippets/erlang.snippets | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index c9a43e5..fb2b32b 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -64,3 +64,56 @@ snippet %s # private function marker snippet %p %% @private +# OTP gen_server +snippet gen_server + -module(${1:`Filename('', 'my')`}). + + -behaviour(gen_server). + + %% API + -export([ + start_link/0 + ]). + + %% gen_server callbacks + -export([init/1, handle_call/3, handle_cast/2, handle_info/2, + terminate/2, code_change/3]). + + -define(SERVER, ?MODULE). + + -record(state, {}). + + %%%=================================================================== + %%% API + %%%=================================================================== + + start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + + %%%=================================================================== + %%% gen_server callbacks + %%%=================================================================== + + init([]) -> + {ok, #state{}}. + + handle_call(_Request, _From, State) -> + Reply = ok, + {reply, Reply, State}. + + handle_cast(_Msg, State) -> + {noreply, State}. + + handle_info(_Info, State) -> + {noreply, State}. + + terminate(_Reason, _State) -> + ok. + + code_change(_OldVsn, State, _Extra) -> + {ok, State}. + + %%%=================================================================== + %%% Internal functions + %%%=================================================================== + From 6624937532fe89564cf9a0ee6e952cbf801d6e21 Mon Sep 17 00:00:00 2001 From: tormaroe Date: Wed, 23 May 2012 13:57:14 +0200 Subject: [PATCH 13/46] Added OTP application template following normal conventions --- snippets/erlang.snippets | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index fb2b32b..3770ef7 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -64,6 +64,24 @@ snippet %s # private function marker snippet %p %% @private +# OTP application +snippet application + -module(${1:`Filename('', 'my')`}). + + -behaviour(application). + + -export([start/2, stop/1]). + + start(_Type, _StartArgs) -> + case ${2:root_supervisor}:start_link() of + {ok, Pid} -> + {ok, Pid}; + Other -> + {error, Other} + end. + + stop(_State) -> + ok. # OTP gen_server snippet gen_server -module(${1:`Filename('', 'my')`}). From 5e48d7470cc767e7236f7c90b665ccb9f9f082ff Mon Sep 17 00:00:00 2001 From: tormaroe Date: Wed, 23 May 2012 14:09:22 +0200 Subject: [PATCH 14/46] Added OTP supervisor template following normal conventions --- snippets/erlang.snippets | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index 3770ef7..acc6fd1 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -82,6 +82,29 @@ snippet application stop(_State) -> ok. +# OTP supervisor +snippet supervisor + -module(${1:`Filename('', 'my')`}). + + -behaviour(supervisor). + + %% API + -export([start_link/0]). + + %% Supervisor callbacks + -export([init/1]). + + -define(SERVER, ?MODULE). + + start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + + init([]) -> + Server = {${2:my_server}, {$2, start_link, []}, + permanent, 2000, worker, [$2]}, + Children = [Server], + RestartStrategy = {one_for_one, 0, 1}, + {ok, {RestartStrategy, Children}}. # OTP gen_server snippet gen_server -module(${1:`Filename('', 'my')`}). From d5b89bc74b3acff2e4c236de8dd97f628d8d5051 Mon Sep 17 00:00:00 2001 From: Stephen Tudor Date: Mon, 28 May 2012 20:49:17 -0400 Subject: [PATCH 15/46] Fix mismatched closing tags for h3 --- snippets/html.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/html.snippets b/snippets/html.snippets index ca6bbcf..01374e5 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -387,9 +387,9 @@ snippet h2# snippet h3

${1}

snippet h3. -

${2}

+

${2}

snippet h3# -

${2}

+

${2}

snippet h4

${1}

snippet h4. From fd225cbb5c36af05191649d9d44dd58dc258498a Mon Sep 17 00:00:00 2001 From: Stephen Tudor Date: Thu, 31 May 2012 13:00:48 -0400 Subject: [PATCH 16/46] Initial version of jQuery snippets from akitaonrails/scrooloose fork --- snippets/javascript-jquery.snippets | 329 ++++++++++++++++++++++++++++ 1 file changed, 329 insertions(+) create mode 100644 snippets/javascript-jquery.snippets diff --git a/snippets/javascript-jquery.snippets b/snippets/javascript-jquery.snippets new file mode 100644 index 0000000..59f795e --- /dev/null +++ b/snippets/javascript-jquery.snippets @@ -0,0 +1,329 @@ +snippet add + ${1:obj}.add('${2:selector expression}')${3} +snippet addClass + ${1:obj}.addClass('${2:class name}')${3} +snippet after + ${1:obj}.after('${2:Some text and bold!}')${3} +snippet ajax + $.ajax({ + url: "${1:mydomain.com/url}", + type: "${2:POST}", + dataType: "${3:xml/html/script/json}", + data: $.param( $("${4:Element or Expression}") ), + + complete: function() { + ${5://called when complete} + }, + + success: function() { + ${6://called when successful} + }, + + error: function() { + ${7://called when there is an error} + }, + }); +snippet ajaxerror + .ajaxError(function(${1:request, settings}) { + ${2://stuff to do when an AJAX call returns an error}; + }); + ${3} +snippet ajaxget + $.get('${1:/test/ajax-test.xml}', function(xml){ + ${2:alert( ("title",xml).text() ) //optional stuff to do after get;} + }); +snippet ajaxgetif + $.getIfModified('${1:/test/test.cgi}', function(data){ + ${2:alert( "Data loaded: " + data ) //optional stuff to do after get;} + }); +snippet ajaxpost + $.post('<+/path/to/file.cgi+>',{ + <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+>}, + function(){ + <+//stuff to do after event occurs;+> + }); +snippet ajaxsend + .ajaxSend(function(${1:request, settings}) { + ${2://stuff to do when an AJAX call returns an error}; + }); + ${3} +snippet ajaxsetup + $.ajaxSetup({ + url: "${1:mydomain.com/url}", + type: "${2:POST}", + dataType: "${3:xml/html/script/json}", + data: $.param( $("${4:Element or Expression}") ), + + complete: function() { + ${5://called when complete} + }, + + success: function() { + ${6://called when successful} + }, + + error: function() { + ${7://called when there is an error} + }, + }); +snippet ajaxstart + $.ajaxStart(function() { + ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; + }); + ${2} +snippet ajaxstop + $.ajaxStop(function() { + ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; + }); + ${2} +snippet ajaxsuccess + $.ajaxSuccess(function() { + ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; + }); + ${2} +snippet animate + ${1:obj}.animate({${2:param1: value1, param2: value2}}, ${3:speed})${4} +snippet append + ${1:obj}.append('${2:Some text and bold!}')${3} +snippet appendTo + ${1:obj}.appendTo('${2:selector expression}')${3} +snippet attr + ${1:obj}.attr('${2:attribute}', '${3:value}')${4} +snippet attrm + ${1:obj}.attr({'${2:attr1}': '${3:value1}', '${4:attr2}': '${5:value2}'})${6} +snippet before + ${1:obj}.before('${2:Some text and bold!}')${3} +snippet bind + ${1:obj}.bind('${2:event name}', function(${3:event}) { + ${4:// Act on the event} + }); +snippet blur + ${1:obj}.blur(function() { + ${2:// Act on the event} + }); +snippet change + ${1:obj}.change(function() { + ${2:// Act on the event} + }); +snippet children + ${1:obj}.children('${2:selector expression}')${3} +snippet click + ${1:obj}.click(function() { + ${2:// Act on the event} + }); +snippet clone + ${1:obj}.clone()${2} +snippet contains + ${1:obj}.contains('${2:text to find}')${3} +snippet css + ${1:obj}.css('${2:attribute}', '${3:value}')${4} +snippet cssm + ${1:obj}.css({${2:attribute1}: '${3:value1}', ${4:attribute2}: '${5:value2}'})${6} +snippet dblclick + ${1:obj}.dblclick(function() { + ${2:// Act on the event} + }); +snippet each + ${1:obj}.each(function(index) { + ${2:this.innerHTML = this + " is the element, " + index + " is the position";} + }); +snippet el + $('${1}')${2:} +snippet eltrim + $.trim('${1:string}')${2} +snippet end + ${1:obj}.end()${2} +snippet error + ${1:obj}.error(function() { + ${2:// Act on the event} + }); +snippet fadein + ${1:obj}.fadeIn('${2:slow/400/fast}')${3} +snippet fadeinc + ${1:obj}.fadeIn('slow/400/fast', function() { + ${2://Stuff to do *after* the animation takes place}; + }); +snippet fadeout + ${1:obj}.fadeOut('${2:slow/400/fast}')${3} +snippet fadeoutc + ${1:obj}.fadeOut('slow/400/fast', function() { + ${2://Stuff to do *after* the animation takes place}; + }); +snippet fadeto + ${1:obj}.fadeTo('${2:slow/400/fast}', ${3:0.5})${4} +snippet fadetoc + ${1:obj}.fadeTo('slow/400/fast', ${2:0.5}, function() { + ${3://Stuff to do *after* the animation takes place}; + }); +snippet filter + ${1:obj}.filter('${2:selector expression}')${3} +snippet find + ${1:obj}.find('${2:selector expression}')${3} +snippet focus + ${1:obj}.focus(function() { + ${2:// Act on the event} + }); +snippet get + ${1:obj}.get(${2:element index})${3} +snippet getjson + $.getJSON('<+/path/to/file.cgi+>',{ + <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+>}, + function(json){ + <+//stuff to do after event occurs;+> + }); +snippet getscript + $.getScript('${1:somescript.js}', function(){ + ${2://optional stuff to do after getScript;} + }); +snippet height + ${1:obj}.height(${2:integer})${3} +snippet hide + ${1:obj}.hide('${2:slow/400/fast}')${3} +snippet hidec + ${1:obj}.hide('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place} + }); +snippet hover + ${1:obj}.hover(function() { + ${2:// Stuff to do when the mouse enters the element;} + }, function() { + ${3:// Stuff to do when the mouse leaves the element;} + });${4} +snippet html + ${1:obj}.html('${2:Some text and bold!}')${3} +snippet insertAfter + ${1:obj}.insertAfter('${2:selector expression}')${3} +snippet insertBefore + ${1:obj}.insertBefore('${2:selector expression}')${3} +snippet is + ${1:obj}.is('${2:selector expression}')${3} +snippet jj + $('${1:selector}')${2} +snippet load + ${1:obj}.load(function() { + ${2:// Act on the event} + }); +snippet loadf + <+obj+>.load('<+/path/to/file.htm+>', { <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+> }, function() { + <+// Stuff to do after the page is loaded+> +snippet });loadif + <+obj+>.loadIfModified('<+/path/to/file.htm+>', { <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+> }, function() { + <+// Stuff to do after the page is loaded+> + }); +snippet mdown + ${1:obj}.mousedown(function() { + ${2:// Act on the event} + }); +snippet mmove + ${1:obj}.mousemove(function() { + ${2:// Act on the event} + }); +snippet mout + ${1:obj}.mouseout(function() { + ${2:// Act on the event} + }); +snippet mover + ${1:obj}.mouseover(function() { + ${2:// Act on the event} + }); +snippet mup + ${1:obj}.mouseup(function() { + ${2:// Act on the event} + }); +snippet next + ${1:obj}.next('${2:selector expression}')${3} +snippet not + ${1:obj}.not('${2:selector expression}')${3} +snippet one + ${1:obj}.one('${2:event name}', function(${3:event}) { + ${4:// Act on the event once} + }); +snippet parent + ${1:obj}.parent('${2:selector expression}')${3} +snippet parents + ${1:obj}.parents('${2:selector expression}')${3} +snippet prepend + ${1:obj}.prepend('${2:Some text and bold!}')${3} +snippet prependto + ${1:obj}.prependTo('${2:selector expression}')${3} +snippet prev + ${1:obj}.prev('${2:selector expression}')${3} +snippet ready + $(function() { + ${1} + }); +snippet remove + ${1:obj}.remove()${2} +snippet removeattr + ${1:obj}.removeAttr('${2:attribute name}')${3} +snippet removeclass + ${1:obj}.removeClass('${2:class name}')${3} +snippet reset + ${1:obj}.reset(function() { + ${2:// Act on the event} + }); +snippet resize + ${1:obj}.resize(function() { + ${2:// Act on the event} + }); +snippet scroll + ${1:obj}.scroll(function() { + ${2:// Act on the event} + }); +snippet sdown + ${1:obj}.slideDown('${2:slow/400/fast}')${3} +snippet sdownc + ${1:obj}.slideDown('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place}; + }); +snippet sdupc + ${1:obj}.slideUp('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place}; + }); +snippet select + ${1:obj}.select(function() { + ${2:// Act on the event} + }); +snippet show + ${1:obj}.show('${2:slow/400/fast}')${3} +snippet showc + ${1:obj}.show('${2:slow/400/fast}', function() { + ${3://Stuff to do *after* the animation takes place} + }); +snippet sib + ${1:obj}.siblings('${2:selector expression}')${3} +snippet size + ${1:obj}.size()${2} +snippet stoggle + ${1:obj}.slideToggle('${2:slow/400/fast}')${3} +snippet submit + ${1:obj}.submit(function() { + ${2:// Act on the event once} + }); +snippet sup + ${1:obj}.slideUp('${2:slow/400/fast}')${3} +snippet text + ${1:obj}.text(${2:'some text'})${3} +snippet this + $(this)${1} +snippet tog + ${1:obj}.toggle(function() { + ${2:// Stuff to do every *odd* time the element is clicked;} + }, function() { + ${3:// Stuff to do every *even* time the element is clicked;} + }); + ${4} +snippet togclass + ${1:obj}.toggleClass('${2:class name}')${3} +snippet togsh + ${1:obj}.toggle('${2:slow/400/fast}')${3} +snippet trig + ${1:obj}.trigger('${2:event name}')${3} +snippet unbind + ${1:obj}.unbind('${2:event name}')${3} +snippet val + ${1:obj}.val('${2:text}')${3} +snippet width + ${1:obj}.width(${2:integer})${3} +snippet wrap + ${1:obj}.wrap('${2:<div class="extra-wrapper"></div>}')${3} From c1188dfbc209fba99e5ecf29035f3fca0db4bdab Mon Sep 17 00:00:00 2001 From: Stephen Tudor Date: Sun, 3 Jun 2012 13:16:02 -0400 Subject: [PATCH 17/46] Make jQuery snippets 1.7-compatible --- snippets/javascript-jquery.snippets | 520 +++++++++++++++++++++------- 1 file changed, 390 insertions(+), 130 deletions(-) diff --git a/snippets/javascript-jquery.snippets b/snippets/javascript-jquery.snippets index 59f795e..ce247a0 100644 --- a/snippets/javascript-jquery.snippets +++ b/snippets/javascript-jquery.snippets @@ -6,45 +6,50 @@ snippet after ${1:obj}.after('${2:Some text and bold!}')${3} snippet ajax $.ajax({ - url: "${1:mydomain.com/url}", - type: "${2:POST}", - dataType: "${3:xml/html/script/json}", - data: $.param( $("${4:Element or Expression}") ), - - complete: function() { - ${5://called when complete} + url: '${1:mydomain.com/url}', + type: '${2:POST}', + dataType: '${3:xml/html/script/json}', + data: $.param( $('${4:Element or Expression}') ), + complete: function (jqXHR, textStatus) { + ${5:// callback} }, - - success: function() { - ${6://called when successful} - }, - - error: function() { - ${7://called when there is an error} + success: function (data, textStatus, jqXHR) { + ${6:// success callback} }, + error: function (jqXHR, textStatus, errorThrown) { + ${7:// error callback} + } + }); +snippet ajaxcomplete + ${1:obj}.ajaxComplete(function (${1:e}, xhr, settings) { + ${2:// callback} }); snippet ajaxerror - .ajaxError(function(${1:request, settings}) { - ${2://stuff to do when an AJAX call returns an error}; + ${1:obj}.ajaxError(function (${1:e}, xhr, settings, thrownError) { + ${2:// error callback} }); ${3} snippet ajaxget - $.get('${1:/test/ajax-test.xml}', function(xml){ - ${2:alert( ("title",xml).text() ) //optional stuff to do after get;} - }); -snippet ajaxgetif - $.getIfModified('${1:/test/test.cgi}', function(data){ - ${2:alert( "Data loaded: " + data ) //optional stuff to do after get;} - }); + $.get('${1:mydomain.com/url}', + ${2:{ param1: value1 },} + function (data, textStatus, jqXHR) { + ${3:// success callback} + } + ); snippet ajaxpost - $.post('<+/path/to/file.cgi+>',{ - <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+>}, - function(){ - <+//stuff to do after event occurs;+> + $.post('${1:mydomain.com/url}', + ${2:{ param1: value1 },} + function (data, textStatus, jqXHR) { + ${3:// success callback} + } + ); +snippet ajaxprefilter + $.ajaxPrefilter(function (${1:options}, ${2:originalOptions}, jqXHR) { + ${3: // Modify options, control originalOptions, store jqXHR, etc} }); snippet ajaxsend - .ajaxSend(function(${1:request, settings}) { - ${2://stuff to do when an AJAX call returns an error}; + ${1:obj}.ajaxSend(function (${1:request, settings}) { + ${2:// error callback} }); ${3} snippet ajaxsetup @@ -53,34 +58,33 @@ snippet ajaxsetup type: "${2:POST}", dataType: "${3:xml/html/script/json}", data: $.param( $("${4:Element or Expression}") ), - - complete: function() { - ${5://called when complete} + complete: function (jqXHR, textStatus) { + ${5:// callback} }, - - success: function() { - ${6://called when successful} - }, - - error: function() { - ${7://called when there is an error} + success: function (data, textStatus, jqXHR) { + ${6:// success callback} }, + error: function (jqXHR, textStatus, errorThrown) { + ${7:// error callback} + } }); snippet ajaxstart - $.ajaxStart(function() { - ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; + $.ajaxStart(function () { + ${1:// handler for when an AJAX call is started and no other AJAX calls are in progress}; }); ${2} snippet ajaxstop - $.ajaxStop(function() { - ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; + $.ajaxStop(function () { + ${1:// handler for when all AJAX calls have been completed}; }); ${2} snippet ajaxsuccess - $.ajaxSuccess(function() { - ${1://stuff to do when an AJAX call is started and no other AJAX calls are in progress}; + $.ajaxSuccess(function (${1:e}, xhr, settings) { + ${2:// handler for when any AJAX call is successfully completed}; }); ${2} +snippet andself + ${1:obj}.andSelf()${2} snippet animate ${1:obj}.animate({${2:param1: value1, param2: value2}}, ${3:speed})${4} snippet append @@ -94,223 +98,463 @@ snippet attrm snippet before ${1:obj}.before('${2:Some text and bold!}')${3} snippet bind - ${1:obj}.bind('${2:event name}', function(${3:event}) { - ${4:// Act on the event} + ${1:obj}.bind('${2:event name}', function (${3:e}) { + ${4:// event handler} }); snippet blur - ${1:obj}.blur(function() { - ${2:// Act on the event} + ${1:obj}.blur(function (${2:e}) { + ${3:// event handler} }); +snippet C + $.Callbacks()${1} +snippet Cadd + ${1:callbacks}.add(${2:callbacks})${3} +snippet Cdis + ${1:callbacks}.disable()${2} +snippet Cempty + ${1:callbacks}.empty()${2} +snippet Cfire + ${1:callbacks}.fire(${2:args})${3} +snippet Cfired + ${1:callbacks}.fired()${2} +snippet Cfirew + ${1:callbacks}.fireWith(${2:this}, ${3:args})${4} +snippet Chas + ${1:callbacks}.has(${2:callback})${3} +snippet Clock + ${1:callbacks}.lock()${2} +snippet Clocked + ${1:callbacks}.locked()${2} +snippet Crem + ${1:callbacks}.remove(${2:callbacks})${3} snippet change - ${1:obj}.change(function() { - ${2:// Act on the event} + ${1:obj}.change(function (${2:e}) { + ${3:// event handler} }); snippet children ${1:obj}.children('${2:selector expression}')${3} +snippet clearq + ${1:obj}.clearQueue(${2:'queue name'})${3} snippet click - ${1:obj}.click(function() { - ${2:// Act on the event} + ${1:obj}.click(function (${2:e}) { + ${3:// event handler} }); snippet clone ${1:obj}.clone()${2} snippet contains - ${1:obj}.contains('${2:text to find}')${3} + $.contains(${1:container}, ${2:contents}); snippet css ${1:obj}.css('${2:attribute}', '${3:value}')${4} +snippet csshooks + $.cssHooks['${1:CSS prop}'] = { + get: function (elem, computed, extra) { + ${2: // handle getting the CSS property} + }, + set: function (elem, value) { + ${3: // handle setting the CSS value} + } + }; snippet cssm ${1:obj}.css({${2:attribute1}: '${3:value1}', ${4:attribute2}: '${5:value2}'})${6} +snippet D + $.Deferred()${1} +snippet Dalways + ${1:deferred}.always(${2:callbacks})${3} +snippet Ddone + ${1:deferred}.done(${2:callbacks})${3} +snippet Dfail + ${1:deferred}.fail(${2:callbacks})${3} +snippet Disrej + ${1:deferred}.isRejected()${2} +snippet Disres + ${1:deferred}.isResolved()${2} +snippet Dnotify + ${1:deferred}.notify(${2:args})${3} +snippet Dnotifyw + ${1:deferred}.notifyWith(${2:this}, ${3:args})${4} +snippet Dpipe + ${1:deferred}.then(${2:doneFilter}, ${3:failFilter}, ${4:progressFilter})${5} +snippet Dprog + ${1:deferred}.progress(${2:callbacks})${3} +snippet Dprom + ${1:deferred}.promise(${2:target})${3} +snippet Drej + ${1:deferred}.reject(${2:args})${3} +snippet Drejw + ${1:deferred}.rejectWith(${2:this}, ${3:args})${4} +snippet Dres + ${1:deferred}.resolve(${2:args})${3} +snippet Dresw + ${1:deferred}.resolveWith(${2:this}, ${3:args})${4} +snippet Dstate + ${1:deferred}.state()${2} +snippet Dthen + ${1:deferred}.then(${2:doneCallbacks}, ${3:failCallbacks}, ${4:progressCallbacks})${5} +snippet Dwhen + $.when(${1:deferreds})${2} +snippet data + ${1:obj}.data(${2:obj})${3} +snippet dataa + $.data('${1:selector expression}', '${2:key}'${3:, 'value'})${4} snippet dblclick - ${1:obj}.dblclick(function() { - ${2:// Act on the event} + ${1:obj}.dblclick(function (${2:e}) { + ${3:// event handler} }); +snippet delay + ${1:obj}.delay('${2:slow/400/fast}'${3:, 'queue name'})${4} +snippet dele + ${1:obj}.delegate('${2:selector expression}', '${3:event name}', function (${4:e}) { + ${5:// event handler} + }); +snippet deq + ${1:obj}.dequeue(${2:'queue name'})${3} +snippet deqq + $.dequeue('${1:selector expression}'${2:, 'queue name'})${3} +snippet detach + ${1:obj}.detach('${2:selector expression}')${3} +snippet die + ${1:obj}.die(${2:event}, ${3:handler})${4} snippet each - ${1:obj}.each(function(index) { + ${1:obj}.each(function (index) { ${2:this.innerHTML = this + " is the element, " + index + " is the position";} }); snippet el - $('${1}')${2:} + $('<${1}/>'${2:, {}})${3} snippet eltrim $.trim('${1:string}')${2} +snippet empty + ${1:obj}.empty()${2} snippet end ${1:obj}.end()${2} +snippet eq + ${1:obj}.eq(${2:element index})${3} snippet error - ${1:obj}.error(function() { - ${2:// Act on the event} + ${1:obj}.error(function (${2:e}) { + ${3:// event handler} }); +snippet eventsmap + { + :f${1} + } +snippet extend + $.extend(${1:true, }${2:target}, ${3:obj})${4} snippet fadein ${1:obj}.fadeIn('${2:slow/400/fast}')${3} snippet fadeinc - ${1:obj}.fadeIn('slow/400/fast', function() { - ${2://Stuff to do *after* the animation takes place}; + ${1:obj}.fadeIn('slow/400/fast', function () { + ${2:// callback}; }); snippet fadeout ${1:obj}.fadeOut('${2:slow/400/fast}')${3} snippet fadeoutc - ${1:obj}.fadeOut('slow/400/fast', function() { - ${2://Stuff to do *after* the animation takes place}; + ${1:obj}.fadeOut('slow/400/fast', function () { + ${2:// callback}; }); snippet fadeto ${1:obj}.fadeTo('${2:slow/400/fast}', ${3:0.5})${4} snippet fadetoc - ${1:obj}.fadeTo('slow/400/fast', ${2:0.5}, function() { - ${3://Stuff to do *after* the animation takes place}; + ${1:obj}.fadeTo('slow/400/fast', ${2:0.5}, function () { + ${3:// callback}; }); snippet filter ${1:obj}.filter('${2:selector expression}')${3} +snippet filtert + ${1:obj}.filter(function (${2:index}) { + ${3:// test code} + })${4} snippet find ${1:obj}.find('${2:selector expression}')${3} snippet focus - ${1:obj}.focus(function() { - ${2:// Act on the event} + ${1:obj}.focus(function (${2:e}) { + ${3:// event handler} + }); +snippet focusin + ${1:obj}.focusIn(function (${2:e}) { + ${3:// event handler} + }); +snippet focusout + ${1:obj}.focusOut(function (${2:e}) { + ${3:// event handler} }); snippet get ${1:obj}.get(${2:element index})${3} snippet getjson - $.getJSON('<+/path/to/file.cgi+>',{ - <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+>}, - function(json){ - <+//stuff to do after event occurs;+> - }); + $.getJSON('${1:mydomain.com/url}', + ${2:{ param1: value1 },} + function (data, textStatus, jqXHR) { + ${3:// success callback} + } + ); snippet getscript - $.getScript('${1:somescript.js}', function(){ - ${2://optional stuff to do after getScript;} + $.getScript('${1:mydomain.com/url}', function (script, textStatus, jqXHR) { + ${2:// callback} }); +snippet grep + $.grep(${1:array}, function (item, index) { + ${2:// test code} + }${3:, true}); +snippet hasc + ${1:obj}.hasClass('${2:className}')${3} +snippet hasd + $.hasData('${1:selector expression}'); snippet height ${1:obj}.height(${2:integer})${3} snippet hide ${1:obj}.hide('${2:slow/400/fast}')${3} snippet hidec - ${1:obj}.hide('${2:slow/400/fast}', function() { - ${3://Stuff to do *after* the animation takes place} + ${1:obj}.hide('${2:slow/400/fast}', function () { + ${3:// callback} }); snippet hover - ${1:obj}.hover(function() { - ${2:// Stuff to do when the mouse enters the element;} - }, function() { - ${3:// Stuff to do when the mouse leaves the element;} - });${4} + ${1:obj}.hover(function (${2:e}) { + ${3:// event handler} + }, function ($2) { + ${4:// event handler} + });${5} snippet html ${1:obj}.html('${2:Some text and bold!}')${3} -snippet insertAfter +snippet inarr + $.inArray(${1:value}, ${2:array}); +snippet insa ${1:obj}.insertAfter('${2:selector expression}')${3} -snippet insertBefore +snippet insb ${1:obj}.insertBefore('${2:selector expression}')${3} snippet is ${1:obj}.is('${2:selector expression}')${3} +snippet isarr + $.isArray(${1:obj})${2} +snippet isempty + $.isEmptyObject(${1:obj})${2} +snippet isfunc + $.isFunction(${1:obj})${2} +snippet isnum + $.isNumeric(${1:value})${2} +snippet isobj + $.isPlainObject(${1:obj})${2} +snippet iswin + $.isWindow(${1:obj})${2} +snippet isxml + $.isXMLDoc(${1:node})${2} snippet jj $('${1:selector}')${2} +snippet kdown + ${1:obj}.keydown(function (${2:e}) { + ${3:// event handler} + }); +snippet kpress + ${1:obj}.keypress(function (${2:e}) { + ${3:// event handler} + }); +snippet kup + ${1:obj}.keyup(function (${2:e}) { + ${3:// event handler} + }); +snippet last + ${1:obj}.last('${1:selector expression}')${3} +snippet live + ${1:obj}.live('${2:events}', function (${3:e}) { + ${4:// event handler} + }); snippet load - ${1:obj}.load(function() { - ${2:// Act on the event} + ${1:obj}.load(function (${2:e}) { + ${3:// event handler} }); snippet loadf - <+obj+>.load('<+/path/to/file.htm+>', { <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+> }, function() { - <+// Stuff to do after the page is loaded+> -snippet });loadif - <+obj+>.loadIfModified('<+/path/to/file.htm+>', { <+<+param1+>: "<+value1+>", <+param2+>: "<+value2+>"+> }, function() { - <+// Stuff to do after the page is loaded+> + ${1:obj}.load('${2:mydomain.com/url}', + ${2:{ param1: value1 },} + function (responseText, textStatus, xhr) { + ${3:// success callback} + } }); +snippet makearray + $.makeArray(${1:obj}); +snippet map + ${1:obj}.map(function (${2:index}, ${3:element}) { + ${4:// callback} + }); +snippet mapp + $.map(${1:arrayOrObject}, function (${2:value}, ${3:indexOrKey}) { + ${4:// callback} + }); +snippet merge + $.merge(${1:target}, ${2:original}); snippet mdown - ${1:obj}.mousedown(function() { - ${2:// Act on the event} + ${1:obj}.mousedown(function (${2:e}) { + ${3:// event handler} + }); +snippet menter + ${1:obj}.mouseenter(function (${2:e}) { + ${3:// event handler} + }); +snippet mleave + ${1:obj}.mouseleave(function (${2:e}) { + ${3:// event handler} }); snippet mmove - ${1:obj}.mousemove(function() { - ${2:// Act on the event} + ${1:obj}.mousemove(function (${2:e}) { + ${3:// event handler} }); snippet mout - ${1:obj}.mouseout(function() { - ${2:// Act on the event} + ${1:obj}.mouseout(function (${2:e}) { + ${3:// event handler} }); snippet mover - ${1:obj}.mouseover(function() { - ${2:// Act on the event} + ${1:obj}.mouseover(function (${2:e}) { + ${3:// event handler} }); snippet mup - ${1:obj}.mouseup(function() { - ${2:// Act on the event} + ${1:obj}.mouseup(function (${2:e}) { + ${3:// event handler} }); snippet next ${1:obj}.next('${2:selector expression}')${3} +snippet nexta + ${1:obj}.nextAll('${2:selector expression}')${3} +snippet nextu + ${1:obj}.nextUntil('${2:selector expression}'${3:, 'filter expression'})${4} snippet not ${1:obj}.not('${2:selector expression}')${3} -snippet one - ${1:obj}.one('${2:event name}', function(${3:event}) { - ${4:// Act on the event once} +snippet off + ${1:obj}.off('${2:events}', '${3:selector expression}'${4:, handler})${5} +snippet offset + ${1:obj}.offset()${2} +snippet offsetp + ${1:obj}.offsetParent()${2} +snippet on + ${1:obj}.on('${2:events}', '${3:selector expression}', function (${4:e}) { + ${5:// event handler} }); +snippet one + ${1:obj}.one('${2:event name}', function (${3:e}) { + ${4:// event handler} + }); +snippet outerh + ${1:obj}.outerHeight()${2} +snippet outerw + ${1:obj}.outerWidth()${2} +snippet param + $.param(${1:obj})${2} snippet parent ${1:obj}.parent('${2:selector expression}')${3} snippet parents ${1:obj}.parents('${2:selector expression}')${3} +snippet parentsu + ${1:obj}.parentsUntil('${2:selector expression}'${3:, 'filter expression'})${4} +snippet parsejson + $.parseJSON(${1:data})${2} +snippet parsexml + $.parseXML(${1:data})${2} +snippet pos + ${1:obj}.position()${2} snippet prepend ${1:obj}.prepend('${2:Some text and bold!}')${3} snippet prependto ${1:obj}.prependTo('${2:selector expression}')${3} snippet prev ${1:obj}.prev('${2:selector expression}')${3} +snippet preva + ${1:obj}.prevAll('${2:selector expression}')${3} +snippet prevu + ${1:obj}.prevUntil('${2:selector expression}'${3:, 'filter expression'})${4} +snippet promise + ${1:obj}.promise(${2:'fx'}, ${3:target})${4} +snippet prop + ${1:obj}.prop('${2:property name}')${3} +snippet proxy + $.proxy(${1:function}, ${2:this})${3} +snippet pushstack + ${1:obj}.pushStack(${2:elements})${3} +snippet queue + ${1:obj}.queue(${2:name}${3:, newQueue})${4} +snippet queuee + $.queue(${1:element}${2:, name}${3:, newQueue})${4} snippet ready - $(function() { + $(function () { ${1} }); -snippet remove +snippet rem ${1:obj}.remove()${2} -snippet removeattr +snippet rema ${1:obj}.removeAttr('${2:attribute name}')${3} -snippet removeclass +snippet remc ${1:obj}.removeClass('${2:class name}')${3} +snippet remd + ${1:obj}.removeData('${2:key name}')${3} +snippet remdd + $.removeData(${1:element}${2:, 'key name}')${3} +snippet remp + ${1:obj}.removeProp('${2:property name}')${3} +snippet repa + ${1:obj}.replaceAll(${2:target})${3} +snippet repw + ${1:obj}.replaceWith(${2:content})${3} snippet reset - ${1:obj}.reset(function() { - ${2:// Act on the event} + ${1:obj}.reset(function (${2:e}) { + ${3:// event handler} }); snippet resize - ${1:obj}.resize(function() { - ${2:// Act on the event} + ${1:obj}.resize(function (${2:e}) { + ${3:// event handler} }); snippet scroll - ${1:obj}.scroll(function() { - ${2:// Act on the event} + ${1:obj}.scroll(function (${2:e}) { + ${3:// event handler} }); +snippet scrolll + ${1:obj}.scrollLeft(${2:value})${3} +snippet scrollt + ${1:obj}.scrollTop(${2:value})${3} snippet sdown ${1:obj}.slideDown('${2:slow/400/fast}')${3} snippet sdownc - ${1:obj}.slideDown('${2:slow/400/fast}', function() { - ${3://Stuff to do *after* the animation takes place}; - }); -snippet sdupc - ${1:obj}.slideUp('${2:slow/400/fast}', function() { - ${3://Stuff to do *after* the animation takes place}; + ${1:obj}.slideDown('${2:slow/400/fast}', function () { + ${3:// callback}; }); snippet select - ${1:obj}.select(function() { - ${2:// Act on the event} + ${1:obj}.select(function (${2:e}) { + ${3:// event handler} }); +snippet serialize + ${1:obj}.serialize()${2} +snippet serializea + ${1:obj}.serializeArray()${2} snippet show ${1:obj}.show('${2:slow/400/fast}')${3} snippet showc - ${1:obj}.show('${2:slow/400/fast}', function() { - ${3://Stuff to do *after* the animation takes place} + ${1:obj}.show('${2:slow/400/fast}', function () { + ${3:// callback} }); snippet sib ${1:obj}.siblings('${2:selector expression}')${3} snippet size ${1:obj}.size()${2} +snippet slice + ${1:obj}.slice(${2:start}${3:, end})${4} snippet stoggle ${1:obj}.slideToggle('${2:slow/400/fast}')${3} +snippet stop + ${1:obj}.stop('${2:queue}', ${3:false}, ${4:false})${5} snippet submit - ${1:obj}.submit(function() { - ${2:// Act on the event once} + ${1:obj}.submit(function (${2:e}) { + ${3:// event handler} }); snippet sup ${1:obj}.slideUp('${2:slow/400/fast}')${3} +snippet supc + ${1:obj}.slideUp('${2:slow/400/fast}', function () { + ${3:// callback}; + }); snippet text ${1:obj}.text(${2:'some text'})${3} snippet this $(this)${1} +snippet toarr + ${1:obj}.toArray() snippet tog - ${1:obj}.toggle(function() { - ${2:// Stuff to do every *odd* time the element is clicked;} - }, function() { - ${3:// Stuff to do every *even* time the element is clicked;} + ${1:obj}.toggle(function (${2:e}) { + ${3:// event handler} + }, function ($2) { + ${4:// event handler} }); ${4} snippet togclass @@ -319,8 +563,24 @@ snippet togsh ${1:obj}.toggle('${2:slow/400/fast}')${3} snippet trig ${1:obj}.trigger('${2:event name}')${3} +snippet trigh + ${1:obj}.triggerHandler('${2:event name}')${3} +snippet $trim + $.trim(${1:str})${2} +snippet $type + $.type(${1:obj})${2} snippet unbind ${1:obj}.unbind('${2:event name}')${3} +snippet undele + ${1:obj}.undelegate(${2:selector expression}, ${3:event}, ${4:handler})${5} +snippet uniq + $.unique(${1:array})${2} +snippet unload + ${1:obj}.unload(function (${2:e}) { + ${3:// event handler} + }); +snippet unwrap + ${1:obj}.unwrap()${2} snippet val ${1:obj}.val('${2:text}')${3} snippet width From 3f56f55ffab3ff1784748b7ef33fab2e69469d08 Mon Sep 17 00:00:00 2001 From: Julien Stechele Date: Wed, 6 Jun 2012 15:22:44 +0300 Subject: [PATCH 18/46] Fix indentation for templating snippets --- snippets/htmldjango.snippets | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/snippets/htmldjango.snippets b/snippets/htmldjango.snippets index c87b5ee..38f836b 100644 --- a/snippets/htmldjango.snippets +++ b/snippets/htmldjango.snippets @@ -12,17 +12,17 @@ snippet { snippet autoescape {% autoescape ${1:off} %} - ${2} + ${2} {% endautoescape %} snippet block {% block ${1} %} - ${2} + ${2} {% endblock %} snippet # {# ${1:comment} #} snippet comment {% comment %} - ${1} + ${1} {% endcomment %} snippet cycle {% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} @@ -32,33 +32,33 @@ snippet extends {% extends "${1:base.html}" %} snippet filter {% filter ${1} %} - ${2} + ${2} {% endfilter %} snippet firstof {% firstof ${1} %} snippet for {% for ${1} in ${2} %} - ${3} + ${3} {% endfor %} snippet empty {% empty %} ${1} snippet if {% if ${1} %} - ${2} + ${2} {% endif %} snippet else {% else %} - ${1} + ${1} snippet ifchanged {% ifchanged %}${1}{% endifchanged %} snippet ifequal {% ifequal ${1} ${2} %} - ${3} + ${3} {% endifequal %} snippet ifnotequal {% ifnotequal ${1} ${2} %} - ${3} + ${3} {% endifnotequal %} snippet include {% include "${1}" %} From fe8c9a96b0a175f5c458bae64d56c6d2675d2786 Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sun, 17 Jun 2012 22:30:45 +0200 Subject: [PATCH 19/46] Add snippets for the Processing Programming Language (processing.org) --- snippets/processing.snippets | 784 +++++++++++++++++++++++++++++++++++ 1 file changed, 784 insertions(+) create mode 100755 snippets/processing.snippets diff --git a/snippets/processing.snippets b/snippets/processing.snippets new file mode 100755 index 0000000..b0aa93c --- /dev/null +++ b/snippets/processing.snippets @@ -0,0 +1,784 @@ +#BASICS +# doc +snippet doc + /** + * ${1:Description} + * + * @author ${2:name} + * @since ${3:`strftime("%d/%m/%y %H:%M:%S")`} + */ + ${4} +# doc comment +snippet docc + /** + * ${1:@private}$0 + */ + ${2} +# class +snippet class + ${1:public }class ${2:`fnamemodify(bufname("%"),":t:r")`} ${3:extends} + { + + //-------------------------------------- + // CONSTRUCTOR + //-------------------------------------- + + public $2 (${4:arguments}) { + ${0:// expression} + } + } +# package +snippet package + /** + * ${1:Description} + * + * @author ${2:$TM_FULLNAME} + * @since ${3:`strftime("%d/%m/%y %H:%M:%S")`} + */ + + package ${4:package}; +# function +snippet fun + ${1:void/private/protected/public}${2: static} ${3:name}(${4}) { + ${5://if not void return null;} + } + ${6} +snippet fn + ${1:void }${2:name}(${3}) { + ${4://if not void return null;} + } + ${5} +# constant +snippet const + static final ${1:Object} ${2:VAR_NAM} = ${3}; +# var +snippet var + ${1:private/public }${2:static }${3:String} ${4:str}${5: =}${6:value}; +# var objects +snippet obj + ${1:private/public }${2:Object} ${3:o}${4: = new }$2(${5}); +#loop for +snippet for + for (int ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { + ${4:$1[$2]} + }; +#loop while +snippet while + while (${1:/* condition */}) { + ${2:/* code */} + } +#break +snippet break + break ${1:label}; +#case +snippet case + case ${1:expression} : + ${2} + break; +#default +snippet default + default : + ${1} + break; +#switch +snippet switch + switch(${1:expression}) { + case '${3:case}': + ${4:// code} + break; + ${5} + default: + ${2:// code} + } +#try +snippet try + try { + ${3} + } catch(${1:Exception} ${2:e}) { + } +#try catch finally +snippet tryf + try { + ${3} + } catch(${1:Exception} ${2:e}) { + } finally { + } +#throw +snippet throw + throw new ("${1:Exception()}"); +#ternary +snippet ? + ? ${1:trueExpression} : ${2:falseExpression} + ${3} +snippet if + if (${1:true}) {${2}} +# if ... else +snippet ife + if (${1:true}) {${2}} + else{${3}} +#get +snippet get + public ${1:String} get${2}() { + return ${2:fieldName}; + } +#set +snippet set + public void set${1}(${2:String} new${1}) { + ${1:fieldName} = new${1}; + } +#printIn +snippet println + println("${1:`fnamemodify(bufname("%"),":t:r")`}::${2:method}() "${3: +} ${4}); +#println string +snippet pr + println("${1}"); +#setup draw +snippet setup + void setup(){ + ${1} + } + + void draw(){ + ${2} + } +#setup OPENGL +snippet opengl + import processing.opengl.*; + import javax.media.opengl.*; + + PGraphicsOpenGL pgl; + GL gl; + + void setup(){ + size( ${1:300}, ${2:300}, OPENGL ); + colorMode( RGB, 1.0 ); + hint( ENABLE_OPENGL_4X_SMOOTH ); + pgl = (PGraphicsOpenGL) g; + gl = pgl.gl; + gl.setSwapInterval(1); + initGL(); + ${3} + } + + void draw(){ + pgl.beginGL(); + ${4} + pgl.endGL(); + getOpenGLErrors(); + } + + void initGL(){ + ${5} + } + + void getOpenGLErrors(){ + int error = gl.glGetError(); + switch (error){ + case 1280 : + println("GL_INVALID_ENUM - An invalid enumerant was passed to an OpenGL command."); + break; + case 1282 : + println("GL_INVALID_OPERATION - An OpenGL command was issued that was invalid or inappropriate for the current state."); + break; + case 1281 : + println("GL_INVALID_VALUE - A value was passed to OpenGL that was outside the allowed range."); + break; + case 1285 : + println("GL_OUT_OF_MEMORY - OpenGL was unable to allocate enough memory to process a command."); + break; + case 1283 : + println("GL_STACK_OVERFLOW - A command caused an OpenGL stack to overflow."); + break; + case 1284 : + println("GL_STACK_UNDERFLOW - A command caused an OpenGL stack to underflow."); + break; + case 32817 : + println("GL_TABLE_TOO_LARGE"); + break; + } + } + +#GL Functions +snippet gl begin gl + pgl.beginGL(); + ${1} + pgl.endGL(); +snippet gl gl swap interval + // specify the minimum swap interval for buffer swaps. + gl.setSwapInterval(${1:interval}); +snippet gl gl call list + // execute a display list + gl.glCallList(${1:list}); +snippet gl gl gen buffers + // import java.nio.IntBuffer; + // import java.nio.FloatBuffer; + // import com.sun.opengl.util.BufferUtil; + + // You might need to create four buffers to store vertext data, normal data, texture coordinate data, and indices in vertex arrays + IntBuffer bufferObjects = IntBuffer.allocate(${1:4}); + gl.glGenBuffers($1, bufferObjects); + + int vertexCount = ${2:3}; + int numCoordinates = ${3:3}; + // vertexCount * numCoordinates + FloatBuffer vertices = BufferUtil.newFloatBuffer(vertexCount * numCoordinates); + float[] v = {0.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 1.0f}; + vertices.put(v); + + // Bind the first buffer object ID for use with vertext array data + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, bufferObjects.get(0)); + gl.glBufferData(GL.GL_ARRAY_BUFFER, vertexCount * numCoordinates * BufferUtil.SIZEOF_FLOAT, vertices, GL.GL_STATIC_DRAW); +snippet gl gl bind buffer + ${2:// A buffer ID of zero unbinds a buffer object} + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, ${1:0}); +snippet gl gl delete buffers + ${3:// Parameters are the same for glGenBuffers} + gl.glDeleteBuffers(${1:4}, ${2:bufferObjects}); +snippet gl gl depth mask + // enable or disable writing into the depth buffer + gl.glDepthMask(${1:flag}); +snippet gl gl load identity + // replaces the top of the active matrix stack with the identity matrix + gl.glLoadIdentity(); +snippet gl gl tex coord 2f + // set the current texture coordinates - 2 floats + gl.glTexCoord2f(${1:0.0f}, ${2:0.0f}); +snippet gl gl vertex 2f + gl.glVertex2f(${1:0.0f}, ${2:0.0f}); +snippet gl gl vertex 3f + gl.glVertex3f(${1:0.0f}, ${2:0.0f}, ${3:0.0f}); +snippet gl gl translate f + // multiply the current matrix by a translation matrix + gl.glTranslatef(${1:x}, ${2:y}, ${3:z}); +snippet gl gl rotate f + // rotate, x-axis, y-axis, z-axiz + gl.glRotatef(${1:angle}, ${2:x}, ${3:y}, ${4:z}); +snippet gl gl scale f + // multiply the current matrix by a general scaling matrix + gl.glScalef(${1:x}, ${2:y}, ${3:z}); +snippet gl gl color 4f + gl.glColor4f(${1:red}, ${2:green}, ${3:blue}, ${4:alpha}); +snippet gl gl clear color + gl.glClearColor(${1:red}, ${2:green}, ${3:blue}, ${4:alpha}); +snippet gl gl color 3f + gl.glColor3f(${1:red}, ${2:green}, ${3:blue}); +snippet gl gl push matrix + // spush and pop the current matrix stack + gl.glPushMatrix(); + ${1} + gl.glPopMatrix(); +snippet gl gl gen lists + gl.glGenLists(${1:1}) +snippet gl gl flush + // Empties buffers. Call this when all previous issues commands completed + gl.glFlush(); + ${1} +snippet gl gl get error + println(gl.glGetError()); +snippet gl gl clear + gl.glClear(${1:GL.GL_COLOR_BUFFER_BIT}${2: | }${3:GL.GL_DEPTH_BUFFER_BIT}); + +#frame operations +snippet fr framerate + frameRate(${1:30}); + ${2} +snippet fr frameRate + frameRate +snippet fr frameCount + frameCount +snippet fr saveFrame + saveFrame("${1:filename-####}${2:.ext}"); + +#size +snippet size normal size + size(${1:200}, ${2:200}${3:, P3D}); +snippet size opengl size + size(${1:200}, ${2:200}${3:, OPENGL}); + +#PRIMITIVES +#color +snippet color + color ${1:c}${2: = color(}${3:value1, }${4:value2, }${5:value3)}; +#char +snippet char + char ${1:m}${2: = "}${3:char"}; +#float +snippet float + float ${1:f}${2: = }${3:0.0f}; +#int +snippet int + int ${1:f}${2: = }${3:0}; +#boolean +snippet boolean + boolean ${1:b}${2: = }${3:true}; +#byte +snippet byte + byte ${1:b}${2: = }${3:127}; +#string +snippet string + String ${1:str}${2: = "}${3:CCCP"}; +#array +snippet array + ${1:int}[] ${2:numbers}${3: = new $1}[${4:length}]; +#object +snippet object + ${1:Object} ${2:o}${3: = new $1}(${4}); + +#curve +snippet curve curve + curve(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x3}, ${6:y3}, ${7:x4}, ${8:y4}); +snippet curve curve 3D + curve(${1:x1}, ${2:y1}, ${3:z1}, ${4:x2}, ${5:y2}, ${6:z2}, ${7:x3}, ${8:y3}, ${9:z3}, ${10:x4}, ${11:y4}, ${12:z4}); +snippet curve curve Detail + curveDetail(${1:detail}); +snippet curve curve point + curvePoint(${1:a}, ${2:b}, ${3:c}, ${4:d}, ${5:t}); +snippet curve curve tightness + curveTightness(${1:squishy}); + +#bezier +snippet bezier bezier + bezier(${1:x1}, ${2:y1}, ${3:cx1}, ${4:cy1}, ${5:cx2}, ${6:cy2}, ${7:x2}, ${8:y2}); +snippet bezier bezier 3D + bezier(${1:x1}, ${2:y1}, ${3:z1}, ${4:cx1}, ${5:cy1}, ${6:cz1}, ${7:cx2}, ${8:cy2}, ${9:cz2}, ${10:x2}, ${11:y2}, ${12:z2}); +snippet bezier bezier detail + bezierDetail(${1:detail}); +snippet bezier bezier tangent + bezierTangent(${1:a}, ${2:b}, ${3:c}, ${4:d}, ${5:t}); +snippet bezier bezier point + bezierPoint(${1:a}, ${2:b}, ${3:c}, ${4:d}, ${5:t}); + +#vertex +snippet vertex vertex + vertex(${1:x}, ${2:y}${3:, }${4:u}${5:, }${6:v}); +snippet vertex vertex 3D + vertex(${1:x}, ${2:y}, ${3:z}${4:, }${5:u}${6:, }${7:v}); +snippet vertex vertex bezier + bezierVertex(${1:cx1}, ${2:cy1}, ${3:cx2}, ${4:cy2}, ${5:x}, ${6:y}); +snippet vertex vertex bezier 3D + bezierVertex(${1:cx1}, ${2:cy1}, ${3:cz1}, ${4:cx2}, ${5:cy2}, ${6:cz2}, ${7:x}, ${8:y}, ${9:z}); +snippet vertex vertex curve + curveVertex(${1:x}, ${2:y}); +snippet vertex vertex curve 3D + curveVertex(${1:x}, ${2:y}, ${3:z}); + +#stroke +snippet stroke stroke + stroke(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet stroke stroke weight + strokeWeight(${1:1}); +snippet stroke no stroke + noStroke(); + +#mouse +snippet mouse mouse x + mouseX +snippet mouse mouse y + mouseY +snippet mouse mouse drag + void mouseDragged(){ + ${1} + } +snippet mouse mouse move + void mouseMoved(){ + ${1} + } +snippet mouse mouse release + void mouseReleased(){ + ${1} + } +snippet mouse mouse pressed + void mousePressed(){ + ${1} + } +snippet mouse mouse pressed? + mousePressed +snippet mouse mouse button? + mouseButton +snippet mouse pmouse X + pmouseX +snippet mouse pmouse Y + pmouseY + +#key +snippet key keycode? + keyCode +snippet key key + key +snippet key key released + void keyReleased(){ + ${1} + } +snippet key key typed + void keyTyped(){ + ${1} + } +snippet key key pressed + void keyPressed(){ + ${1} + } +snippet key key pressed? + keyPressed + +#file +snippet file load string + loadStrings("${1:filename}"); +snippet file save string + saveStrings(${1:filename}, ${2:strings}); +snippet file load bytes + loadBytes("${1:filename}"); +snippet file begin record + beginRecord(${1:renderer}, ${2:filename}); +snippet file end record + endRecord(); +snippet file save bytes + saveBytes(${1:filename}, ${2:bytes}); +snippet file create writer + createWriter(${1:filename}); +snippet file create reader + createReader(${1:filename}); + +#time +snippet time hour + hour() +snippet time milliseconds + millis() +snippet time year + year() +snippet time minutes + minutes() +snippet time month + month() +snippet time second + second() + +#matrix +snippet matrix reset matrix + translate(${1:x}, ${2:y}, ${3:z}); +snippet matrix print matrix + printMatrix(); +snippet matrix push matrix + pushMatrix(); + ${1:}; + popMatrix(); + + +#text +snippet txt text data + text(${1:data}, ${2:x}, ${3:y}${4:, }${5:z}); +snippet txt text string data + text(${1:stringdata}, ${2:x}, ${3:y}, ${4:width}, ${5:height}${6:, }${7:z}); +snippet txt text size + textSize(${1:size}); +snippet txt text leading + textLeading(${1:size}); +snippet txt text width + textWidth(${1:data}); +snippet txt text descent + textDescent(); +snippet txt text ascent + textAscent(); +snippet txt font + PFont ${1:font}; + $1 = loadFont("${2:FFScala-32.vlw}"); +#load font +snippet txt load font + ${1:font} = loadFont("${2:FFScala-32.vlw}"); +snippet txt text font + textFont(${1:font}${2:, }${3:size}); + +#math +snippet math tangent + tan(${1:rad}); +snippet math atan + atan(${1:rad}); +snippet math atan2 + atan2(${1:rad}); +snippet math sin + sin(${1:rad}); +snippet math asin + asin(${1:rad}); +snippet math cos + cos(${1:rad}); +snippet math acos + acos(${1:rad}); +snippet math degrees + degrees(${1:rad}); +snippet math radians + radians(${1:deg}); +snippet math random seed + randomSeed(${1:value}); +snippet math random + random(${1:value1}${2:, }${3:value2}); +snippet math half PI + HALF_PI +snippet math 2 PI + TWO_PI +snippet math PI + PI +snippet math pow + pow(${1:num}, ${2:exponent}); +snippet math floor + floor(${1:value}); +snippet math sqrt + sqrt(${1:value}); +snippet math abs + abs(${1:value}); +snippet math sq + sq(${1:value}); +snippet math ceil + ceil(${1:value}); +snippet math exp + exp(${1:value}); +snippet math round + round(${1:value}}; +snippet math min + min(${1:value1}, ${2:value2}${3:, }${4:value3}); +snippet math max + max(${1:value1}, ${2:value2}${3:, }${4:value3}); +snippet math array max + max(${1:array}); +snippet math array min + min(${1:array}); +snippet math logarithm + log(${1:value}); +snippet math map + map(${1:value}, ${2:low1}, ${4:high1}, ${5:low2}, ${6:high2}); +snippet math normalize + norm(${1:value}, ${2:low}, ${3:high}); +snippet math constrain + constrain(${1:value}, ${2:min}, ${3:max}); +snippet math magnitude of a vector + mag(${1:a}, ${2:b}${3:, }${4:c}); +snippet math distance + dist(${1:x1}, ${2:y1}, ${4:x2}, ${5:y2}); +snippet math distance 3D + dist(${1:x1}, ${2:y1}, ${3:z1}, ${4:x2}, ${5:y2}, ${6:z2}); + +#noise math +snippet noise set noise + noise(${1:x}${2:, }${3:y}${4:, }${5:z}); +snippet noise noise detail + noiseDetail(${1:octaves}${2:, }${3:falloff}); +snippet noise noise seed + noiseSeed(${1:x}); + +#material +snippet material shininess + shininess(${1:shine}); +snippet material specular + specular(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet material ambient + ambient(${1:value1}, ${2:value2}, ${3:value3}); +snippet material emissive + emissive(${1:value1}, ${2:value2}, ${3:value3}); + +#light +snippet light no light + noLights(); +snippet light light + lights(); +snippet light diretional light + directionalLight(${1:v1}, ${2:v2}, ${3:v3}, ${4:nx}, ${5:ny}, ${6:nz}); +snippet light point light + pointLight(${1:v1}, ${2:v2}, ${3:v3}, ${4:nx}, ${5:ny}, ${6:nz}); +snippet light falloff light + lightFalloff(${1:constant}, ${2:linear}, ${3:quadratic}); +snippet light normal light + normal(${1:nx}, ${2:ny}, ${3:nz}); +snippet light specular light + lightFalloff(${1:v1}, ${2:v2}, ${3:v3}); +snippet light ambient light + ambientLight(${1:v1}, ${2:v2}, ${3:v3}${7:, ${4:x}, ${5:y}, ${6:z}}); +snippet light spot light + spotLight(${1:v1}, ${2:v2}, ${3:v3}, ${4:x}, ${5:y}, ${6:z}, ${7:nx}, ${8:ny}, ${9:nz}, ${10:angle}, ${11:concentration}); + +#camera +snippet cam camera + camera(${1:eyeX}, ${2:eyeY}, ${3:eyeZ}, ${4:centerX}, ${5:centerY}, ${6:centerZ}, ${7:upX}, ${8:upY}, ${9:upZ}); +snippet cam ortho + ortho(${1:left}, ${2:right}, ${3:bottom}, ${4:top}, ${5:near}, ${6:far}); +snippet cam begin camera + beginCamera(); +snippet cam end camera + endCamera(); +snippet cam print camera + printCamera(); +snippet cam print camera projection + printProjection(); +snippet cam perspective camera + perspective(${1:fov}, ${2:aspect}, ${3:zNear}, ${4:zFar}); +snippet cam frustrum + frustrum(${1:left}, ${2:right}, ${3:bottom}, ${4:top}, ${5:near}, ${6:far}); + +#transformations +snippet trans rotate + rotate${1:X}(${1:angle}); +snippet trans translate + translate(${1:x}, ${2:y}${3:, }${4:z}); +snippet trans scale size + scale(${1:size}); +snippet trans scale + scale(${1:x}, ${2:y}${3:, }${4:z}); + +#coordinates +snippet coord + ${1:model/screen}${2:X}(${3:x}, ${4:y}, ${5:z}); + +#effects +snippet fx brightness + brightness(${1:color}); +snippet fx lerp color + lerpColor(${1:c1}, ${2:c2}, ${3:amt}); +snippet fx saturation + saturation(${1:color}); +snippet fx hue + hue(${1:color}); +snippet fx alpha + alpha(${1:color}); +snippet fx tint + tint(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet fx notint + noTint(); + +#pixel +snippet px set pixel + set(${1:x}, ${2:y}, ${3:color/image}); +snippet px update pixel + updatePixels(); +snippet px load pixel + loadPixels(); +snippet px pixels + pixels[${1:index}] +snippet px get pixel + get(${1:x}, ${2:y}${3:, }${4:width}${5:, }${6:height}); + +#geometric figures +snippet geof triangle + triangle(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x3}, ${6:y3}); +snippet geof line + line(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}); +snippet geof line 3D + line(${1:x1}, ${2:y1}, ${3:z1}, ${4:x2}, ${5:y2}, ${6:z2}); +snippet geof arc + arc(${1:x}, ${2:y}, ${3:width}, ${4:height}, ${5:start}, ${6:stop}); +snippet geof point + point(${1:x}, ${2:y}${3:, }${4:z}); +snippet geof quad + quad(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x3}, ${6:y3}, ${7:x4}, ${8:y4}); +snippet geof ellipse + ellipse(${1:x}, ${2:y}, ${3:width}, ${4:height}); +snippet geof rect + rect(${1:x}, ${2:y}, ${3:width}, ${4:height}); +snippet geof box + box(${1:width}, ${2:height}, ${3:depth}); +snippet geof sphere + sphere(${1:radius}); +snippet geof sphere details + sphereDetail(${1:n}); +snippet geof set smooth + smooth(); +snippet geof set no smooth + noSmooth(); + +#array operations +snippet arrop normal split + split("${1:str}"${2: , }${3:delimiter}); +snippet arrop split Tokens + splitTokens(${1:str}${2:, }${3:tokens}); +snippet arrop join + join(${1:strgArray}${2: , }${3:seperator}); +snippet arrop shorten + shorten(${1:array}); +snippet arrop concat + concat(${1:array1}, ${2:array2}); +snippet arrop subset + subset(${1:array}, ${2:offset}); +snippet arrop append + append(${1:array}, ${2:element}); +snippet arrop reverse + reverse(${1:array}); +snippet arrop splice + splice(${1:array}, ${2:value/array2}, ${3:index}); +snippet arrop sort + sort(${1:dataArray}${2:, }${3:count}); +snippet arrop expand + expand(${1:array}${2:, }${3:newSize}); +snippet arrop array copy + arrayCopy(${1:src}, ${2:dest}, ${3:, }${3:length}); + +#string operations +snippet strop str + str("${1:str}"); +snippet strop match + match(${1:str}, ${2:regexp}); +snippet strop trim + trim(${1:str}); +snippet strop nf + nf(${2:value}, ${3:left}${4:, }${5:right}); +snippet strop nfs + nfs(${2:value}, ${3:left}${4:, }${5:right}); +snippet strop nfp + nfp(${2:value}, ${3:left}${4:, }${5:right}); +snippet strop nfc + nfc(${1:value}${2:, }${3:right}); + +#convert +snippet convert unbinary + unbinary("${1:str}"}); +snippet convert hexadecimal + hex(${1:c}); +snippet convert unhex + unhex(${1:c}); +snippet convert binary + binary(${1:value}${2:, }${3:digits}); + +#image operations +snippet image load image + loadImage(${1:filename}); +snippet image image + image(${1:img}, ${2:x}, ${3:y}${4:, }${5:width}${6:, }${7:height}); +snippet copy copy + copy(${1:srcImg}${2:, }${3:x}, ${4:y}, ${5:width}, ${6:height}, ${7:dx}, ${8:dy}, ${9:dwidth}, ${10:dheight}); + + + +#containers +snippet bg + background(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet pg + PGraphics pg; + pg = createGraphics(${1:width}, ${2:height}${3:, }${4:applet}); +snippet pimage + PImage(${1:width}, ${2:height}); + +#UTILS +#nofill +snippet nofill + noFill(); +#fill +snippet fill + fill(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +#red +snippet red + red(${1:color}); +#green +snippet green + green(${1:color}); +#blue +snippet blue + blue(${1:color}); +#status +snippet status + status(${1:text}); +#param +snippet param + param(${1:s}); +#link +snippet link + link(${1:url}${2:, }${3:target}); +#@param +snippet @ + @${1:param/return/private/public} ${1:parameter} ${2:description} From 1d07df0866560f81ec447ab780dac648ee9c35b8 Mon Sep 17 00:00:00 2001 From: stefan Date: Mon, 18 Jun 2012 23:30:07 +0100 Subject: [PATCH 20/46] adding a snippets file for puppet code. Originally created by r.i. pienaar --- snippets/puppet.snippets | 155 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 snippets/puppet.snippets diff --git a/snippets/puppet.snippets b/snippets/puppet.snippets new file mode 100644 index 0000000..f349932 --- /dev/null +++ b/snippets/puppet.snippets @@ -0,0 +1,155 @@ +# Snippets for use with VIM and http://www.vim.org/scripts/script.php?script_id=2540 +# +# Please contact R.I.Pienaar for additions and feedback, +# see it in action @ http://www.devco.net/archives/2009/09/22/vim_and_puppet.php + +# Language Constructs +snippet class + class ${1:`Filename('', 'name')`} { + ${2} + } +snippet node + node "${1:`Filename('', 'fqdn')`}" { + ${2} + } +snippet case + case $${1:variable} { + default: { ${2} } + } +snippet ife + if $${1:variable} { + ${2} + } else { + ${3} + } +snippet if + if $${1:variable} { + ${2} + } +snippet else + else { + ${1} + } +snippet ? + ? { + '${1}' => ${2} + } +# +# blocks etc and general syntax sugar +snippet [ + [ ${1} ]${2} +snippet > + ${1} => ${2} +snippet p: + "puppet://puppet/${1:module name}/${2:file name}" +# +# Functions +snippet alert + alert("${1:message}")${2} +snippet crit + crit("${1:message}")${2} +snippet debug + debug("${1:message}")${2} +snippet defined + defined(${1:Resource}["${2:name}"])${3} +snippet emerg + emerg("${1:message}")${2} +snippet extlookup Simple extlookup + extlookup("${1:variable}")${2} +snippet extlookup Extlookup with defaults + extlookup("${1:variable}", "${2:default}")${3} +snippet extlookup Extlookup with defaults and custom data file + extlookup("${1:variable}", "${2:default}", "${3:data source}")${4} +snippet fail + fail("${1:message}")${2} +snippet info + info("${1:message}")${2} +snippet inline_template + inline_template("<%= ${1} %>")${2} +snippet notice + notice("${1:message}")${2} +snippet realize + realize(${1:Resource}[${2:name}])${3} +snippet regsubst + regsubst(${1:hay stack}, ${2:needle}, "${3:replacement}")${4} +snippet inc + include ${1:classname}${2} +snippet split + split(${1:hay stack}, "${2:patten}")${3} +snippet versioncmp + versioncmp("${1:version}", "${2:version}")${3} +snippet warning + warning("${1:message}")${2} +# +# Types +snippet cron + cron{ "${1:name}": + command => "${2}", + user => "${3:root}", + ${4} => ${5} + } + +snippet exec + exec{ "${1:name}": + command => "${2:$1}", + user => "${3:root}", + ${4} => ${5} + } + +snippet user + user{ "${1:user}": + comment => "${2:$1}", + ensure => present, + managehome => true, + home => "${3:/home/$1}" + } + +snippet group + group{ "${1:group}": + ensure => ${2:present} + } + +snippet host + host{ "${1:hostname}": + ip => ${2:127.0.0.1} + } + +snippet mailalias + mailalias{ "${1:localpart}": + recipient => "${2:recipient}" + } + +snippet mount + mount{ "${1:destination path}": + ensure => ${2:mounted}, + device => "${3:device name or path}" + } + +snippet package + package{ "${1:package name}": + ensure => ${2:present} + } + +snippet yumrepo + yumrepo{ "${1:repo name}": + descr => "${2:$1}", + enabled => ${3:1} + } + +snippet define + define ${1} (${2}) { + ${3} + } + +snippet service + service{ "${1:service}": + enable => ${2:true}, + ensure => ${3:running}, + hasstatus => true, + } + +snippet file + file{ "${1:path}": + ${2} => ${3} + } + From 9982aab77df2b76bd88d9933abd3a42ff81e8f18 Mon Sep 17 00:00:00 2001 From: Brandon Dulaney Date: Sun, 24 Jun 2012 14:41:08 -0500 Subject: [PATCH 21/46] First Commit Alphabetized and organized snippets. Made Print and Error methods more user friendly. Added some more Javadocs snippets. --- snippets/java.snippets | 308 +++++++++++++++++++++++++---------------- 1 file changed, 189 insertions(+), 119 deletions(-) diff --git a/snippets/java.snippets b/snippets/java.snippets index 19a2420..75c1dfe 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -1,91 +1,121 @@ -snippet main - public static void main (String[] args) { - ${1:/* code */} - } -snippet pu - public +## Access Modifiers snippet po protected +snippet pu + public snippet pr private -snippet st - static -snippet fi - final -snippet ab - abstract -snippet re - return -snippet br - break; -snippet de - default: - ${1} -snippet ca - catch(${1:Exception} ${2:e}) ${3} -snippet th - throw -snippet sy - synchronized + +## Annotations +snippet before + @Before + static void ${1:intercept}(${2:args}) { ${3} } +snippet mm + @ManyToMany + ${1} +snippet mo + @ManyToOne + ${1} +snippet om + @OneToMany${1:(cascade=CascadeType.ALL)} + ${2} +snippet oo + @OneToOne + ${1} + +# Basic Java packages and import snippet im import -snippet imp - implements -snippet ext - extends -snippet j.u - java.util -snippet j.i - java.io. snippet j.b java.beans. -snippet j.n - java.net. +snippet j.i + java.io. snippet j.m java.math. -snippet if - if (${1}) ${2} -snippet el - else -snippet elif - else if (${1}) ${2} -snippet wh - while (${1}) ${2} -snippet for - for (${1}; ${2}; ${3}) ${4} -snippet fore - for (${1} : ${2}) ${3} -snippet sw - switch (${1}) ${2} -snippet cs - case ${1}: - ${2} - ${3} -snippet tc - public class ${1:`Filename()`} extends ${2:TestCase} -snippet t - public void test${1:Name}() throws Exception { - ${2} - } -snippet test - @Test - public void test${1:Name}() throws Exception { - ${2} - } +snippet j.n + java.net. +snippet j.u + java.util. + +## Class snippet cl class ${1:`Filename("", "untitled")`} ${2} snippet in interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} -snippet m - ${1:void} ${2:method}(${3}) ${4:throws }${5} -snippet v - ${1:String} ${2:var}${3: = null}${4};${5} +snippet tc + public class ${1:`Filename()`} extends ${2:TestCase} + +## Class Enhancements +snippet ext + extends +snippet imp + implements + +## Comments +snippet /* + /* + * ${1} + */ + +## Constants snippet co static public final ${1:String} ${2:var} = ${3};${4} snippet cos static public final String ${1:var} = "${2}";${3} + +## Control Statements +snippet case + case ${1}: + ${2} +snippet def + default: + ${2} +snippet el + else +snippet elif + else if (${1}) ${2} +snippet if + if (${1}) ${2} +snippet sw + switch (${1}) { + ${2} + } + +## Create a Method +snippet m + ${1:void} ${2:method}(${3}) ${4:throws }${5} + +## Create a Variable +snippet v + ${1:String} ${2:var}${3: = null}${4};${5} + +## Enhancements to Methods, variables, classes, etc. +snippet ab + abstract +snippet fi + final +snippet st + static +snippet sy + synchronized + +## Error Methods +snippet err + System.err.print("${1:Message}"); +snippet errf + System.err.printf("${1:Message}", ${2:exception}); +snippet errln + System.err.println("${1:Message}"); + +## Exception Handling snippet as assert ${1:test} : "${2:Failure message}";${3} +snippet ca + catch(${1:Exception} ${2:e}) ${3} +snippet thr + throw +snippet ths + throws snippet try try { ${3} @@ -97,45 +127,62 @@ snippet tryf } catch(${1:Exception} ${2:e}) { } finally { } -snippet rst - ResultSet ${1:rst}${2: = null}${3};${4} -snippet @au - @author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5")` -snippet mm - @ManyToMany - ${1} -snippet mo - @ManyToOne - ${1} -snippet om - OneToMany${1:(cascade=CascadeType.ALL)} - ${2} -snippet oo - @OneToOne - ${1} -snippet action - public static void ${1:index}(${2:args}) { ${3} } -snippet before - @Before - static void ${1:intercept}(${2:args}) { ${3} } -snippet debug - Logger.debug(${1:param});${2} -snippet error - Logger.error(${1:param});${2} + +## Find Methods snippet findall List<${1:listName}> ${2:items} = ${1}.findAll();${3} snippet findbyid ${1:var} ${2:item} = ${1}.findById(${3});${4} + +## Javadocs +snippet /** + /** + * ${1} + */ +snippet @au + @author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5")` +snippet @br + @brief ${1:Description} +snippet @fi + @file ${1:`Filename()`}.java +snippet @pa + @param ${1:param} +snippet @re + @return ${1:param} + +## Logger Methods +snippet debug + Logger.debug(${1:param});${2} +snippet error + Logger.error(${1:param});${2} snippet info Logger.info(${1:param});${2} -snippet rnf - notFound(${1:param});${2} -snippet rnfin - notFoundIfNull(${1:param});${2} -snippet rr - redirect(${1:param});${2} -snippet ru - unauthorized(${1:param});${2} +snippet warn + Logger.warn(${1:param});${2} + +## Loops +snippet enfor + for (${1} : ${2}) ${3} +snippet for + for (${1}; ${2}; ${3}) ${4} +snippet wh + while (${1}) ${2} + +## Main method +snippet main + public static void main (String[] args) { + ${1:/* code */} + } + +## Print Methods +snippet print + System.out.print("${1:Message"); +snippet printf + System.out.printf("${1:Message", ${2:args}); +snippet println + System.out.println(${1}); + +## Render Methods snippet ren render(${1:param});${2} snippet rena @@ -146,27 +193,50 @@ snippet renj renderJSON(${1:param});${2} snippet renx renderXml(${1:param});${2} -snippet unless - (unless=${1:param});${2} -snippet warn - Logger.warn(${1:param});${2} -snippet sysout - System.out.println(${1}); -snippet syserr - System.err.println(${1}); -snippet /* - /* - * ${1} - */ -snippet /** - /** - * ${1} - */ -snippet prop + +## Setter and Getter Methods +snippet set $1 void set$3($2 $4){ this.$4 = $4; } - +snippet get ${1:public} ${2:String} get${3:}(){ return this.${4:}; } + +## Terminate Methods or Loops +snippet re + return +snippet br + break; + +## Test Methods +snippet t + public void test${1:Name}() throws Exception { + ${2} + } +snippet test + @Test + public void test${1:Name}() throws Exception { + ${2} + } + +## Utils +snippet Sc + Scanner + +## Miscellaneous +snippet action + public static void ${1:index}(${2:args}) { ${3} } +snippet rnf + notFound(${1:param});${2} +snippet rnfin + notFoundIfNull(${1:param});${2} +snippet rr + redirect(${1:param});${2} +snippet rst + ResultSet ${1:rst}${2: = null}${3};${4} +snippet ru + unauthorized(${1:param});${2} +snippet unless + (unless=${1:param});${2} From 533f1141eab73c93cf2effeda2b099a0a308ada8 Mon Sep 17 00:00:00 2001 From: DSIW Date: Sat, 9 Jun 2012 17:17:24 +0200 Subject: [PATCH 22/46] Added encoding to shebang of ruby --- snippets/ruby.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 199c1e3..9e78380 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -5,6 +5,7 @@ # #!/usr/bin/env ruby snippet #! #!/usr/bin/env ruby + # encoding: utf-8 # New Block snippet =b From 933bcd0529a3a81507e4c65029acd511d9eee04f Mon Sep 17 00:00:00 2001 From: DSIW Date: Sat, 9 Jun 2012 17:18:11 +0200 Subject: [PATCH 23/46] Fixed escaping of '"' in snippet tas for ruby --- snippets/ruby.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 9e78380..56cad02 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -528,7 +528,7 @@ snippet nam ${2} end snippet tas - desc "${1:Task description\}" + desc "${1:Task description}" task :${2:task_name => [:dependent, :tasks]} do ${3} end From 0527c5c040881a7853e45a32a2b6d669031bd109 Mon Sep 17 00:00:00 2001 From: DSIW Date: Sat, 9 Jun 2012 17:19:54 +0200 Subject: [PATCH 24/46] Removed trailing whitespace for ruby --- snippets/ruby.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 56cad02..ebb571e 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -534,7 +534,7 @@ snippet tas end # block snippet b - {|${1:var}| ${2}} + { |${1:var}| ${2} } snippet begin begin raise 'A test exception.' From 3cb6bb5b7f0e06ba246981a98fda2c6e32e460b0 Mon Sep 17 00:00:00 2001 From: DSIW Date: Sat, 9 Jun 2012 17:21:54 +0200 Subject: [PATCH 25/46] Replaced bracket pair by spaces in snippet bef,aft for ruby --- snippets/ruby.snippets | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index ebb571e..b9cdfb9 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -555,7 +555,7 @@ snippet pry ############################################# # Rails snippets - for pure Ruby, see above # -############################################# +############################################# snippet art assert_redirected_to ${1::action => "${2:index}"} snippet artnp @@ -589,7 +589,7 @@ snippet crw snippet defcreate def create @${1:model_class_name} = ${2:ModelClassName}.new(params[:$1]) - + respond_to do |wants| if @$1.save flash[:notice] = '$2 was successfully created.' @@ -605,7 +605,7 @@ snippet defdestroy def destroy @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) @$1.destroy - + respond_to do |wants| wants.html { redirect_to($1s_url) } wants.xml { head :ok } @@ -618,7 +618,7 @@ snippet defedit snippet defindex def index @${1:model_class_name} = ${2:ModelClassName}.all - + respond_to do |wants| wants.html # index.html.erb wants.xml { render :xml => @$1s } @@ -627,7 +627,7 @@ snippet defindex snippet defnew def new @${1:model_class_name} = ${2:ModelClassName}.new - + respond_to do |wants| wants.html # new.html.erb wants.xml { render :xml => @$1 } @@ -636,7 +636,7 @@ snippet defnew snippet defshow def show @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) - + respond_to do |wants| wants.html # show.html.erb wants.xml { render :xml => @$1 } @@ -645,7 +645,7 @@ snippet defshow snippet defupdate def update @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) - + respond_to do |wants| if @$1.update_attributes(params[:$1]) flash[:notice] = '$2 was successfully updated.' @@ -776,15 +776,15 @@ snippet sha1 snippet sweeper class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper observe $1 - + def after_save(${2:model_class_name}) expire_cache($2) end - + def after_destroy($2) expire_cache($2) end - + def expire_cache($2) expire_page end @@ -893,7 +893,7 @@ snippet migration def self.up ${2} end - + def self.down end end @@ -923,10 +923,10 @@ snippet cont ${2} end snippet bef - before(:${1:each}) do + before :${1:each} do ${2} end snippet aft - after(:${1:each}) do + after :${1:each} do ${2} end From 55496d503207c9127600ead95b9cbd0281a88ce3 Mon Sep 17 00:00:00 2001 From: DSIW Date: Sat, 9 Jun 2012 17:25:57 +0200 Subject: [PATCH 26/46] Removed empty lines in snippet cla for ruby --- snippets/ruby.snippets | 8 -------- 1 file changed, 8 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index b9cdfb9..e97aec8 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -82,24 +82,18 @@ snippet cla class .. initialize .. end def initialize(${2:args}) ${3} end - - end snippet cla class .. < ParentClass .. initialize .. end class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass} def initialize(${3:args}) ${4} end - - end snippet cla ClassName = Struct .. do .. end ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do def ${3:method_name} ${4} end - - end snippet cla class BlankSlate .. initialize .. end class ${1:BlankSlate} @@ -116,8 +110,6 @@ snippet cla- ${5} end - - end snippet mod module .. end module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} From 54ff2a135477749d5e557aab372c624f1dfeee16 Mon Sep 17 00:00:00 2001 From: DSIW Date: Sun, 10 Jun 2012 19:43:36 +0200 Subject: [PATCH 27/46] Added snippet bun for vim --- snippets/vim.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/vim.snippets b/snippets/vim.snippets index 4b07cdb..329d1e9 100644 --- a/snippets/vim.snippets +++ b/snippets/vim.snippets @@ -41,3 +41,5 @@ snippet au " this one is which you're most likely to use? autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|} ${4} augroup end +snippet bun + Bundle '${1}' From 5d248021544f910c365800b469a5cab9aee80a5d Mon Sep 17 00:00:00 2001 From: DSIW Date: Mon, 25 Jun 2012 22:26:47 +0200 Subject: [PATCH 28/46] Fixed snippet map+ --- snippets/html.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/html.snippets b/snippets/html.snippets index 01374e5..be8b0f6 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -565,7 +565,7 @@ snippet map# snippet map+ - ${6} + ${5}${6} ${7} snippet mark ${1} From 2459f52d95e60d3072538d89b315b787a5c13763 Mon Sep 17 00:00:00 2001 From: Eustaquio Rangel Date: Tue, 26 Jun 2012 08:18:43 -0300 Subject: [PATCH 29/46] Fixed the BlankState class snippet --- snippets/ruby.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index e97aec8..26bdfa5 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -98,6 +98,7 @@ snippet cla ClassName = Struct .. do .. end snippet cla class BlankSlate .. initialize .. end class ${1:BlankSlate} instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ } + end snippet cla class << self .. end class << ${1:self} ${2} From f0b3126f47e1c525d618d49c063c4a1f318bb489 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sun, 1 Jul 2012 14:10:57 +0530 Subject: [PATCH 30/46] Added beerware license to the list of license --- snippets/_.snippets | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/snippets/_.snippets b/snippets/_.snippets index b99f454..081db1c 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -214,4 +214,14 @@ snippet APACHE See the License for the specific language governing permissions and limitations under the License. + ${3} +snippet BEERWARE + ${1:one line to give the program's name and a brief description} + Copyright `strftime("%Y")` ${2:copyright holder} + + Licensed under the "THE BEER-WARE LICENSE" (Revision 42): + ${1:`g:snips_author`} wrote this file. As long as you retain this notice you + can do whatever you want with this stuff. If we meet some day, and you think + this stuff is worth it, you can buy me a beer or coffee in return + ${3} From 0bfbc3a50a5416bc4b7c4148df58d3ff371222ed Mon Sep 17 00:00:00 2001 From: Brandon Dulaney Date: Mon, 2 Jul 2012 16:23:32 -0500 Subject: [PATCH 31/46] Whitespace Fixes I didn't realize this, but snipmate takes into account any and all whitespaces in the snippets. I fixed these by inserting ## in order to keep it straight and clean. Also did some minor bug fixes. --- snippets/java.snippets | 52 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/snippets/java.snippets b/snippets/java.snippets index 75c1dfe..f03c2e0 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -5,7 +5,7 @@ snippet pu public snippet pr private - +## ## Annotations snippet before @Before @@ -22,8 +22,8 @@ snippet om snippet oo @OneToOne ${1} - -# Basic Java packages and import +## +## Basic Java packages and import snippet im import snippet j.b @@ -36,7 +36,7 @@ snippet j.n java.net. snippet j.u java.util. - +## ## Class snippet cl class ${1:`Filename("", "untitled")`} ${2} @@ -44,25 +44,25 @@ snippet in interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} snippet tc public class ${1:`Filename()`} extends ${2:TestCase} - +## ## Class Enhancements snippet ext extends snippet imp implements - +## ## Comments snippet /* /* * ${1} */ - +## ## Constants snippet co static public final ${1:String} ${2:var} = ${3};${4} snippet cos static public final String ${1:var} = "${2}";${3} - +## ## Control Statements snippet case case ${1}: @@ -80,15 +80,15 @@ snippet sw switch (${1}) { ${2} } - +## ## Create a Method snippet m ${1:void} ${2:method}(${3}) ${4:throws }${5} - +## ## Create a Variable snippet v ${1:String} ${2:var}${3: = null}${4};${5} - +## ## Enhancements to Methods, variables, classes, etc. snippet ab abstract @@ -98,7 +98,7 @@ snippet st static snippet sy synchronized - +## ## Error Methods snippet err System.err.print("${1:Message}"); @@ -106,7 +106,7 @@ snippet errf System.err.printf("${1:Message}", ${2:exception}); snippet errln System.err.println("${1:Message}"); - +## ## Exception Handling snippet as assert ${1:test} : "${2:Failure message}";${3} @@ -127,13 +127,13 @@ snippet tryf } catch(${1:Exception} ${2:e}) { } finally { } - +## ## Find Methods snippet findall List<${1:listName}> ${2:items} = ${1}.findAll();${3} snippet findbyid ${1:var} ${2:item} = ${1}.findById(${3});${4} - +## ## Javadocs snippet /** /** @@ -149,7 +149,7 @@ snippet @pa @param ${1:param} snippet @re @return ${1:param} - +## ## Logger Methods snippet debug Logger.debug(${1:param});${2} @@ -159,7 +159,7 @@ snippet info Logger.info(${1:param});${2} snippet warn Logger.warn(${1:param});${2} - +## ## Loops snippet enfor for (${1} : ${2}) ${3} @@ -167,13 +167,13 @@ snippet for for (${1}; ${2}; ${3}) ${4} snippet wh while (${1}) ${2} - +## ## Main method snippet main public static void main (String[] args) { ${1:/* code */} } - +## ## Print Methods snippet print System.out.print("${1:Message"); @@ -181,7 +181,7 @@ snippet printf System.out.printf("${1:Message", ${2:args}); snippet println System.out.println(${1}); - +## ## Render Methods snippet ren render(${1:param});${2} @@ -193,7 +193,7 @@ snippet renj renderJSON(${1:param});${2} snippet renx renderXml(${1:param});${2} - +## ## Setter and Getter Methods snippet set $1 void set$3($2 $4){ @@ -203,13 +203,13 @@ snippet get ${1:public} ${2:String} get${3:}(){ return this.${4:}; } - +## ## Terminate Methods or Loops snippet re return snippet br break; - +## ## Test Methods snippet t public void test${1:Name}() throws Exception { @@ -220,11 +220,11 @@ snippet test public void test${1:Name}() throws Exception { ${2} } - +## ## Utils snippet Sc Scanner - +## ## Miscellaneous snippet action public static void ${1:index}(${2:args}) { ${3} } @@ -234,8 +234,6 @@ snippet rnfin notFoundIfNull(${1:param});${2} snippet rr redirect(${1:param});${2} -snippet rst - ResultSet ${1:rst}${2: = null}${3};${4} snippet ru unauthorized(${1:param});${2} snippet unless From 80f98cd938a68167417f7570ee0dbf90625c3f61 Mon Sep 17 00:00:00 2001 From: Zaven Muradyan Date: Tue, 3 Jul 2012 00:40:37 -0700 Subject: [PATCH 32/46] Add pprint snippet for Python --- snippets/python.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index 4386210..b3b1e9b 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -121,6 +121,8 @@ snippet ipdb # ipython debugger (pdbbb) snippet pdbbb import pdbpp; pdbpp.set_trace() +snippet pprint + import pprint; pprint.pprint(${1})${2} snippet " """ ${1:doc} From cd5ceff6fc592dc8cc3ef48234b17d1fdd0ec035 Mon Sep 17 00:00:00 2001 From: Stephen Woods Date: Tue, 3 Jul 2012 21:25:00 +0100 Subject: [PATCH 33/46] Fixed indentation for cs.snippets --- snippets/cs.snippets | 98 ++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/snippets/cs.snippets b/snippets/cs.snippets index fd8c255..725f8b7 100644 --- a/snippets/cs.snippets +++ b/snippets/cs.snippets @@ -59,28 +59,28 @@ # entry point snippet sim public static int Main(string[] args) { - ${1} - return 0; + ${1} + return 0; } snippet simc public class Application { - public static int Main(string[] args) { - ${1} - return 0; - } + public static int Main(string[] args) { + ${1} + return 0; + } } # if condition snippet if if (${1}) { - ${2} + ${2} } snippet el else { - ${1} + ${1} } snippet ifs if (${1}) - ${2} + ${2} # ternary conditional snippet t ${1} ? ${2} : ${3} @@ -89,77 +89,77 @@ snippet ? # do while loop snippet do do { - ${2} + ${2} } while (${1}); # while loop snippet wh while (${1}) { - ${2} + ${2} } # for loop snippet for for (int ${1:i} = 0; $1 < ${2:count}; $1${3:++}) { - ${4} + ${4} } # foreach snippet fore foreach (var ${1:entry} in ${2}) { - ${3} + ${3} } snippet foreach foreach (var ${1:entry} in ${2}) { - ${3} + ${3} } snippet each foreach (var ${1:entry} in ${2}) { - ${3} + ${3} } # interfaces snippet interface public interface ${1:`Filename()`} { - ${2} + ${2} } snippet if+ public interface ${1:`Filename()`} { - ${2} + ${2} } # class bodies snippet class public class ${1:`Filename()`} { - ${2} + ${2} } snippet cls ${2:public} class ${1:`Filename()`} { - ${3} + ${3} } snippet cls+ public class ${1:`Filename()`} { - ${2} + ${2} } snippet cls+^ public static class ${1:`Filename()`} { - ${2} + ${2} } snippet cls& internal class ${1:`Filename()`} { - ${2} + ${2} } snippet cls&^ internal static class ${1:`Filename()`} { - ${2} + ${2} } snippet cls| protected class ${1:`Filename()`} { - ${2} + ${2} } snippet cls|% protected abstract class ${1:`Filename()`} { - ${2} + ${2} } # constructor snippet ctor public ${1:`Filename()`}() { - ${2} + ${2} } # properties - auto properties by default. # default type is int with layout get / set. @@ -259,101 +259,101 @@ snippet ps- # members - void snippet m ${1:public} ${2:void} ${3:}(${4:}) { - ${5:} + ${5:} } snippet m+ public ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } snippet m& internal ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } snippet m| protected ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } snippet m- private ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } # members - int snippet mi ${1:public} int ${2:}(${3:}) { - ${4:return 0;} + ${4:return 0;} } snippet mi+ public int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } snippet mi& internal int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } snippet mi| protected int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } snippet mi- private int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } # members - bool snippet mb ${1:public} bool ${2:}(${3:}) { - ${4:return false;} + ${4:return false;} } snippet mb+ public bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } snippet mb& internal bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } snippet mb| protected bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } snippet mb- private bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } # members - string snippet ms ${1:public} string ${2:}(${3:}) { - ${4:return "";} + ${4:return "";} } snippet ms+ public string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } snippet ms& internal string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } snippet ms| protected string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } snippet ms- private string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } # structure snippet struct public struct ${1:`Filename()`} { - ${2} + ${2} } # enumeration snippet enum public enum ${1} { - ${2} + ${2} } # preprocessor directives snippet #if #if - ${1} + ${1} #endif # inline xml documentation snippet /// From 737aec3ebc4cb8229f34e7ed32c97a1756f5d635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Guimar=C3=A3es?= Date: Wed, 4 Jul 2012 15:44:10 -0300 Subject: [PATCH 34/46] Create '=' and '%' shortcuts for eruby files --- snippets/eruby.snippets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snippets/eruby.snippets b/snippets/eruby.snippets index f856265..8a9fb75 100644 --- a/snippets/eruby.snippets +++ b/snippets/eruby.snippets @@ -7,6 +7,10 @@ snippet rc <% ${1} %> snippet rce <%= ${1} %>${2} +snippet % + <% ${1} %> +snippet = + <%= ${1} %>${2} snippet end <% end %>${1} snippet ead From 8dd16c1caa52c4203ee91349449e9404b47ce21d Mon Sep 17 00:00:00 2001 From: troydm Date: Fri, 20 Jul 2012 15:15:09 +0400 Subject: [PATCH 35/46] java set snippet fixed --- snippets/java.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/java.snippets b/snippets/java.snippets index f03c2e0..fb27b9c 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -196,7 +196,7 @@ snippet renx ## ## Setter and Getter Methods snippet set - $1 void set$3($2 $4){ + ${1:public} void set${3:}(${2:String} ${4:}){ this.$4 = $4; } snippet get From 6c45e042f8e3b0a6c7b108886c06e3f9eccc037f Mon Sep 17 00:00:00 2001 From: Chris Nicola Date: Sun, 22 Jul 2012 13:05:17 -0700 Subject: [PATCH 36/46] Fixes the spacing for the eruby yield snippet --- snippets/eruby.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/eruby.snippets b/snippets/eruby.snippets index 8a9fb75..be1c7ec 100644 --- a/snippets/eruby.snippets +++ b/snippets/eruby.snippets @@ -40,7 +40,7 @@ snippet lica snippet licai <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${3:edit}', :id => ${4:@item} %> snippet yield - <%= yield${1::content_symbol}%>${2} + <%= yield ${1::content_symbol} %>${2} snippet conf <% content_for :${1:head} do %> ${2} From c59a7f2c49bcf0b7eb91498cb4184b09818a9149 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 08:09:49 +1200 Subject: [PATCH 37/46] use parent instead of base --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 4ba985d..0037cc3 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,7 +82,7 @@ snippet fore snippet cl package ${1:ClassName}; - use base qw(${2:ParentClass}); + use parent qw(${2:ParentClass}); sub new { my $class = shift; From 79b4377ee3caf2060b4ffdcc3ccf39fbcdde5ded Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 18:21:55 +1200 Subject: [PATCH 38/46] experimenting with a couple new package constructs --- snippets/perl.snippets | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 0037cc3..d77d748 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,16 +82,30 @@ snippet fore snippet cl package ${1:ClassName}; - use parent qw(${2:ParentClass}); + #use parent qw(${2:ParentClass}); - sub new { - my $class = shift; - $class = ref $class if ref $class; - my $self = bless {}, $class; - $self; - } 1;${3} + + __END__ + +# Package block syntax +snippet package + package ${1:ClassName} ${2:version} { + + ${3:#}use Moose; + + ${4:#}use parent qw(${5:ParentClass}); + ${3:#}extends qw(${5:ParentClass}); + + ${6:#...} + + } + + 1; + + __END__ + # Read File snippet slurp my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; From b272f87f1f05ed81e57fc4356507a38892b5f8b8 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 20:32:53 +1200 Subject: [PATCH 39/46] experimenting with some new perl features --- snippets/perl.snippets | 86 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index d77d748..2796658 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -83,29 +83,51 @@ snippet cl package ${1:ClassName}; #use parent qw(${2:ParentClass}); - - - 1;${3} - - __END__ - -# Package block syntax -snippet package - package ${1:ClassName} ${2:version} { - - ${3:#}use Moose; - - ${4:#}use parent qw(${5:ParentClass}); - ${3:#}extends qw(${5:ParentClass}); - - ${6:#...} - - } + + ${3:#...} 1; __END__ +# Moose package +snippet moosecl + package ${1:ClassName}; + + use Moose; + #extends '${2:# ParentClass}'; + + ${3:#...} + + 1; + + + __END__ + + +# Package syntax perl >= 5.12.0 +snippet package + package ${1:ClassName} ${2:0.99}; + + ${3:#...} + + 1; + + __END__ + + +#moose +snippet moose + use Moose; + +# moose extends +snippet extends + extends qw(${1:Parent Class}); + +# parent +snippet parent + use parent qw(${1:Parent Class}); + # Read File snippet slurp my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> }; @@ -190,7 +212,6 @@ snippet hslice @{ ${1:hash} }{ ${2:array} } - # map snippet map map { ${2: body } } ${1: @array } ; @@ -276,33 +297,6 @@ snippet parg -# Moose package -snippet moosecl - package ${1:ClassName}; - - use Moose; - #extends '${2:# ParentClass}'; - - ${6:# body of class} - - 1; - - - __END__ - - =head1 NAME - - $1 - ${3:ShortDesc} - - =head1 SYNOPSIS - - ${4:# synopsis...} - - =head1 DESCRIPTION - - ${5:# longer description...} - - # Moose has snippet has has ${1:attribute} => ( From 313ec98d836305ae913344a4ba71a8926e3440f3 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 16 May 2012 22:05:44 +1200 Subject: [PATCH 40/46] make package definitions more generic --- snippets/perl.snippets | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 2796658..8164130 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -82,9 +82,7 @@ snippet fore snippet cl package ${1:ClassName}; - #use parent qw(${2:ParentClass}); - - ${3:#...} + ${2:#...} 1; @@ -93,7 +91,7 @@ snippet cl # Moose package snippet moosecl package ${1:ClassName}; - + use Moose; #extends '${2:# ParentClass}'; From af4851445519c4ee7df3c1f31f1d000e22e0ef88 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:27:09 +1200 Subject: [PATCH 41/46] changing package template and a few others --- snippets/perl.snippets | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 8164130..ef30667 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -79,7 +79,7 @@ snippet for snippet fore ${1:expression} foreach @${2:array};${3} # Package -snippet cl +snippet package package ${1:ClassName}; ${2:#...} @@ -88,23 +88,9 @@ snippet cl __END__ -# Moose package -snippet moosecl - package ${1:ClassName}; - - use Moose; - #extends '${2:# ParentClass}'; - - ${3:#...} - - 1; - - - __END__ - # Package syntax perl >= 5.12.0 -snippet package +snippet packagev512 package ${1:ClassName} ${2:0.99}; ${3:#...} @@ -117,6 +103,8 @@ snippet package #moose snippet moose use Moose; + use namespace::autoclean; + #extends '${2:# ParentClass}'; # moose extends snippet extends @@ -298,10 +286,12 @@ snippet parg # Moose has snippet has has ${1:attribute} => ( - is => '${2:ro|rw}', + is => '${2:ro|rw}', isa => '${3:Str|Int|HashRef|ArrayRef|etc}', - default => ${4:defaultvalue} - ,${5:# other attributes} + default => sub { + ${4:defaultvalue} + }, + ${5:# other attributes} ); @@ -309,14 +299,14 @@ snippet has snippet override override ${1:attribute} => sub { ${2:# my $self = shift;}; - ${3:# my ($self,$args) = @_;}; + ${3:# my ($self, $args) = @_;}; }; # use test classes snippet tuse use Test::More; - use Test::Deep (); + use Test::Deep; # (); # uncomment to stop prototype errors use Test::Exception; # local test lib @@ -353,6 +343,7 @@ snippet tprep my $self = shift; ${4:# body} } + # cause failures to print stack trace snippet debug_trace use Carp; # 'verbose'; From 2abf84e6b90d9fb2c38929048bff2da1cb968b40 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:37:23 +1200 Subject: [PATCH 42/46] experimenting with file name in package snippet --- snippets/perl.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index ef30667..9afdee6 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -91,7 +91,7 @@ snippet package # Package syntax perl >= 5.12.0 snippet packagev512 - package ${1:ClassName} ${2:0.99}; + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; ${3:#...} @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - #extends '${2:# ParentClass}'; + ${1:#}extends '${2:# ParentClass}'; # moose extends snippet extends From a42eb6a320285a522847b04e678804850beb6c48 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Wed, 25 Jul 2012 22:43:24 +1200 Subject: [PATCH 43/46] substitute regular package name --- snippets/perl.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 9afdee6..79462fc 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -80,7 +80,7 @@ snippet fore ${1:expression} foreach @${2:array};${3} # Package snippet package - package ${1:ClassName}; + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}; ${2:#...} @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}extends '${2:# ParentClass}'; + ${1:#}extends '${2:ParentClass}'; # moose extends snippet extends From 2f701a905899aac4b364943d0803ddee84b955e2 Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Thu, 26 Jul 2012 09:57:26 +1200 Subject: [PATCH 44/46] put extends in a BEGIN block --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 79462fc..dbe9288 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}extends '${2:ParentClass}'; + ${1:#}BEGIN {extends '${2:ParentClass}}'; # moose extends snippet extends From 0d5ecadc576ad095bcdf33c010340ac1e79d1040 Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Thu, 26 Jul 2012 16:07:33 +1200 Subject: [PATCH 45/46] fix quote on moose snippet --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index dbe9288..024aee1 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -104,7 +104,7 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}BEGIN {extends '${2:ParentClass}}'; + ${1:#}BEGIN {extends '${2:ParentClass}'}; # moose extends snippet extends From c805b4f24131b05ee85e2a77187a444a260f9639 Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Thu, 26 Jul 2012 16:08:11 +1200 Subject: [PATCH 46/46] put in a goto point to jump to --- snippets/perl.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 024aee1..6416180 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -105,6 +105,7 @@ snippet moose use Moose; use namespace::autoclean; ${1:#}BEGIN {extends '${2:ParentClass}'}; + ${3} # moose extends snippet extends