mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
* Commands are now identified by a new "# type: command" directive.
This commit is contained in:
parent
0b55a52b8d
commit
088ba32300
14
yasnippet.el
14
yasnippet.el
@ -1235,6 +1235,7 @@ line through the syntax:
|
|||||||
|
|
||||||
Here's a list of currently recognized variables:
|
Here's a list of currently recognized variables:
|
||||||
|
|
||||||
|
* type
|
||||||
* name
|
* name
|
||||||
* contributor
|
* contributor
|
||||||
* condition
|
* condition
|
||||||
@ -1249,7 +1250,8 @@ Here's a list of currently recognized variables:
|
|||||||
;;
|
;;
|
||||||
;;
|
;;
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(let* ((name (and file
|
(let* ((type 'snippet)
|
||||||
|
(name (and file
|
||||||
(file-name-nondirectory file)))
|
(file-name-nondirectory file)))
|
||||||
(key (unless yas/ignore-filenames-as-triggers
|
(key (unless yas/ignore-filenames-as-triggers
|
||||||
(and name
|
(and name
|
||||||
@ -1268,12 +1270,16 @@ Here's a list of currently recognized variables:
|
|||||||
(setq bound (point))
|
(setq bound (point))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*\\)$" bound t)
|
(while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*\\)$" bound t)
|
||||||
|
(when (string= "type" (match-string-no-properties 1))
|
||||||
|
(setq type (if (string= "command" (match-string-no-properties 2))
|
||||||
|
'command
|
||||||
|
'snippet)))
|
||||||
|
(when (string= "key" (match-string-no-properties 1))
|
||||||
|
(setq key (match-string-no-properties 2)))
|
||||||
(when (string= "name" (match-string-no-properties 1))
|
(when (string= "name" (match-string-no-properties 1))
|
||||||
(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 (match-string-no-properties 2)))
|
(setq condition (match-string-no-properties 2)))
|
||||||
(when (string= "key" (match-string-no-properties 1))
|
|
||||||
(setq key (match-string-no-properties 2)))
|
|
||||||
(when (string= "group" (match-string-no-properties 1))
|
(when (string= "group" (match-string-no-properties 1))
|
||||||
(setq group (match-string-no-properties 2)))
|
(setq group (match-string-no-properties 2)))
|
||||||
(when (string= "expand-env" (match-string-no-properties 1))
|
(when (string= "expand-env" (match-string-no-properties 1))
|
||||||
@ -1283,7 +1289,7 @@ Here's a list of currently recognized variables:
|
|||||||
(setq binding (match-string-no-properties 2)))))
|
(setq binding (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))))
|
||||||
(when (aget expand-env 'yas/command)
|
(when (eq type 'command)
|
||||||
(setq template (yas/read-lisp (concat "(progn" template ")"))))
|
(setq template (yas/read-lisp (concat "(progn" template ")"))))
|
||||||
(list key template name condition group expand-env file binding)))
|
(list key template name condition group expand-env file binding)))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user