Ignore trailing spaces in snippet definitions

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
This commit is contained in:
Sharif Nassar 2015-11-08 10:28:16 -08:00 committed by Noam Postavsky
parent 3aa7cb29d4
commit 1cf723a408
2 changed files with 10 additions and 1 deletions

View File

@ -123,6 +123,15 @@
(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)

View 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))