Added grouping support for snippets (Issue 30)

This commit is contained in:
Zhang Chiyuan 2009-01-28 07:04:27 +00:00
parent 11f4a94680
commit 64e5027d10
82 changed files with 149 additions and 15 deletions

View File

@ -1,4 +1,5 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com> #contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dd> ... </dd> #name : <dd> ... </dd>
#group : list
# -- # --
<dd>$1</dd> <dd>$1</dd>

View File

@ -1,5 +1,6 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com> #contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dl> ... </dl> #name : <dl> ... </dl>
#group : list
# -- # --
<dl> <dl>
$0 $0

View File

@ -1,5 +1,6 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com> #contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dl> ... </dl> #name : <dl> ... </dl>
#group : list
# -- # --
<dl id="$1"> <dl id="$1">
$0 $0

View File

@ -1,3 +1,4 @@
#name : Doctype HTML 4.01 Strict #name : Doctype HTML 4.01 Strict
#group : meta
# -- # --
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

View File

@ -1,3 +1,4 @@
#name : DocType XHTML 1.0 frameset #name : DocType XHTML 1.0 frameset
#group : meta
# -- # --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

View File

@ -1,3 +1,4 @@
#name : DocType XHTML 1.1 #name : DocType XHTML 1.1
#group : meta
# -- # --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

View File

@ -1,3 +1,4 @@
#name : DocType XHTML 1.0 Strict #name : DocType XHTML 1.0 Strict
#group : meta
# -- # --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

View File

@ -1,3 +1,4 @@
#name : DocType XHTML 1.0 Transitional #name : DocType XHTML 1.0 Transitional
#group : meta
# -- # --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View File

@ -1,4 +1,5 @@
#contributor : Rodrigo Setti <rodrigosetti@gmail.com> #contributor : Rodrigo Setti <rodrigosetti@gmail.com>
#name : <dt> ... </dt> #name : <dt> ... </dt>
#group : list
# -- # --
<dt>$1</dt> <dt>$1</dt>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h1>...</h1> #name : <h1>...</h1>
#group : header
# -- # --
<h1>$1</h1> <h1>$1</h1>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h2>...</h2> #name : <h2>...</h2>
#group : header
# -- # --
<h2>$1</h2> <h2>$1</h2>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h3>...</h3> #name : <h3>...</h3>
#group : header
# -- # --
<h3>$1</h3> <h3>$1</h3>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h4>...</h4> #name : <h4>...</h4>
#group : header
# -- # --
<h4>$1</h4> <h4>$1</h4>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h5>...</h5> #name : <h5>...</h5>
#group : header
# -- # --
<h5>$1</h5> <h5>$1</h5>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <h6>...</h6> #name : <h6>...</h6>
#group : header
# -- # --
<h6>$1</h6> <h6>$1</h6>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <li>...</li> #name : <li>...</li>
#group : list
# -- # --
<li>$1</li> <li>$1</li>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <li class="...">...</li> #name : <li class="...">...</li>
#group : list
# -- # --
<li class="$1">$2</li> <li class="$1">$2</li>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#group : meta
#name : <meta name="..." content="..." /> #name : <meta name="..." content="..." />
# -- # --
<meta name="${1:generator}" content="${2:content}" /> <meta name="${1:generator}" content="${2:content}" />

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <meta http-equiv="..." content="..." /> #name : <meta http-equiv="..." content="..." />
#group : meta
# -- # --
<meta name="${1:Content-Type}" content="${2:text/html; charset=UTF-8}" /> <meta name="${1:Content-Type}" content="${2:text/html; charset=UTF-8}" />

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <ol>...</ol> #name : <ol>...</ol>
#group : list
# -- # --
<ol> <ol>
$0 $0

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <ol class="...">...</ol> #name : <ol class="...">...</ol>
#group : list
# -- # --
<ol class="$1"> <ol class="$1">
$0 $0

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <ol id="...">...</ol> #name : <ol id="...">...</ol>
#group : list
# -- # --
<ol id="$1"> <ol id="$1">
$0 $0

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <table ...>...</table> #name : <table ...>...</table>
#group : table
# -- # --
<table width="$1" cellspacing="$2" cellpadding="$3" border="$4"> <table width="$1" cellspacing="$2" cellpadding="$3" border="$4">
$0 $0

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <td>...</td> #name : <td>...</td>
#group : table
# -- # --
<td$1>$2</td> <td$1>$2</td>

View File

@ -1,4 +1,5 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <th>...</th> #name : <th>...</th>
#group : table
# -- # --
<th$1>$2</th> <th$1>$2</th>

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <tr>...</tr> #name : <tr>...</tr>
#group : table
# -- # --
<tr> <tr>
$0 $0

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <ul>...</ul> #name : <ul>...</ul>
#group : list
# -- # --
<ul> <ul>
$0 $0

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <ul class="...">...</ul> #name : <ul class="...">...</ul>
#group : list
# -- # --
<ul class="$1"> <ul class="$1">
$0 $0

View File

@ -1,5 +1,6 @@
#contributor : Jimmy Wu <frozenthrone88@gmail.com> #contributor : Jimmy Wu <frozenthrone88@gmail.com>
#name : <ul id="...">...</ul> #name : <ul id="...">...</ul>
#group : list
# -- # --
<ul id="$1"> <ul id="$1">
$0 $0

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : DocType XHTML 1.1 #name : DocType XHTML 1.1
#group : meta
# -- # --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : DocType XHTML 1.0 Strict #name : DocType XHTML 1.0 Strict
#group : meta
# -- # --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : DocType XHTML 1.0 Transitional #name : DocType XHTML 1.0 Transitional
#group : meta
# -- # --
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : <h1>...</h1> #name : <h1>...</h1>
#group : header
# -- # --
<h1>$1</h1> <h1>$1</h1>

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : <h2>...</h2> #name : <h2>...</h2>
#group : header
# -- # --
<h2>$1</h2> <h2>$1</h2>

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : <h3>...</h3> #name : <h3>...</h3>
#group : header
# -- # --
<h3>$1</h3> <h3>$1</h3>

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : <h4>...</h4> #name : <h4>...</h4>
#group : header
# -- # --
<h4>$1</h4> <h4>$1</h4>

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : <h5>...</h5> #name : <h5>...</h5>
#group : header
# -- # --
<h5>$1</h5> <h5>$1</h5>

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : <h6>...</h6> #name : <h6>...</h6>
#group : header
# -- # --
<h6>$1</h6> <h6>$1</h6>

View File

@ -1,4 +1,5 @@
#contributor : Anders Bach Nielsen <abachn@abachn.net> #contributor : Anders Bach Nielsen <abachn@abachn.net>
#name : <meta name="..." content="..." /> #name : <meta name="..." content="..." />
#group : meta
# -- # --
<meta name="${1:generator}" content="${2:content}" /> <meta name="${1:generator}" content="${2:content}" />

View File

@ -1,3 +1,4 @@
#name : # => #name : # =>
#group : general
# -- # --
# => # =>

View File

@ -1,3 +1,6 @@
#name : =begin rdoc ... =end
#group : general
# --
=begin rdoc =begin rdoc
$0 $0
=end =end

View File

@ -1,4 +1,5 @@
#name : include Comparable; def <=> ... end #name : include Comparable; def <=> ... end
#group : definitions
# -- # --
include Comparable include Comparable

View File

@ -1,3 +1,4 @@
#name : all? { |...| ... } #name : all? { |...| ... }
#group : collections
# -- # --
all? { |${e}| $0 } all? { |${e}| $0 }

View File

@ -1,3 +1,4 @@
#name : alias_method new, old #name : alias_method new, old
#group : definitions
# -- # --
alias_method :${new_name}, :${old_name} alias_method :${new_name}, :${old_name}

View File

@ -1,3 +1,4 @@
#name : any? { |...| ... } #name : any? { |...| ... }
#group : collections
# -- # --
any? { |${e}| $0 } any? { |${e}| $0 }

View File

@ -1,4 +1,5 @@
#name : if __FILE__ == $PROGRAM_NAME ... end #name : if __FILE__ == $PROGRAM_NAME ... end
#group : general
# -- # --
if __FILE__ == $PROGRAM_NAME if __FILE__ == $PROGRAM_NAME
$0 $0

View File

@ -1,4 +1,5 @@
#name : Benchmark.bmbm(...) do ... end #name : Benchmark.bmbm(...) do ... end
#group : general
# -- # --
Benchmark.bmbm(${1:10}) do |x| Benchmark.bmbm(${1:10}) do |x|
$0 $0

View File

@ -1,4 +1,5 @@
#name : case ... end #name : case ... end
#group : general
# -- # --
case ${1:object} case ${1:object}
when ${2:condition} when ${2:condition}

View File

@ -1,4 +1,5 @@
#name : class << self ... end #name : class << self ... end
#group : definitions
# -- # --
class << ${self} class << ${self}
$0 $0

View File

@ -1,3 +1,4 @@
#name : classify { |...| ... } #name : classify { |...| ... }
#group : collections
# -- # --
classify { |${e}| $0 } classify { |${e}| $0 }

View File

@ -1,5 +1,6 @@
#name : class ... end #name : class ... end
#contributor : hitesh <hitesh.jasani@gmail.com> #contributor : hitesh <hitesh.jasani@gmail.com>
#group : definitions
# -- # --
class ${1:$ class ${1:$
(let ((fn (capitalize (file-name-nondirectory (let ((fn (capitalize (file-name-nondirectory

View File

@ -1,3 +1,4 @@
#name : collect { |...| ... } #name : collect { |...| ... }
#group : collections
# -- # --
collect { |${e}| $0 } collect { |${e}| $0 }

View File

@ -1,3 +1,4 @@
#name : deep_copy(...) #name : deep_copy(...)
#group : general
# -- # --
Marshal.load(Marshal.dump($0)) Marshal.load(Marshal.dump($0))

View File

@ -1,3 +1,4 @@
#name : delete_if { |...| ... } #name : delete_if { |...| ... }
#group : collections
# -- # --
delete_if { |${e} $0 } delete_if { |${e} $0 }

View File

@ -1,3 +1,4 @@
#name : detect { |...| ... } #name : detect { |...| ... }
#group : collections
# -- # --
detect { |${e}| $0 } detect { |${e}| $0 }

View File

@ -0,0 +1,6 @@
#name : downto(...) { |n| ... }
#group : control structure
# --
downto(${0}) { |${n}|
$0
}

View File

@ -1,3 +1,4 @@
#name : each { |...| ... } #name : each { |...| ... }
#group : collections
# -- # --
each { |${e}| $0 } each { |${e}| $0 }

View File

@ -1,3 +1,4 @@
#name : each_cons(...) { |...| ... } #name : each_cons(...) { |...| ... }
#group : collections
# -- # --
each_cons(${1:2}) { |${group}| $0 } each_cons(${1:2}) { |${group}| $0 }

View File

@ -1,3 +1,4 @@
#name : each_index { |i| ... } #name : each_index { |i| ... }
#group : collections
# -- # --
each_index { |${i}| $0 } each_index { |${i}| $0 }

View File

@ -1,3 +1,4 @@
#name : each_value { |val| ... } #name : each_value { |val| ... }
#group : collections
# -- # --
each_value { |${val}| $0 } each_value { |${val}| $0 }

View File

@ -1,3 +1,4 @@
#name : each_with_index { |e, i| ... } #name : each_with_index { |e, i| ... }
#group : collections
# -- # --
each_with_index { |${e}, ${i}| $0 } each_with_index { |${e}, ${i}| $0 }

View File

@ -1,4 +1,5 @@
#name : for ... in ...; ... end #name : for ... in ...; ... end
#group : control structure
# -- # --
for ${1:element} in ${2:collection} for ${1:element} in ${2:collection}
$0 $0

View File

@ -1,4 +1,5 @@
#name : if ... end #name : if ... end
#group : control structure
# -- # --
if ${1:condition} if ${1:condition}
$0 $0

View File

@ -1,4 +1,5 @@
#name : if ... else ... end #name : if ... else ... end
#group : control structure
# -- # --
if ${1:condition} if ${1:condition}
$2 $2

View File

@ -1,3 +1,4 @@
#name : inject(...) { |...| ... } #name : inject(...) { |...| ... }
#group : collections
# -- # --
inject(${1:0}) { |${2:injection}, ${3:element}| $0 } inject(${1:0}) { |${2:injection}, ${3:element}| $0 }

View File

@ -1,4 +1,5 @@
#name : def method_missing ... end #name : def method_missing ... end
#group : definitions
# -- # --
def method_missing(method, *args) def method_missing(method, *args)
$0 $0

View File

@ -1,3 +1,4 @@
#name : attr_reader ... #name : attr_reader ...
#group : definitions
# -- # --
attr_reader : attr_reader :

View File

@ -1,3 +1,4 @@
#name : /usr/bin/ruby -wKU #name : /usr/bin/ruby -wKU
#group : general
# -- # --
#!/usr/bin/ruby -wKU #!/usr/bin/ruby -wKU

View File

@ -1,3 +1,4 @@
#name : reject { |...| ... } #name : reject { |...| ... }
#group : collections
# -- # --
reject { |${1:element}| $0 } reject { |${1:element}| $0 }

View File

@ -1,3 +1,4 @@
#name : require "..." #name : require "..."
#group : general
# -- # --
require "$0" require "$0"

View File

@ -1,3 +1,4 @@
#name : require File.join(File.dirname(__FILE__), ...) #name : require File.join(File.dirname(__FILE__), ...)
#group : general
# -- # --
require File.join(File.dirname(__FILE__), $0) require File.join(File.dirname(__FILE__), $0)

View File

@ -1,3 +1,4 @@
#name : attr_accessor ... #name : attr_accessor ...
#group : definitions
# -- # --
attr_accessor : attr_accessor :

View File

@ -1,3 +1,4 @@
#name : select { |...| ... } #name : select { |...| ... }
#group : collections
# -- # --
select { |${1:element}| $0 } select { |${1:element}| $0 }

View File

@ -0,0 +1,4 @@
#name : times { |n| ... }
#group : control structure
# --
times { |${n}| $0 }

View File

@ -0,0 +1,6 @@
#name : until ... end
#group: control structure
# --
until ${condition}
$0
end

View File

@ -0,0 +1,6 @@
#name : upto(...) { |n| ... }
#group : control structure
# --
upto(${n}) { |${i}|
$0
}

View File

@ -1,3 +1,4 @@
#name : attr_writer ... #name : attr_writer ...
#group : definitions
# -- # --
attr_writer : attr_writer :

View File

@ -0,0 +1,6 @@
#name : when ... end
#group : control structure
# --
when ${condition}
$0
end

View File

@ -0,0 +1,6 @@
#name : while ... end
#group : control structure
# --
while ${condition}
$0
end

View File

@ -1,3 +1,4 @@
#name : :yields: arguments (rdoc) #name : :yields: arguments (rdoc)
#group : general
# -- # --
:yields: $0 :yields: $0

View File

@ -1,3 +1,4 @@
#name : zip(...) { |...| ... } #name : zip(...) { |...| ... }
#group : collections
# -- # --
zip(${enums}) { |${row}| $0 } zip(${enums}) { |${row}| $0 }

View File

@ -900,12 +900,14 @@ Here's a list of currently recognized variables:
* name * name
* contributor * contributor
* condition * condition
* key
* group
#name: #include \"...\" #name: #include \"...\"
# -- # --
#include \"$1\"" #include \"$1\""
(goto-char (point-min)) (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) (if (re-search-forward "^# --\n" nil t)
(progn (setq template (progn (setq template
(buffer-substring-no-properties (point) (buffer-substring-no-properties (point)
@ -917,11 +919,13 @@ Here's a list of currently recognized variables:
(setq name (match-string-no-properties 2))) (setq name (match-string-no-properties 2)))
(when (string= "condition" (match-string-no-properties 1)) (when (string= "condition" (match-string-no-properties 1))
(setq condition (read (match-string-no-properties 2)))) (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)) (when (string= "key" (match-string-no-properties 1))
(setq key (match-string-no-properties 2))))) (setq key (match-string-no-properties 2)))))
(setq template (setq template
(buffer-substring-no-properties (point-min) (point-max)))) (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?) (defun yas/directory-files (directory file?)
"Return directory files or subdirectories in full path." "Return directory files or subdirectories in full path."
@ -1074,15 +1078,19 @@ all the parameters:
(insert " (" (insert " ("
(yas/quote-string (car snippet)) (yas/quote-string (car snippet))
" " " "
(yas/quote-string (cadr snippet)) (yas/quote-string (nth 1 snippet))
" " " "
(if (caddr snippet) (if (nth 2 snippet)
(yas/quote-string (caddr snippet)) (yas/quote-string (nth 2 snippet))
"nil") "nil")
" " " "
(if (nth 3 snippet) (if (nth 3 snippet)
(format "'%s" (nth 3 snippet)) (format "'%s" (nth 3 snippet))
"nil") "nil")
" "
(if (nth 4 snippet)
(yas/quote-string (nth 4 snippet))
"nil")
")\n")) ")\n"))
(insert " )\n") (insert " )\n")
(insert (if parent (insert (if parent
@ -1154,9 +1162,9 @@ content of the file is the template."
"Define snippets for MODE. SNIPPETS is a list of "Define snippets for MODE. SNIPPETS is a list of
snippet definition, of the following form: 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 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 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." 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) (dolist (snippet snippets)
(let* ((full-key (car snippet)) (let* ((full-key (car snippet))
(key (file-name-sans-extension full-key)) (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)) (condition (nth 3 snippet))
(template (yas/make-template (cadr snippet) (group (nth 4 snippet))
(template (yas/make-template (nth 1 snippet)
(or name key) (or name key)
condition))) condition)))
(yas/snippet-table-store snippet-table (yas/snippet-table-store snippet-table
@ -1191,10 +1200,24 @@ parent mode. The PARENT-MODE may not need to be a real mode."
key key
template) template)
(when yas/use-menu (when yas/use-menu
(define-key keymap (vector (make-symbol full-key)) (let ((group-keymap keymap))
`(menu-item ,(yas/template-name template) (when (and (not (null group))
,(yas/make-menu-binding (yas/template-content template)) (not (string= "" group)))
:keys ,(concat key yas/trigger-symbol)))))))) (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) (defun yas/set-mode-parent (mode parent)
"Set parent mode of MODE to 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" `(menu-item "parent mode"
,(yas/menu-keymap-for-mode parent))))) ,(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. "Define a snippet. Expanding KEY into TEMPLATE.
NAME is a description to this template. Also update NAME is a description to this template. Also update
the menu if `yas/use-menu' is `t'. CONDITION is the 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 condition to a snippet, then it will only be expanded
when the condition evaluated to non-nil." when the condition evaluated to non-nil."
(yas/define-snippets mode (yas/define-snippets mode
(list (list key template name condition)))) (list (list key template name condition group))))
(defun yas/hippie-try-expand (first-time?) (defun yas/hippie-try-expand (first-time?)