]> code.delx.au - gnu-emacs-elpa/commitdiff
Ignore trailing spaces in snippet definitions
authorSharif Nassar <sharif@mrwacky.com>
Sun, 8 Nov 2015 18:28:16 +0000 (10:28 -0800)
committerNoam Postavsky <npostavs@users.sourceforge.net>
Sun, 8 Nov 2015 23:05:09 +0000 (18:05 -0500)
Probably nobody wants a snippet `key` with a trailing space. It can
be hard to differentiate from a `key` without trailing space. The
default `<TAB>` behavior of yasnippet will never expand these.

* yasnippet.el (yas--parse-template): Ignore trailing spaces in snippet
  definitions.
* yasnippet-tests.el (deftest ignore-trailing-whitespace): New test for
  new behavior.

Copyright-paperwork-exempt: yes

yasnippet-tests.el
yasnippet.el

index b71ea7e5ea94b7898d604df943aded6b90274aad..9a1e2c23b8e675c70d62fa8db515136d5ef887ab 100644 (file)
     (should (looking-at "ble"))
     (should (null (yas--snippets-at-point)))))
 
+(ert-deftest ignore-trailing-whitespace ()
+  (should (equal
+           (with-temp-buffer
+             (insert "# key: foo\n# --\nfoo")
+             (yas--parse-template))
+           (with-temp-buffer
+             (insert "# key: foo \n# --\nfoo")
+             (yas--parse-template)))))
+
 ;; (ert-deftest in-snippet-undo ()
 ;;   (with-temp-buffer
 ;;     (yas-minor-mode 1)
index ef6a763ca12f5f5ce23045178f45a9b52b2c5edf..c456247dd625d2009f13331fd8f9e5c917ac0380 100644 (file)
@@ -1448,7 +1448,7 @@ Here's a list of currently recognized directives:
                                                      (point-max)))
                (setq bound (point))
                (goto-char (point-min))
-               (while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*\\)$" bound t)
+               (while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*?\\)[[:space:]]*$" bound t)
                  (when (string= "uuid" (match-string-no-properties 1))
                    (setq uuid (match-string-no-properties 2)))
                  (when (string= "type" (match-string-no-properties 1))