mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
Try and fix issue #1214
* yasnippet.el (yas--load-directory-1): Add a `lexical-binding` cookie to the compiled-snippet files, and silence warnings if it's absent from them. (yas--letenv-f): New function extracted from `yas--letenv`. (yas--letenv): Use it.
This commit is contained in:
parent
2384fe1655
commit
272b6067f1
23
yasnippet.el
23
yasnippet.el
@ -1933,16 +1933,18 @@ With prefix argument USE-JIT do jit-loading of snippets."
|
|||||||
(let ((output-file (expand-file-name ".yas-compiled-snippets.el"
|
(let ((output-file (expand-file-name ".yas-compiled-snippets.el"
|
||||||
directory)))
|
directory)))
|
||||||
(with-temp-file output-file
|
(with-temp-file output-file
|
||||||
(insert (format ";;; Compiled snippets and support files for `%s'\n"
|
(insert (format ";;; \"Compiled\" snippets and support files for `%S' -*- lexical-binding:t -*-\n"
|
||||||
mode-sym))
|
mode-sym))
|
||||||
(yas--load-directory-2 directory mode-sym)
|
(yas--load-directory-2 directory mode-sym)
|
||||||
(insert (format ";;; Do not edit! File generated at %s\n"
|
(insert (format ";;; Do not edit! File generated at %s\n"
|
||||||
(current-time-string)))))
|
(current-time-string)))))
|
||||||
;; Normal case.
|
;; Normal case.
|
||||||
(unless (file-exists-p (expand-file-name ".yas-skip" directory))
|
(unless (file-exists-p (expand-file-name ".yas-skip" directory))
|
||||||
(unless (and (load (expand-file-name ".yas-compiled-snippets" directory)
|
(if (let ((warning-inhibit-types
|
||||||
'noerror (<= yas-verbosity 3))
|
'((files missing-lexbind-cookie))))
|
||||||
(progn (yas--message 4 "Loaded compiled snippets from %s" directory) t))
|
(load (expand-file-name ".yas-compiled-snippets" directory)
|
||||||
|
'noerror (<= yas-verbosity 3)))
|
||||||
|
(yas--message 4 "Loaded compiled snippets from %s" directory)
|
||||||
(yas--message 4 "Loading snippet files from %s" directory)
|
(yas--message 4 "Loading snippet files from %s" directory)
|
||||||
(yas--load-directory-2 directory mode-sym)))))
|
(yas--load-directory-2 directory mode-sym)))))
|
||||||
|
|
||||||
@ -3200,12 +3202,13 @@ ENV is a lisp expression that evaluates to list of elements with
|
|||||||
the form (VAR FORM), where VAR is a symbol and FORM is a lisp
|
the form (VAR FORM), where VAR is a symbol and FORM is a lisp
|
||||||
expression that evaluates to its value."
|
expression that evaluates to its value."
|
||||||
(declare (debug (form body)) (indent 1))
|
(declare (debug (form body)) (indent 1))
|
||||||
(let ((envvar (make-symbol "envvar")))
|
`(yas--letenv-f ,env (lambda () ,@body)))
|
||||||
`(let ((,envvar ,env))
|
|
||||||
(cl-progv
|
(defun yas--letenv-f (env body-fun)
|
||||||
(mapcar #'car ,envvar)
|
(cl-progv
|
||||||
(mapcar (lambda (v-f) (eval (cadr v-f) t)) ,envvar)
|
(mapcar #'car env)
|
||||||
,@body))))
|
(mapcar (lambda (v-f) (eval (cadr v-f) t)) env)
|
||||||
|
(funcall body-fun)))
|
||||||
|
|
||||||
(defun yas--snippet-map-markers (fun snippet)
|
(defun yas--snippet-map-markers (fun snippet)
|
||||||
"Apply FUN to all marker (sub)fields in SNIPPET.
|
"Apply FUN to all marker (sub)fields in SNIPPET.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user