mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
multiple key-syntaxes supported. like charm. see python-mode snippet: __ => __${init}__
This commit is contained in:
parent
d63608bd79
commit
8ef771a696
27
yasnippet.el
27
yasnippet.el
@ -27,9 +27,14 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; User customizable variables
|
;; User customizable variables
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(defvar yas/key-syntax "w"
|
(defvar yas/key-syntaxes (list "w" "w_")
|
||||||
"Syntax of a key. This is used to determine the current key being
|
"A list of syntax of a key. This list is tried in the order
|
||||||
expanded.")
|
to try to find a key. For example, if the list is '(\"w\" \"w_\").
|
||||||
|
And in emacs-lisp-mode, where \"-\" has the syntax of \"_\":
|
||||||
|
|
||||||
|
foo-bar
|
||||||
|
|
||||||
|
will first try \"bar\", if not found, then \"foo-bar\" is tried.")
|
||||||
|
|
||||||
(defvar yas/indent-line t
|
(defvar yas/indent-line t
|
||||||
"Each (except the 1st) line of the snippet template is indented to
|
"Each (except the 1st) line of the snippet template is indented to
|
||||||
@ -210,13 +215,21 @@ have, compare through the start point of the overlay."
|
|||||||
"Get the key under current position. A key is used to find
|
"Get the key under current position. A key is used to find
|
||||||
the template of a snippet in the current snippet-table."
|
the template of a snippet in the current snippet-table."
|
||||||
(let ((start (point))
|
(let ((start (point))
|
||||||
(end (point)))
|
(end (point))
|
||||||
|
(syntaxes yas/key-syntaxes)
|
||||||
|
syntax done)
|
||||||
|
(while (and (not done) syntaxes)
|
||||||
|
(setq syntax (car syntaxes))
|
||||||
|
(setq syntaxes (cdr syntaxes))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(skip-syntax-backward yas/key-syntax)
|
(skip-syntax-backward syntax)
|
||||||
(setq start (point))
|
(when (gethash (buffer-substring-no-properties (point) end)
|
||||||
|
(yas/current-snippet-table))
|
||||||
|
(setq done t)
|
||||||
|
(setq start (point)))))
|
||||||
(list (buffer-substring-no-properties start end)
|
(list (buffer-substring-no-properties start end)
|
||||||
start
|
start
|
||||||
end))))
|
end)))
|
||||||
|
|
||||||
(defun yas/synchronize-fields (field-group)
|
(defun yas/synchronize-fields (field-group)
|
||||||
"Update all fields' text according to the primary field."
|
"Update all fields' text according to the primary field."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user