From 64e5027d10bb28bdd5d4728578318f2368266d81 Mon Sep 17 00:00:00 2001 From: Zhang Chiyuan Date: Wed, 28 Jan 2009 07:04:27 +0000 Subject: [PATCH] Added grouping support for snippets (Issue 30) --- snippets/text-mode/html-mode/dd | 1 + snippets/text-mode/html-mode/dl | 1 + snippets/text-mode/html-mode/dl.id | 1 + snippets/text-mode/html-mode/doctype | 1 + snippets/text-mode/html-mode/doctype.xhml1 | 1 + snippets/text-mode/html-mode/doctype.xhtml1_1 | 1 + .../text-mode/html-mode/doctype.xhtml1_strict | 1 + .../html-mode/doctype.xhtml1_transitional | 1 + snippets/text-mode/html-mode/dt | 1 + snippets/text-mode/html-mode/h1 | 1 + snippets/text-mode/html-mode/h2 | 1 + snippets/text-mode/html-mode/h3 | 1 + snippets/text-mode/html-mode/h4 | 1 + snippets/text-mode/html-mode/h5 | 1 + snippets/text-mode/html-mode/h6 | 1 + snippets/text-mode/html-mode/li | 1 + snippets/text-mode/html-mode/li.class | 1 + snippets/text-mode/html-mode/meta | 1 + snippets/text-mode/html-mode/meta.http-equiv | 1 + snippets/text-mode/html-mode/ol | 1 + snippets/text-mode/html-mode/ol.class | 1 + snippets/text-mode/html-mode/ol.id | 1 + snippets/text-mode/html-mode/table | 1 + snippets/text-mode/html-mode/td | 1 + snippets/text-mode/html-mode/th | 1 + snippets/text-mode/html-mode/tr | 1 + snippets/text-mode/html-mode/ul | 1 + snippets/text-mode/html-mode/ul.class | 1 + snippets/text-mode/html-mode/ul.id | 1 + snippets/text-mode/nxml-mode/doctype | 1 + .../text-mode/nxml-mode/doctype.xhtml1_strict | 1 + .../nxml-mode/doctype.xhtml1_transitional | 1 + snippets/text-mode/nxml-mode/h1 | 1 + snippets/text-mode/nxml-mode/h2 | 1 + snippets/text-mode/nxml-mode/h3 | 1 + snippets/text-mode/nxml-mode/h4 | 1 + snippets/text-mode/nxml-mode/h5 | 1 + snippets/text-mode/nxml-mode/h6 | 1 + snippets/text-mode/nxml-mode/meta | 1 + snippets/text-mode/ruby-mode/# | 1 + snippets/text-mode/ruby-mode/=b | 3 ++ snippets/text-mode/ruby-mode/Comp | 1 + snippets/text-mode/ruby-mode/all | 1 + snippets/text-mode/ruby-mode/am | 1 + snippets/text-mode/ruby-mode/any | 1 + snippets/text-mode/ruby-mode/app | 1 + snippets/text-mode/ruby-mode/bm | 1 + snippets/text-mode/ruby-mode/case | 1 + snippets/text-mode/ruby-mode/cla | 1 + snippets/text-mode/ruby-mode/classify | 1 + snippets/text-mode/ruby-mode/cls | 1 + snippets/text-mode/ruby-mode/collect | 1 + snippets/text-mode/ruby-mode/dee | 1 + snippets/text-mode/ruby-mode/deli | 1 + snippets/text-mode/ruby-mode/det | 1 + snippets/text-mode/ruby-mode/dow | 6 +++ snippets/text-mode/ruby-mode/ea | 1 + snippets/text-mode/ruby-mode/eac | 1 + snippets/text-mode/ruby-mode/eai | 1 + snippets/text-mode/ruby-mode/eav | 1 + snippets/text-mode/ruby-mode/eawi | 1 + snippets/text-mode/ruby-mode/forin | 1 + snippets/text-mode/ruby-mode/if | 1 + snippets/text-mode/ruby-mode/ife | 1 + snippets/text-mode/ruby-mode/inject | 1 + snippets/text-mode/ruby-mode/mm | 1 + snippets/text-mode/ruby-mode/r | 1 + snippets/text-mode/ruby-mode/rb | 1 + snippets/text-mode/ruby-mode/reject | 1 + snippets/text-mode/ruby-mode/req | 1 + snippets/text-mode/ruby-mode/rreq | 1 + snippets/text-mode/ruby-mode/rw | 1 + snippets/text-mode/ruby-mode/select | 1 + snippets/text-mode/ruby-mode/tim | 4 ++ snippets/text-mode/ruby-mode/until | 6 +++ snippets/text-mode/ruby-mode/upt | 6 +++ snippets/text-mode/ruby-mode/w | 1 + snippets/text-mode/ruby-mode/when | 6 +++ snippets/text-mode/ruby-mode/while | 6 +++ snippets/text-mode/ruby-mode/y | 1 + snippets/text-mode/ruby-mode/zip | 1 + yasnippet.el | 53 +++++++++++++------ 82 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 snippets/text-mode/ruby-mode/dow create mode 100644 snippets/text-mode/ruby-mode/tim create mode 100644 snippets/text-mode/ruby-mode/until create mode 100644 snippets/text-mode/ruby-mode/upt create mode 100644 snippets/text-mode/ruby-mode/when create mode 100644 snippets/text-mode/ruby-mode/while diff --git a/snippets/text-mode/html-mode/dd b/snippets/text-mode/html-mode/dd index 7e339c0..8120b13 100644 --- a/snippets/text-mode/html-mode/dd +++ b/snippets/text-mode/html-mode/dd @@ -1,4 +1,5 @@ #contributor : Rodrigo Setti #name :
...
+#group : list # --
$1
\ No newline at end of file diff --git a/snippets/text-mode/html-mode/dl b/snippets/text-mode/html-mode/dl index a75c875..be11bb5 100644 --- a/snippets/text-mode/html-mode/dl +++ b/snippets/text-mode/html-mode/dl @@ -1,5 +1,6 @@ #contributor : Rodrigo Setti #name :
...
+#group : list # --
$0 diff --git a/snippets/text-mode/html-mode/dl.id b/snippets/text-mode/html-mode/dl.id index f635606..16aba53 100644 --- a/snippets/text-mode/html-mode/dl.id +++ b/snippets/text-mode/html-mode/dl.id @@ -1,5 +1,6 @@ #contributor : Rodrigo Setti #name :
...
+#group : list # --
$0 diff --git a/snippets/text-mode/html-mode/doctype b/snippets/text-mode/html-mode/doctype index 5e678d5..a60dfb6 100644 --- a/snippets/text-mode/html-mode/doctype +++ b/snippets/text-mode/html-mode/doctype @@ -1,3 +1,4 @@ #name : Doctype HTML 4.01 Strict +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/html-mode/doctype.xhml1 b/snippets/text-mode/html-mode/doctype.xhml1 index c5cfb6f..5d95e07 100644 --- a/snippets/text-mode/html-mode/doctype.xhml1 +++ b/snippets/text-mode/html-mode/doctype.xhml1 @@ -1,3 +1,4 @@ #name : DocType XHTML 1.0 frameset +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/html-mode/doctype.xhtml1_1 b/snippets/text-mode/html-mode/doctype.xhtml1_1 index 72076c0..fec46d7 100644 --- a/snippets/text-mode/html-mode/doctype.xhtml1_1 +++ b/snippets/text-mode/html-mode/doctype.xhtml1_1 @@ -1,3 +1,4 @@ #name : DocType XHTML 1.1 +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/html-mode/doctype.xhtml1_strict b/snippets/text-mode/html-mode/doctype.xhtml1_strict index 176616b..20d95d3 100644 --- a/snippets/text-mode/html-mode/doctype.xhtml1_strict +++ b/snippets/text-mode/html-mode/doctype.xhtml1_strict @@ -1,3 +1,4 @@ #name : DocType XHTML 1.0 Strict +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/html-mode/doctype.xhtml1_transitional b/snippets/text-mode/html-mode/doctype.xhtml1_transitional index d6b6bae..c5255fc 100644 --- a/snippets/text-mode/html-mode/doctype.xhtml1_transitional +++ b/snippets/text-mode/html-mode/doctype.xhtml1_transitional @@ -1,3 +1,4 @@ #name : DocType XHTML 1.0 Transitional +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/html-mode/dt b/snippets/text-mode/html-mode/dt index bd950f7..f385cec 100644 --- a/snippets/text-mode/html-mode/dt +++ b/snippets/text-mode/html-mode/dt @@ -1,4 +1,5 @@ #contributor : Rodrigo Setti #name :
...
+#group : list # --
$1
\ No newline at end of file diff --git a/snippets/text-mode/html-mode/h1 b/snippets/text-mode/html-mode/h1 index 614c626..414e457 100644 --- a/snippets/text-mode/html-mode/h1 +++ b/snippets/text-mode/html-mode/h1 @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :

...

+#group : header # --

$1

\ No newline at end of file diff --git a/snippets/text-mode/html-mode/h2 b/snippets/text-mode/html-mode/h2 index 1d7c8a0..3722a29 100644 --- a/snippets/text-mode/html-mode/h2 +++ b/snippets/text-mode/html-mode/h2 @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :

...

+#group : header # --

$1

\ No newline at end of file diff --git a/snippets/text-mode/html-mode/h3 b/snippets/text-mode/html-mode/h3 index 321877c..a1eaab1 100644 --- a/snippets/text-mode/html-mode/h3 +++ b/snippets/text-mode/html-mode/h3 @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :

...

+#group : header # --

$1

\ No newline at end of file diff --git a/snippets/text-mode/html-mode/h4 b/snippets/text-mode/html-mode/h4 index 49af37b..df71628 100644 --- a/snippets/text-mode/html-mode/h4 +++ b/snippets/text-mode/html-mode/h4 @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :

...

+#group : header # --

$1

\ No newline at end of file diff --git a/snippets/text-mode/html-mode/h5 b/snippets/text-mode/html-mode/h5 index dbce14c..0109822 100644 --- a/snippets/text-mode/html-mode/h5 +++ b/snippets/text-mode/html-mode/h5 @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :
...
+#group : header # --
$1
\ No newline at end of file diff --git a/snippets/text-mode/html-mode/h6 b/snippets/text-mode/html-mode/h6 index 855ef7f..21c718f 100644 --- a/snippets/text-mode/html-mode/h6 +++ b/snippets/text-mode/html-mode/h6 @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :
...
+#group : header # --
$1
\ No newline at end of file diff --git a/snippets/text-mode/html-mode/li b/snippets/text-mode/html-mode/li index 93f9c4c..c5139fa 100644 --- a/snippets/text-mode/html-mode/li +++ b/snippets/text-mode/html-mode/li @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :
  • ...
  • +#group : list # --
  • $1
  • \ No newline at end of file diff --git a/snippets/text-mode/html-mode/li.class b/snippets/text-mode/html-mode/li.class index 9f0443c..90f0c65 100644 --- a/snippets/text-mode/html-mode/li.class +++ b/snippets/text-mode/html-mode/li.class @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name :
  • ...
  • +#group : list # --
  • $2
  • \ No newline at end of file diff --git a/snippets/text-mode/html-mode/meta b/snippets/text-mode/html-mode/meta index b729207..30319ef 100644 --- a/snippets/text-mode/html-mode/meta +++ b/snippets/text-mode/html-mode/meta @@ -1,4 +1,5 @@ #contributor : Jimmy Wu +#group : meta #name : # -- \ No newline at end of file diff --git a/snippets/text-mode/html-mode/meta.http-equiv b/snippets/text-mode/html-mode/meta.http-equiv index 7e21a8e..c059a44 100644 --- a/snippets/text-mode/html-mode/meta.http-equiv +++ b/snippets/text-mode/html-mode/meta.http-equiv @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name : +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/html-mode/ol b/snippets/text-mode/html-mode/ol index 3fa3fd8..58899fa 100644 --- a/snippets/text-mode/html-mode/ol +++ b/snippets/text-mode/html-mode/ol @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name :
      ...
    +#group : list # --
      $0 diff --git a/snippets/text-mode/html-mode/ol.class b/snippets/text-mode/html-mode/ol.class index 3b7b1e3..b091f08 100644 --- a/snippets/text-mode/html-mode/ol.class +++ b/snippets/text-mode/html-mode/ol.class @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name :
        ...
      +#group : list # --
        $0 diff --git a/snippets/text-mode/html-mode/ol.id b/snippets/text-mode/html-mode/ol.id index b906264..13c7c06 100644 --- a/snippets/text-mode/html-mode/ol.id +++ b/snippets/text-mode/html-mode/ol.id @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name :
          ...
        +#group : list # --
          $0 diff --git a/snippets/text-mode/html-mode/table b/snippets/text-mode/html-mode/table index 0dded23..561614f 100644 --- a/snippets/text-mode/html-mode/table +++ b/snippets/text-mode/html-mode/table @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name : ...
          +#group : table # -- $0 diff --git a/snippets/text-mode/html-mode/td b/snippets/text-mode/html-mode/td index 8a9b791..4f494eb 100644 --- a/snippets/text-mode/html-mode/td +++ b/snippets/text-mode/html-mode/td @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name : +#group : table # -- $2 \ No newline at end of file diff --git a/snippets/text-mode/html-mode/th b/snippets/text-mode/html-mode/th index e6b8e0a..3b5fab1 100644 --- a/snippets/text-mode/html-mode/th +++ b/snippets/text-mode/html-mode/th @@ -1,4 +1,5 @@ #contributor : Jimmy Wu #name : +#group : table # -- $2 \ No newline at end of file diff --git a/snippets/text-mode/html-mode/tr b/snippets/text-mode/html-mode/tr index 210ec45..3878a1c 100644 --- a/snippets/text-mode/html-mode/tr +++ b/snippets/text-mode/html-mode/tr @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name : ... +#group : table # -- $0 diff --git a/snippets/text-mode/html-mode/ul b/snippets/text-mode/html-mode/ul index 1262154..981e6e7 100644 --- a/snippets/text-mode/html-mode/ul +++ b/snippets/text-mode/html-mode/ul @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name :
            ...
          +#group : list # --
            $0 diff --git a/snippets/text-mode/html-mode/ul.class b/snippets/text-mode/html-mode/ul.class index 6c59820..c1e3e91 100644 --- a/snippets/text-mode/html-mode/ul.class +++ b/snippets/text-mode/html-mode/ul.class @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name :
              ...
            +#group : list # --
              $0 diff --git a/snippets/text-mode/html-mode/ul.id b/snippets/text-mode/html-mode/ul.id index 76146d3..ababf37 100644 --- a/snippets/text-mode/html-mode/ul.id +++ b/snippets/text-mode/html-mode/ul.id @@ -1,5 +1,6 @@ #contributor : Jimmy Wu #name :
                ...
              +#group : list # --
                $0 diff --git a/snippets/text-mode/nxml-mode/doctype b/snippets/text-mode/nxml-mode/doctype index 8974132..3fdcf17 100644 --- a/snippets/text-mode/nxml-mode/doctype +++ b/snippets/text-mode/nxml-mode/doctype @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name : DocType XHTML 1.1 +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/doctype.xhtml1_strict b/snippets/text-mode/nxml-mode/doctype.xhtml1_strict index d2c66d8..eca5860 100644 --- a/snippets/text-mode/nxml-mode/doctype.xhtml1_strict +++ b/snippets/text-mode/nxml-mode/doctype.xhtml1_strict @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name : DocType XHTML 1.0 Strict +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/doctype.xhtml1_transitional b/snippets/text-mode/nxml-mode/doctype.xhtml1_transitional index 3cef6e8..fba232a 100644 --- a/snippets/text-mode/nxml-mode/doctype.xhtml1_transitional +++ b/snippets/text-mode/nxml-mode/doctype.xhtml1_transitional @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name : DocType XHTML 1.0 Transitional +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/h1 b/snippets/text-mode/nxml-mode/h1 index 388ec77..bc72fd6 100644 --- a/snippets/text-mode/nxml-mode/h1 +++ b/snippets/text-mode/nxml-mode/h1 @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name :

                ...

                +#group : header # --

                $1

                \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/h2 b/snippets/text-mode/nxml-mode/h2 index 092abfe..b790e56 100644 --- a/snippets/text-mode/nxml-mode/h2 +++ b/snippets/text-mode/nxml-mode/h2 @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name :

                ...

                +#group : header # --

                $1

                \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/h3 b/snippets/text-mode/nxml-mode/h3 index a17eccb..7dfd9d7 100644 --- a/snippets/text-mode/nxml-mode/h3 +++ b/snippets/text-mode/nxml-mode/h3 @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name :

                ...

                +#group : header # --

                $1

                \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/h4 b/snippets/text-mode/nxml-mode/h4 index 5c89b54..b782998 100644 --- a/snippets/text-mode/nxml-mode/h4 +++ b/snippets/text-mode/nxml-mode/h4 @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name :

                ...

                +#group : header # --

                $1

                \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/h5 b/snippets/text-mode/nxml-mode/h5 index dbf1123..13a51a1 100644 --- a/snippets/text-mode/nxml-mode/h5 +++ b/snippets/text-mode/nxml-mode/h5 @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name :
                ...
                +#group : header # --
                $1
                \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/h6 b/snippets/text-mode/nxml-mode/h6 index efa1313..b2f0c55 100644 --- a/snippets/text-mode/nxml-mode/h6 +++ b/snippets/text-mode/nxml-mode/h6 @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name :
                ...
                +#group : header # --
                $1
                \ No newline at end of file diff --git a/snippets/text-mode/nxml-mode/meta b/snippets/text-mode/nxml-mode/meta index ad7f4b5..dfee1f2 100644 --- a/snippets/text-mode/nxml-mode/meta +++ b/snippets/text-mode/nxml-mode/meta @@ -1,4 +1,5 @@ #contributor : Anders Bach Nielsen #name : +#group : meta # -- \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/# b/snippets/text-mode/ruby-mode/# index 7d21bb4..33581c8 100644 --- a/snippets/text-mode/ruby-mode/# +++ b/snippets/text-mode/ruby-mode/# @@ -1,3 +1,4 @@ #name : # => +#group : general # -- # => \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/=b b/snippets/text-mode/ruby-mode/=b index c93d6db..22a013f 100644 --- a/snippets/text-mode/ruby-mode/=b +++ b/snippets/text-mode/ruby-mode/=b @@ -1,3 +1,6 @@ +#name : =begin rdoc ... =end +#group : general +# -- =begin rdoc $0 =end \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/Comp b/snippets/text-mode/ruby-mode/Comp index 9602d59..03f2b35 100644 --- a/snippets/text-mode/ruby-mode/Comp +++ b/snippets/text-mode/ruby-mode/Comp @@ -1,4 +1,5 @@ #name : include Comparable; def <=> ... end +#group : definitions # -- include Comparable diff --git a/snippets/text-mode/ruby-mode/all b/snippets/text-mode/ruby-mode/all index 8bafece..a98a9f4 100644 --- a/snippets/text-mode/ruby-mode/all +++ b/snippets/text-mode/ruby-mode/all @@ -1,3 +1,4 @@ #name : all? { |...| ... } +#group : collections # -- all? { |${e}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/am b/snippets/text-mode/ruby-mode/am index 20594fd..7675a97 100644 --- a/snippets/text-mode/ruby-mode/am +++ b/snippets/text-mode/ruby-mode/am @@ -1,3 +1,4 @@ #name : alias_method new, old +#group : definitions # -- alias_method :${new_name}, :${old_name} \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/any b/snippets/text-mode/ruby-mode/any index 084a2c7..d0b6dd2 100644 --- a/snippets/text-mode/ruby-mode/any +++ b/snippets/text-mode/ruby-mode/any @@ -1,3 +1,4 @@ #name : any? { |...| ... } +#group : collections # -- any? { |${e}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/app b/snippets/text-mode/ruby-mode/app index 7bda767..19bf60a 100644 --- a/snippets/text-mode/ruby-mode/app +++ b/snippets/text-mode/ruby-mode/app @@ -1,4 +1,5 @@ #name : if __FILE__ == $PROGRAM_NAME ... end +#group : general # -- if __FILE__ == $PROGRAM_NAME $0 diff --git a/snippets/text-mode/ruby-mode/bm b/snippets/text-mode/ruby-mode/bm index 934ff85..4789f64 100644 --- a/snippets/text-mode/ruby-mode/bm +++ b/snippets/text-mode/ruby-mode/bm @@ -1,4 +1,5 @@ #name : Benchmark.bmbm(...) do ... end +#group : general # -- Benchmark.bmbm(${1:10}) do |x| $0 diff --git a/snippets/text-mode/ruby-mode/case b/snippets/text-mode/ruby-mode/case index acc03ba..40c3529 100644 --- a/snippets/text-mode/ruby-mode/case +++ b/snippets/text-mode/ruby-mode/case @@ -1,4 +1,5 @@ #name : case ... end +#group : general # -- case ${1:object} when ${2:condition} diff --git a/snippets/text-mode/ruby-mode/cla b/snippets/text-mode/ruby-mode/cla index c8f3524..81ccf45 100644 --- a/snippets/text-mode/ruby-mode/cla +++ b/snippets/text-mode/ruby-mode/cla @@ -1,4 +1,5 @@ #name : class << self ... end +#group : definitions # -- class << ${self} $0 diff --git a/snippets/text-mode/ruby-mode/classify b/snippets/text-mode/ruby-mode/classify index 0fffa2d..2378afa 100644 --- a/snippets/text-mode/ruby-mode/classify +++ b/snippets/text-mode/ruby-mode/classify @@ -1,3 +1,4 @@ #name : classify { |...| ... } +#group : collections # -- classify { |${e}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/cls b/snippets/text-mode/ruby-mode/cls index 5f43de1..4ce8a0b 100644 --- a/snippets/text-mode/ruby-mode/cls +++ b/snippets/text-mode/ruby-mode/cls @@ -1,5 +1,6 @@ #name : class ... end #contributor : hitesh +#group : definitions # -- class ${1:$ (let ((fn (capitalize (file-name-nondirectory diff --git a/snippets/text-mode/ruby-mode/collect b/snippets/text-mode/ruby-mode/collect index 32ec608..934014a 100644 --- a/snippets/text-mode/ruby-mode/collect +++ b/snippets/text-mode/ruby-mode/collect @@ -1,3 +1,4 @@ #name : collect { |...| ... } +#group : collections # -- collect { |${e}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/dee b/snippets/text-mode/ruby-mode/dee index ecec2f7..56d0a18 100644 --- a/snippets/text-mode/ruby-mode/dee +++ b/snippets/text-mode/ruby-mode/dee @@ -1,3 +1,4 @@ #name : deep_copy(...) +#group : general # -- Marshal.load(Marshal.dump($0)) \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/deli b/snippets/text-mode/ruby-mode/deli index a91fc7b..843b154 100644 --- a/snippets/text-mode/ruby-mode/deli +++ b/snippets/text-mode/ruby-mode/deli @@ -1,3 +1,4 @@ #name : delete_if { |...| ... } +#group : collections # -- delete_if { |${e} $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/det b/snippets/text-mode/ruby-mode/det index 734d45c..6a17da9 100644 --- a/snippets/text-mode/ruby-mode/det +++ b/snippets/text-mode/ruby-mode/det @@ -1,3 +1,4 @@ #name : detect { |...| ... } +#group : collections # -- detect { |${e}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/dow b/snippets/text-mode/ruby-mode/dow new file mode 100644 index 0000000..3b65271 --- /dev/null +++ b/snippets/text-mode/ruby-mode/dow @@ -0,0 +1,6 @@ +#name : downto(...) { |n| ... } +#group : control structure +# -- +downto(${0}) { |${n}| + $0 +} \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/ea b/snippets/text-mode/ruby-mode/ea index c779dd6..9cdf8dc 100644 --- a/snippets/text-mode/ruby-mode/ea +++ b/snippets/text-mode/ruby-mode/ea @@ -1,3 +1,4 @@ #name : each { |...| ... } +#group : collections # -- each { |${e}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/eac b/snippets/text-mode/ruby-mode/eac index 2547b2d..f0d9cb1 100644 --- a/snippets/text-mode/ruby-mode/eac +++ b/snippets/text-mode/ruby-mode/eac @@ -1,3 +1,4 @@ #name : each_cons(...) { |...| ... } +#group : collections # -- each_cons(${1:2}) { |${group}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/eai b/snippets/text-mode/ruby-mode/eai index 4136dc0..5b0ed67 100644 --- a/snippets/text-mode/ruby-mode/eai +++ b/snippets/text-mode/ruby-mode/eai @@ -1,3 +1,4 @@ #name : each_index { |i| ... } +#group : collections # -- each_index { |${i}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/eav b/snippets/text-mode/ruby-mode/eav index 4ff171a..558e5b4 100644 --- a/snippets/text-mode/ruby-mode/eav +++ b/snippets/text-mode/ruby-mode/eav @@ -1,3 +1,4 @@ #name : each_value { |val| ... } +#group : collections # -- each_value { |${val}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/eawi b/snippets/text-mode/ruby-mode/eawi index 3d03998..edf8418 100644 --- a/snippets/text-mode/ruby-mode/eawi +++ b/snippets/text-mode/ruby-mode/eawi @@ -1,3 +1,4 @@ #name : each_with_index { |e, i| ... } +#group : collections # -- each_with_index { |${e}, ${i}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/forin b/snippets/text-mode/ruby-mode/forin index 3d7e4d2..36b4387 100644 --- a/snippets/text-mode/ruby-mode/forin +++ b/snippets/text-mode/ruby-mode/forin @@ -1,4 +1,5 @@ #name : for ... in ...; ... end +#group : control structure # -- for ${1:element} in ${2:collection} $0 diff --git a/snippets/text-mode/ruby-mode/if b/snippets/text-mode/ruby-mode/if index 51bf24c..077b097 100644 --- a/snippets/text-mode/ruby-mode/if +++ b/snippets/text-mode/ruby-mode/if @@ -1,4 +1,5 @@ #name : if ... end +#group : control structure # -- if ${1:condition} $0 diff --git a/snippets/text-mode/ruby-mode/ife b/snippets/text-mode/ruby-mode/ife index 08fbb81..e57d395 100644 --- a/snippets/text-mode/ruby-mode/ife +++ b/snippets/text-mode/ruby-mode/ife @@ -1,4 +1,5 @@ #name : if ... else ... end +#group : control structure # -- if ${1:condition} $2 diff --git a/snippets/text-mode/ruby-mode/inject b/snippets/text-mode/ruby-mode/inject index f6adb5c..37932e5 100644 --- a/snippets/text-mode/ruby-mode/inject +++ b/snippets/text-mode/ruby-mode/inject @@ -1,3 +1,4 @@ #name : inject(...) { |...| ... } +#group : collections # -- inject(${1:0}) { |${2:injection}, ${3:element}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/mm b/snippets/text-mode/ruby-mode/mm index 5f1ebfc..3f62b10 100644 --- a/snippets/text-mode/ruby-mode/mm +++ b/snippets/text-mode/ruby-mode/mm @@ -1,4 +1,5 @@ #name : def method_missing ... end +#group : definitions # -- def method_missing(method, *args) $0 diff --git a/snippets/text-mode/ruby-mode/r b/snippets/text-mode/ruby-mode/r index b8d68d3..2e7b797 100644 --- a/snippets/text-mode/ruby-mode/r +++ b/snippets/text-mode/ruby-mode/r @@ -1,3 +1,4 @@ #name : attr_reader ... +#group : definitions # -- attr_reader : \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/rb b/snippets/text-mode/ruby-mode/rb index 9153653..74d26dd 100644 --- a/snippets/text-mode/ruby-mode/rb +++ b/snippets/text-mode/ruby-mode/rb @@ -1,3 +1,4 @@ #name : /usr/bin/ruby -wKU +#group : general # -- #!/usr/bin/ruby -wKU diff --git a/snippets/text-mode/ruby-mode/reject b/snippets/text-mode/ruby-mode/reject index 9625fe9..c2501bc 100644 --- a/snippets/text-mode/ruby-mode/reject +++ b/snippets/text-mode/ruby-mode/reject @@ -1,3 +1,4 @@ #name : reject { |...| ... } +#group : collections # -- reject { |${1:element}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/req b/snippets/text-mode/ruby-mode/req index 2fbc3d4..3e001ec 100644 --- a/snippets/text-mode/ruby-mode/req +++ b/snippets/text-mode/ruby-mode/req @@ -1,3 +1,4 @@ #name : require "..." +#group : general # -- require "$0" \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/rreq b/snippets/text-mode/ruby-mode/rreq index 84ac9df..0b9c6a4 100644 --- a/snippets/text-mode/ruby-mode/rreq +++ b/snippets/text-mode/ruby-mode/rreq @@ -1,3 +1,4 @@ #name : require File.join(File.dirname(__FILE__), ...) +#group : general # -- require File.join(File.dirname(__FILE__), $0) \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/rw b/snippets/text-mode/ruby-mode/rw index aadf605..a364675 100644 --- a/snippets/text-mode/ruby-mode/rw +++ b/snippets/text-mode/ruby-mode/rw @@ -1,3 +1,4 @@ #name : attr_accessor ... +#group : definitions # -- attr_accessor : \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/select b/snippets/text-mode/ruby-mode/select index b18a17d..78bca8f 100644 --- a/snippets/text-mode/ruby-mode/select +++ b/snippets/text-mode/ruby-mode/select @@ -1,3 +1,4 @@ #name : select { |...| ... } +#group : collections # -- select { |${1:element}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/tim b/snippets/text-mode/ruby-mode/tim new file mode 100644 index 0000000..0da115f --- /dev/null +++ b/snippets/text-mode/ruby-mode/tim @@ -0,0 +1,4 @@ +#name : times { |n| ... } +#group : control structure +# -- +times { |${n}| $0 } \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/until b/snippets/text-mode/ruby-mode/until new file mode 100644 index 0000000..476966a --- /dev/null +++ b/snippets/text-mode/ruby-mode/until @@ -0,0 +1,6 @@ +#name : until ... end +#group: control structure +# -- +until ${condition} + $0 +end \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/upt b/snippets/text-mode/ruby-mode/upt new file mode 100644 index 0000000..6fc6810 --- /dev/null +++ b/snippets/text-mode/ruby-mode/upt @@ -0,0 +1,6 @@ +#name : upto(...) { |n| ... } +#group : control structure +# -- +upto(${n}) { |${i}| + $0 +} \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/w b/snippets/text-mode/ruby-mode/w index d680f25..9edbfcb 100644 --- a/snippets/text-mode/ruby-mode/w +++ b/snippets/text-mode/ruby-mode/w @@ -1,3 +1,4 @@ #name : attr_writer ... +#group : definitions # -- attr_writer : \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/when b/snippets/text-mode/ruby-mode/when new file mode 100644 index 0000000..9b06f21 --- /dev/null +++ b/snippets/text-mode/ruby-mode/when @@ -0,0 +1,6 @@ +#name : when ... end +#group : control structure +# -- +when ${condition} + $0 +end \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/while b/snippets/text-mode/ruby-mode/while new file mode 100644 index 0000000..4c9ad35 --- /dev/null +++ b/snippets/text-mode/ruby-mode/while @@ -0,0 +1,6 @@ +#name : while ... end +#group : control structure +# -- +while ${condition} + $0 +end \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/y b/snippets/text-mode/ruby-mode/y index cdec730..0ddf0f9 100644 --- a/snippets/text-mode/ruby-mode/y +++ b/snippets/text-mode/ruby-mode/y @@ -1,3 +1,4 @@ #name : :yields: arguments (rdoc) +#group : general # -- :yields: $0 \ No newline at end of file diff --git a/snippets/text-mode/ruby-mode/zip b/snippets/text-mode/ruby-mode/zip index 1da1086..56f4266 100644 --- a/snippets/text-mode/ruby-mode/zip +++ b/snippets/text-mode/ruby-mode/zip @@ -1,3 +1,4 @@ #name : zip(...) { |...| ... } +#group : collections # -- zip(${enums}) { |${row}| $0 } \ No newline at end of file diff --git a/yasnippet.el b/yasnippet.el index cfbf26e..28fb469 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -900,12 +900,14 @@ Here's a list of currently recognized variables: * name * contributor * condition + * key + * group #name: #include \"...\" # -- #include \"$1\"" (goto-char (point-min)) - (let ((name file-name) template bound condition key) + (let ((name file-name) template bound condition key group) (if (re-search-forward "^# --\n" nil t) (progn (setq template (buffer-substring-no-properties (point) @@ -917,11 +919,13 @@ Here's a list of currently recognized variables: (setq name (match-string-no-properties 2))) (when (string= "condition" (match-string-no-properties 1)) (setq condition (read (match-string-no-properties 2)))) + (when (string= "group" (match-string-no-properties 1)) + (setq group (match-string-no-properties 2))) (when (string= "key" (match-string-no-properties 1)) (setq key (match-string-no-properties 2))))) (setq template (buffer-substring-no-properties (point-min) (point-max)))) - (list key template name condition))) + (list key template name condition group))) (defun yas/directory-files (directory file?) "Return directory files or subdirectories in full path." @@ -1074,15 +1078,19 @@ all the parameters: (insert " (" (yas/quote-string (car snippet)) " " - (yas/quote-string (cadr snippet)) + (yas/quote-string (nth 1 snippet)) " " - (if (caddr snippet) - (yas/quote-string (caddr snippet)) + (if (nth 2 snippet) + (yas/quote-string (nth 2 snippet)) "nil") " " (if (nth 3 snippet) (format "'%s" (nth 3 snippet)) "nil") + " " + (if (nth 4 snippet) + (yas/quote-string (nth 4 snippet)) + "nil") ")\n")) (insert " )\n") (insert (if parent @@ -1154,9 +1162,9 @@ content of the file is the template." "Define snippets for MODE. SNIPPETS is a list of snippet definition, of the following form: - (KEY TEMPLATE NAME CONDITION) + (KEY TEMPLATE NAME CONDITION GROUP) -or the NAME and CONDITION may be omitted. The optional 3rd +or the NAME, CONDITION or GROUP may be omitted. The optional 3rd parameter can be used to specify the parent mode of MODE. That is, when looking a snippet in MODE failed, it can refer to its parent mode. The PARENT-MODE may not need to be a real mode." @@ -1181,9 +1189,10 @@ parent mode. The PARENT-MODE may not need to be a real mode." (dolist (snippet snippets) (let* ((full-key (car snippet)) (key (file-name-sans-extension full-key)) - (name (or (caddr snippet) (file-name-extension full-key))) + (name (or (nth 2 snippet) (file-name-extension full-key))) (condition (nth 3 snippet)) - (template (yas/make-template (cadr snippet) + (group (nth 4 snippet)) + (template (yas/make-template (nth 1 snippet) (or name key) condition))) (yas/snippet-table-store snippet-table @@ -1191,10 +1200,24 @@ parent mode. The PARENT-MODE may not need to be a real mode." key template) (when yas/use-menu - (define-key keymap (vector (make-symbol full-key)) - `(menu-item ,(yas/template-name template) - ,(yas/make-menu-binding (yas/template-content template)) - :keys ,(concat key yas/trigger-symbol)))))))) + (let ((group-keymap keymap)) + (when (and (not (null group)) + (not (string= "" group))) + (dolist (subgroup (mapcar #'make-symbol + (split-string group "\\."))) + (let ((subgroup-keymap (lookup-key group-keymap + (vector subgroup)))) + (when (null subgroup-keymap) + (setq subgroup-keymap (make-sparse-keymap)) + (define-key group-keymap (vector subgroup) + `(menu-item ,(symbol-name subgroup) + ,subgroup-keymap))) + (setq group-keymap subgroup-keymap)))) + (define-key group-keymap (vector (make-symbol full-key)) + `(menu-item ,(yas/template-name template) + ,(yas/make-menu-binding (yas/template-content + template)) + :keys ,(concat key yas/trigger-symbol))))))))) (defun yas/set-mode-parent (mode parent) "Set parent mode of MODE to PARENT." @@ -1206,7 +1229,7 @@ parent mode. The PARENT-MODE may not need to be a real mode." `(menu-item "parent mode" ,(yas/menu-keymap-for-mode parent))))) -(defun yas/define (mode key template &optional name condition) +(defun yas/define (mode key template &optional name condition group) "Define a snippet. Expanding KEY into TEMPLATE. NAME is a description to this template. Also update the menu if `yas/use-menu' is `t'. CONDITION is the @@ -1214,7 +1237,7 @@ condition attached to this snippet. If you attach a condition to a snippet, then it will only be expanded when the condition evaluated to non-nil." (yas/define-snippets mode - (list (list key template name condition)))) + (list (list key template name condition group)))) (defun yas/hippie-try-expand (first-time?)
          ......