From 088ba32300cdda96bde07a4d5efc3fffb8ec88a9 Mon Sep 17 00:00:00 2001 From: capitaomorte Date: Fri, 16 Oct 2009 14:56:49 +0000 Subject: [PATCH] * Commands are now identified by a new "# type: command" directive. --- yasnippet.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 91c91f7..87350e6 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -1235,6 +1235,7 @@ line through the syntax: Here's a list of currently recognized variables: + * type * name * contributor * condition @@ -1249,7 +1250,8 @@ Here's a list of currently recognized variables: ;; ;; (goto-char (point-min)) - (let* ((name (and file + (let* ((type 'snippet) + (name (and file (file-name-nondirectory file))) (key (unless yas/ignore-filenames-as-triggers (and name @@ -1268,12 +1270,16 @@ Here's a list of currently recognized variables: (setq bound (point)) (goto-char (point-min)) (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)) (setq name (match-string-no-properties 2))) (when (string= "condition" (match-string-no-properties 1)) (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)) (setq group (match-string-no-properties 2))) (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 template (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 ")")))) (list key template name condition group expand-env file binding)))