mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-15 05:53:04 +00:00
bugfix: better with-snippet-dirs
macro
This commit is contained in:
parent
275ac7fe00
commit
b347b61360
@ -205,10 +205,9 @@ TODO: correct this bug!"
|
|||||||
(let ((default-directory (concat default-directory "/" file-or-dir-name)))
|
(let ((default-directory (concat default-directory "/" file-or-dir-name)))
|
||||||
(mapc #'yas/make-file-or-dirs content)))
|
(mapc #'yas/make-file-or-dirs content)))
|
||||||
((stringp content)
|
((stringp content)
|
||||||
(with-current-buffer (find-file file-or-dir-name)
|
(with-temp-buffer
|
||||||
(insert content)
|
(insert content)
|
||||||
(save-buffer)
|
(write-region nil nil file-or-dir-name nil 'nomessage)))
|
||||||
(kill-buffer (current-buffer))))
|
|
||||||
(t
|
(t
|
||||||
(message "[yas] oops don't know this content")))))
|
(message "[yas] oops don't know this content")))))
|
||||||
|
|
||||||
@ -228,15 +227,22 @@ TODO: correct this bug!"
|
|||||||
(yas/variables))
|
(yas/variables))
|
||||||
,@body))
|
,@body))
|
||||||
|
|
||||||
(defmacro with-snippet-dirs (dirs &rest body)
|
(defun yas/call-with-snippet-dirs (dirs fn)
|
||||||
`(let ((default-directory (make-temp-file "yasnippet-fixture" t)))
|
(let ((default-directory (make-temp-file "yasnippet-fixture" t))
|
||||||
|
(message-log-max nil)
|
||||||
|
(yas/snippet-dirs (mapcar #'car (cadr dirs))))
|
||||||
|
(with-temp-message ""
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(setq yas/snippet-dirs ',(mapcar #'car (cadr dirs)))
|
(mapc #'yas/make-file-or-dirs dirs)
|
||||||
(mapc #'yas/make-file-or-dirs ,dirs)
|
(funcall fn))
|
||||||
,@body)
|
|
||||||
(when (>= emacs-major-version 23)
|
(when (>= emacs-major-version 23)
|
||||||
(delete-directory default-directory 'recursive)))))
|
(delete-directory default-directory 'recursive))))))
|
||||||
|
|
||||||
|
(defmacro with-snippet-dirs (dirs &rest body)
|
||||||
|
`(yas/call-with-snippet-dirs ,dirs
|
||||||
|
#'(lambda ()
|
||||||
|
,@body)))
|
||||||
|
|
||||||
;;; Older emacsen
|
;;; Older emacsen
|
||||||
;;;
|
;;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user