mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
exit-snippet mostly implemented.
This commit is contained in:
parent
aa7b6f0a91
commit
eee6a51740
38
yasnippet.el
38
yasnippet.el
@ -249,14 +249,20 @@ will be deleted before inserting template."
|
|||||||
;; Step 5: Create fields
|
;; Step 5: Create fields
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward yas/field-regexp nil t)
|
(while (re-search-forward yas/field-regexp nil t)
|
||||||
(yas/snippet-add-field
|
(let ((number (match-string-no-properties 1)))
|
||||||
snippet
|
(if (and number
|
||||||
(yas/snippet-field-new
|
(string= "0" number))
|
||||||
(make-overlay (match-beginning 0) (match-end 0))
|
(progn
|
||||||
(if (match-string-no-properties 1)
|
(replace-match "")
|
||||||
(string-to-number (match-string-no-properties 1))
|
(yas/snippet-exit-marker-set
|
||||||
nil)
|
snippet
|
||||||
(match-string-no-properties 2))))
|
(copy-marker (point) t)))
|
||||||
|
(yas/snippet-add-field
|
||||||
|
snippet
|
||||||
|
(yas/snippet-field-new
|
||||||
|
(make-overlay (match-beginning 0) (match-end 0))
|
||||||
|
(and number (string-to-number number))
|
||||||
|
(match-string-no-properties 2))))))
|
||||||
|
|
||||||
;; Step 6: Sort and link each field group
|
;; Step 6: Sort and link each field group
|
||||||
(yas/snippet-field-groups-set
|
(yas/snippet-field-groups-set
|
||||||
@ -295,14 +301,17 @@ will be deleted before inserting template."
|
|||||||
(length (- end start)))
|
(length (- end start)))
|
||||||
(goto-char start)
|
(goto-char start)
|
||||||
(insert value)
|
(insert value)
|
||||||
(delete-char length))))))
|
(delete-char length)))))
|
||||||
|
|
||||||
;; Step : restore all escape characters
|
;; Step 9: restore all escape characters
|
||||||
(yas/replace-all yas/escape-dollar "$")
|
(yas/replace-all yas/escape-dollar "$")
|
||||||
(yas/replace-all yas/escape-backquote "`")
|
(yas/replace-all yas/escape-backquote "`")
|
||||||
(yas/replace-all yas/escape-backslash "\\")
|
(yas/replace-all yas/escape-backslash "\\")
|
||||||
|
|
||||||
(goto-char (point-max)))
|
;; Step 10: move to end and make sure exit-marker exist
|
||||||
|
(goto-char (point-max))
|
||||||
|
(unless (yas/snippet-exit-marker snippet)
|
||||||
|
(yas/snippet-exit-marker-set snippet (copy-marker (point) t)))))
|
||||||
|
|
||||||
(delete-char length)))
|
(delete-char length)))
|
||||||
|
|
||||||
@ -368,6 +377,7 @@ otherwise, nil returned."
|
|||||||
(defun yas/exit-snippet (snippet)
|
(defun yas/exit-snippet (snippet)
|
||||||
"Goto exit-marker of SNIPPET and delete the snippet."
|
"Goto exit-marker of SNIPPET and delete the snippet."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
(goto-char (yas/snippet-exit-marker snippet))
|
||||||
)
|
)
|
||||||
|
|
||||||
(provide 'yasnippet)
|
(provide 'yasnippet)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user