mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Added grouping support for snippets (Issue 30)
This commit is contained in:
parent
11f4a94680
commit
64e5027d10
@ -1,4 +1,5 @@
|
||||
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
|
||||
#name : <dd> ... </dd>
|
||||
#group : list
|
||||
# --
|
||||
<dd>$1</dd>
|
@ -1,5 +1,6 @@
|
||||
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
|
||||
#name : <dl> ... </dl>
|
||||
#group : list
|
||||
# --
|
||||
<dl>
|
||||
$0
|
||||
|
@ -1,5 +1,6 @@
|
||||
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
|
||||
#name : <dl> ... </dl>
|
||||
#group : list
|
||||
# --
|
||||
<dl id="$1">
|
||||
$0
|
||||
|
@ -1,3 +1,4 @@
|
||||
#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">
|
@ -1,3 +1,4 @@
|
||||
#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">
|
@ -1,3 +1,4 @@
|
||||
#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">
|
@ -1,3 +1,4 @@
|
||||
#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">
|
@ -1,3 +1,4 @@
|
||||
#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">
|
@ -1,4 +1,5 @@
|
||||
#contributor : Rodrigo Setti <rodrigosetti@gmail.com>
|
||||
#name : <dt> ... </dt>
|
||||
#group : list
|
||||
# --
|
||||
<dt>$1</dt>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <h1>...</h1>
|
||||
#group : header
|
||||
# --
|
||||
<h1>$1</h1>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <h2>...</h2>
|
||||
#group : header
|
||||
# --
|
||||
<h2>$1</h2>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <h3>...</h3>
|
||||
#group : header
|
||||
# --
|
||||
<h3>$1</h3>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <h4>...</h4>
|
||||
#group : header
|
||||
# --
|
||||
<h4>$1</h4>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <h5>...</h5>
|
||||
#group : header
|
||||
# --
|
||||
<h5>$1</h5>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <h6>...</h6>
|
||||
#group : header
|
||||
# --
|
||||
<h6>$1</h6>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <li>...</li>
|
||||
#group : list
|
||||
# --
|
||||
<li>$1</li>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <li class="...">...</li>
|
||||
#group : list
|
||||
# --
|
||||
<li class="$1">$2</li>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#group : meta
|
||||
#name : <meta name="..." content="..." />
|
||||
# --
|
||||
<meta name="${1:generator}" content="${2:content}" />
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <meta http-equiv="..." content="..." />
|
||||
#group : meta
|
||||
# --
|
||||
<meta name="${1:Content-Type}" content="${2:text/html; charset=UTF-8}" />
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <ol>...</ol>
|
||||
#group : list
|
||||
# --
|
||||
<ol>
|
||||
$0
|
||||
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <ol class="...">...</ol>
|
||||
#group : list
|
||||
# --
|
||||
<ol class="$1">
|
||||
$0
|
||||
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <ol id="...">...</ol>
|
||||
#group : list
|
||||
# --
|
||||
<ol id="$1">
|
||||
$0
|
||||
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <table ...>...</table>
|
||||
#group : table
|
||||
# --
|
||||
<table width="$1" cellspacing="$2" cellpadding="$3" border="$4">
|
||||
$0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <td>...</td>
|
||||
#group : table
|
||||
# --
|
||||
<td$1>$2</td>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <th>...</th>
|
||||
#group : table
|
||||
# --
|
||||
<th$1>$2</th>
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <tr>...</tr>
|
||||
#group : table
|
||||
# --
|
||||
<tr>
|
||||
$0
|
||||
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <ul>...</ul>
|
||||
#group : list
|
||||
# --
|
||||
<ul>
|
||||
$0
|
||||
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <ul class="...">...</ul>
|
||||
#group : list
|
||||
# --
|
||||
<ul class="$1">
|
||||
$0
|
||||
|
@ -1,5 +1,6 @@
|
||||
#contributor : Jimmy Wu <frozenthrone88@gmail.com>
|
||||
#name : <ul id="...">...</ul>
|
||||
#group : list
|
||||
# --
|
||||
<ul id="$1">
|
||||
$0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#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">
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#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">
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#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">
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#name : <h1>...</h1>
|
||||
#group : header
|
||||
# --
|
||||
<h1>$1</h1>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#name : <h2>...</h2>
|
||||
#group : header
|
||||
# --
|
||||
<h2>$1</h2>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#name : <h3>...</h3>
|
||||
#group : header
|
||||
# --
|
||||
<h3>$1</h3>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#name : <h4>...</h4>
|
||||
#group : header
|
||||
# --
|
||||
<h4>$1</h4>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#name : <h5>...</h5>
|
||||
#group : header
|
||||
# --
|
||||
<h5>$1</h5>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#name : <h6>...</h6>
|
||||
#group : header
|
||||
# --
|
||||
<h6>$1</h6>
|
@ -1,4 +1,5 @@
|
||||
#contributor : Anders Bach Nielsen <abachn@abachn.net>
|
||||
#name : <meta name="..." content="..." />
|
||||
#group : meta
|
||||
# --
|
||||
<meta name="${1:generator}" content="${2:content}" />
|
@ -1,3 +1,4 @@
|
||||
#name : # =>
|
||||
#group : general
|
||||
# --
|
||||
# =>
|
@ -1,3 +1,6 @@
|
||||
#name : =begin rdoc ... =end
|
||||
#group : general
|
||||
# --
|
||||
=begin rdoc
|
||||
$0
|
||||
=end
|
@ -1,4 +1,5 @@
|
||||
#name : include Comparable; def <=> ... end
|
||||
#group : definitions
|
||||
# --
|
||||
include Comparable
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#name : all? { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
all? { |${e}| $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : alias_method new, old
|
||||
#group : definitions
|
||||
# --
|
||||
alias_method :${new_name}, :${old_name}
|
@ -1,3 +1,4 @@
|
||||
#name : any? { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
any? { |${e}| $0 }
|
@ -1,4 +1,5 @@
|
||||
#name : if __FILE__ == $PROGRAM_NAME ... end
|
||||
#group : general
|
||||
# --
|
||||
if __FILE__ == $PROGRAM_NAME
|
||||
$0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#name : Benchmark.bmbm(...) do ... end
|
||||
#group : general
|
||||
# --
|
||||
Benchmark.bmbm(${1:10}) do |x|
|
||||
$0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#name : case ... end
|
||||
#group : general
|
||||
# --
|
||||
case ${1:object}
|
||||
when ${2:condition}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#name : class << self ... end
|
||||
#group : definitions
|
||||
# --
|
||||
class << ${self}
|
||||
$0
|
||||
|
@ -1,3 +1,4 @@
|
||||
#name : classify { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
classify { |${e}| $0 }
|
@ -1,5 +1,6 @@
|
||||
#name : class ... end
|
||||
#contributor : hitesh <hitesh.jasani@gmail.com>
|
||||
#group : definitions
|
||||
# --
|
||||
class ${1:$
|
||||
(let ((fn (capitalize (file-name-nondirectory
|
||||
|
@ -1,3 +1,4 @@
|
||||
#name : collect { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
collect { |${e}| $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : deep_copy(...)
|
||||
#group : general
|
||||
# --
|
||||
Marshal.load(Marshal.dump($0))
|
@ -1,3 +1,4 @@
|
||||
#name : delete_if { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
delete_if { |${e} $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : detect { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
detect { |${e}| $0 }
|
6
snippets/text-mode/ruby-mode/dow
Normal file
6
snippets/text-mode/ruby-mode/dow
Normal file
@ -0,0 +1,6 @@
|
||||
#name : downto(...) { |n| ... }
|
||||
#group : control structure
|
||||
# --
|
||||
downto(${0}) { |${n}|
|
||||
$0
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#name : each { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
each { |${e}| $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : each_cons(...) { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
each_cons(${1:2}) { |${group}| $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : each_index { |i| ... }
|
||||
#group : collections
|
||||
# --
|
||||
each_index { |${i}| $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : each_value { |val| ... }
|
||||
#group : collections
|
||||
# --
|
||||
each_value { |${val}| $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : each_with_index { |e, i| ... }
|
||||
#group : collections
|
||||
# --
|
||||
each_with_index { |${e}, ${i}| $0 }
|
@ -1,4 +1,5 @@
|
||||
#name : for ... in ...; ... end
|
||||
#group : control structure
|
||||
# --
|
||||
for ${1:element} in ${2:collection}
|
||||
$0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#name : if ... end
|
||||
#group : control structure
|
||||
# --
|
||||
if ${1:condition}
|
||||
$0
|
||||
|
@ -1,4 +1,5 @@
|
||||
#name : if ... else ... end
|
||||
#group : control structure
|
||||
# --
|
||||
if ${1:condition}
|
||||
$2
|
||||
|
@ -1,3 +1,4 @@
|
||||
#name : inject(...) { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
inject(${1:0}) { |${2:injection}, ${3:element}| $0 }
|
@ -1,4 +1,5 @@
|
||||
#name : def method_missing ... end
|
||||
#group : definitions
|
||||
# --
|
||||
def method_missing(method, *args)
|
||||
$0
|
||||
|
@ -1,3 +1,4 @@
|
||||
#name : attr_reader ...
|
||||
#group : definitions
|
||||
# --
|
||||
attr_reader :
|
@ -1,3 +1,4 @@
|
||||
#name : /usr/bin/ruby -wKU
|
||||
#group : general
|
||||
# --
|
||||
#!/usr/bin/ruby -wKU
|
||||
|
@ -1,3 +1,4 @@
|
||||
#name : reject { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
reject { |${1:element}| $0 }
|
@ -1,3 +1,4 @@
|
||||
#name : require "..."
|
||||
#group : general
|
||||
# --
|
||||
require "$0"
|
@ -1,3 +1,4 @@
|
||||
#name : require File.join(File.dirname(__FILE__), ...)
|
||||
#group : general
|
||||
# --
|
||||
require File.join(File.dirname(__FILE__), $0)
|
@ -1,3 +1,4 @@
|
||||
#name : attr_accessor ...
|
||||
#group : definitions
|
||||
# --
|
||||
attr_accessor :
|
@ -1,3 +1,4 @@
|
||||
#name : select { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
select { |${1:element}| $0 }
|
4
snippets/text-mode/ruby-mode/tim
Normal file
4
snippets/text-mode/ruby-mode/tim
Normal file
@ -0,0 +1,4 @@
|
||||
#name : times { |n| ... }
|
||||
#group : control structure
|
||||
# --
|
||||
times { |${n}| $0 }
|
6
snippets/text-mode/ruby-mode/until
Normal file
6
snippets/text-mode/ruby-mode/until
Normal file
@ -0,0 +1,6 @@
|
||||
#name : until ... end
|
||||
#group: control structure
|
||||
# --
|
||||
until ${condition}
|
||||
$0
|
||||
end
|
6
snippets/text-mode/ruby-mode/upt
Normal file
6
snippets/text-mode/ruby-mode/upt
Normal file
@ -0,0 +1,6 @@
|
||||
#name : upto(...) { |n| ... }
|
||||
#group : control structure
|
||||
# --
|
||||
upto(${n}) { |${i}|
|
||||
$0
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#name : attr_writer ...
|
||||
#group : definitions
|
||||
# --
|
||||
attr_writer :
|
6
snippets/text-mode/ruby-mode/when
Normal file
6
snippets/text-mode/ruby-mode/when
Normal file
@ -0,0 +1,6 @@
|
||||
#name : when ... end
|
||||
#group : control structure
|
||||
# --
|
||||
when ${condition}
|
||||
$0
|
||||
end
|
6
snippets/text-mode/ruby-mode/while
Normal file
6
snippets/text-mode/ruby-mode/while
Normal file
@ -0,0 +1,6 @@
|
||||
#name : while ... end
|
||||
#group : control structure
|
||||
# --
|
||||
while ${condition}
|
||||
$0
|
||||
end
|
@ -1,3 +1,4 @@
|
||||
#name : :yields: arguments (rdoc)
|
||||
#group : general
|
||||
# --
|
||||
:yields: $0
|
@ -1,3 +1,4 @@
|
||||
#name : zip(...) { |...| ... }
|
||||
#group : collections
|
||||
# --
|
||||
zip(${enums}) { |${row}| $0 }
|
53
yasnippet.el
53
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?)
|
||||
|
Loading…
x
Reference in New Issue
Block a user