From 70191eb0d95c476c8100390e7c2559bfd8d7063b Mon Sep 17 00:00:00 2001 From: Zhang Chiyuan Date: Tue, 9 Dec 2008 16:46:48 +0000 Subject: [PATCH] Accept patch from dima.exe to add #key in template file (Issue 43) --- doc/changelog.rst | 11 +++++++++-- yasnippet.el | 21 ++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 4efc94f..e273d48 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -6,9 +6,16 @@ ChangeLog :Contact: pluskid@gmail.com :Date: 2008-03-22 -0.5.7 / -================= +0.5.7 / 2008-12-03 +================== +* Fixed `Issue 28 + `_ of + properly clean up snippet (by joaotavora). +* Added a new section "Field-level undo functionality" to correct + `Issue 33 `_ + (by joaotavora). +* Added some snippets from users for sql, erlang, scala, html, xml, latex, etc. * Fixed `Issue 16 `_ by adding ``$>`` support. Here's the `doc for $> indenting diff --git a/yasnippet.el b/yasnippet.el index 9e27984..b22834e 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -3,7 +3,7 @@ ;; Copyright 2008 pluskid ;; ;; Author: pluskid -;; Version: 0.5.6 +;; Version: 0.5.7 ;; X-URL: http://code.google.com/p/yasnippet/ ;; This file is free software; you can redistribute it and/or modify @@ -188,7 +188,7 @@ to expand. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Internal variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defvar yas/version "0.5.6") +(defvar yas/version "0.5.7") (defvar yas/snippet-tables (make-hash-table) "A hash table of snippet tables corresponding to each major-mode.") @@ -886,7 +886,7 @@ Here's a list of currently recognized variables: # -- #include \"$1\"" (goto-char (point-min)) - (let ((name file-name) template bound condition) + (let ((name file-name) template bound condition key) (if (re-search-forward "^# --\n" nil t) (progn (setq template (buffer-substring-no-properties (point) @@ -897,10 +897,12 @@ Here's a list of currently recognized variables: (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 (read (match-string-no-properties 2)))))) + (setq condition (read (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 template name condition))) + (list key template name condition))) (defun yas/directory-files (directory file?) "Return directory files or subdirectories in full path." @@ -989,10 +991,11 @@ hierarchy." (dolist (file (yas/directory-files directory t)) (when (file-readable-p file) (insert-file-contents file nil nil nil t) - (let ((snippet-file-name (file-name-nondirectory file))) - (push (cons snippet-file-name - (yas/parse-template snippet-file-name)) - snippets))))) + (let* ((snip (yas/parse-template)) + (key (or (car snip) + (file-name-nondirectory file))) + (snip (cdr snip))) + (push (cons key snip) snippets))))) (yas/define-snippets mode-sym snippets parent)