\r
;;; Commentary:\r
\r
-;; Test basic snippet mechanics and the loading system \r
+;; Test basic snippet mechanics and the loading system\r
\r
;;; Code:\r
\r
(yas/expand-snippet "${1:brother} from another ${2:mother}")\r
(should (string= (buffer-substring-no-properties (point-min) (point-max))\r
"brother from another mother"))\r
- \r
+\r
(should (looking-at "brother"))\r
(ert-simulate-command '(yas/next-field-or-maybe-expand))\r
(should (looking-at "mother"))\r
\r
\r
;;; Misc tests\r
-;;; \r
+;;;\r
\r
(ert-deftest protection-overlay-no-cheating ()\r
"Protection overlays at the very end of the buffer, are dealt by cheatingly inserting a newline!\r
(let ((default-directory (concat default-directory "/" file-or-dir-name)))\r
(mapc #'yas/make-file-or-dirs content)))\r
((stringp content)\r
- (with-current-buffer (find-file file-or-dir-name)\r
+ (with-temp-buffer\r
(insert content)\r
- (save-buffer)\r
- (kill-buffer (current-buffer))))\r
+ (write-region nil nil file-or-dir-name nil 'nomessage)))\r
(t\r
(message "[yas] oops don't know this content")))))\r
\r
(yas/variables))\r
,@body))\r
\r
+(defun yas/call-with-snippet-dirs (dirs fn)\r
+ (let ((default-directory (make-temp-file "yasnippet-fixture" t))\r
+ (message-log-max nil)\r
+ (yas/snippet-dirs (mapcar #'car (cadr dirs))))\r
+ (with-temp-message ""\r
+ (unwind-protect\r
+ (progn\r
+ (mapc #'yas/make-file-or-dirs dirs)\r
+ (funcall fn))\r
+ (when (>= emacs-major-version 23)\r
+ (delete-directory default-directory 'recursive))))))\r
+\r
(defmacro with-snippet-dirs (dirs &rest body)\r
- `(let ((default-directory (make-temp-file "yasnippet-fixture" t)))\r
- (unwind-protect\r
- (progn \r
- (setq yas/snippet-dirs ',(mapcar #'car (cadr dirs)))\r
- (mapc #'yas/make-file-or-dirs ,dirs)\r
- ,@body)\r
- (when (>= emacs-major-version 23)\r
- (delete-directory default-directory 'recursive)))))\r
+ `(yas/call-with-snippet-dirs ,dirs\r
+ #'(lambda ()\r
+ ,@body)))\r
\r
;;; Older emacsen\r
;;;\r