(require 'cl)
(require 'easymenu)
(require 'help-mode)
-
-;; Future-proof against obsoleting flet, per discussion at
-;; http://github.com/capitaomorte/yasnippet/issues/324
+(require 'assoc)
+
+(eval-when-compile
+ (defvar yas--editing-template)
+ (defvar yas--guessed-modes)
+ (defvar yas--indent-original-column)
+ (defvar yas--scheduled-jit-loads)
+ (defvar yas-keymap)
+ (defvar yas-selected-text)
+ (defvar yas-verbosity))
+
++;; Future-proof against obsoleting flet, see github #324
++;;
+ (eval-and-compile
+ (unless (fboundp 'cl-flet)
+ (defalias 'cl-flet 'flet)
+ (put 'cl-flet 'lisp-indent-function 1)
+ (put 'cl-flet 'edebug-form-spec '((&rest (defun*)) cl-declarations body))))
+
\f
;;; User customizable variables
This works by stubbing a few functions, then calling
`yas-load-directory'."
(interactive "DTop level snippet directory?")
- (flet ((yas--load-yas-setup-file
+ (cl-flet ((yas--load-yas-setup-file
- (file)
- (let ((elfile (concat file ".el")))
- (when (file-exists-p elfile)
- (insert ";;; .yas-setup.el support file if any:\n;;;\n")
- (insert-file-contents elfile)
- (end-of-buffer)
- )))
- (yas-define-snippets
- (mode snippets)
- (insert ";;; Snippet definitions:\n;;;\n")
- (let ((literal-snippets (list))
- (print-length nil))
- (dolist (snippet snippets)
- (let ((key (first snippet))
- (template-content (second snippet))
- (name (third snippet))
- (condition (fourth snippet))
- (group (fifth snippet))
- (expand-env (sixth snippet))
- (file nil) ;; (seventh snippet)) ;; omit on purpose
- (binding (eighth snippet))
- (uuid (ninth snippet)))
- (push `(,key
- ,template-content
- ,name
- ,condition
- ,group
- ,expand-env
- ,file
- ,binding
- ,uuid)
- literal-snippets)))
- (insert (pp-to-string `(yas-define-snippets ',mode ',literal-snippets)))
- (insert "\n\n")))
- (yas--load-directory-1
- (dir mode parents &rest ignore)
- (let ((output-file (concat (file-name-as-directory dir) ".yas-compiled-snippets.el")))
- (with-temp-file output-file
- (insert (format ";;; Compiled snippets and support files for `%s'\n" mode))
- (yas--load-directory-2 dir mode)
- (insert (format ";;; Do not edit! File generated at %s\n" (current-time-string)))))))
+ (file)
+ (let ((elfile (concat file ".el")))
+ (when (file-exists-p elfile)
+ (insert ";;; .yas-setup.el support file if any:\n;;;\n")
+ (insert-file-contents elfile)
+ (goto-char (point-max))
+ )))
+ (yas-define-snippets
+ (mode snippets)
+ (insert ";;; Snippet definitions:\n;;;\n")
+ (let ((literal-snippets (list))
+ (print-length nil))
+ (dolist (snippet snippets)
+ (let ((key (first snippet))
+ (template-content (second snippet))
+ (name (third snippet))
+ (condition (fourth snippet))
+ (group (fifth snippet))
+ (expand-env (sixth snippet))
+ (file nil) ;; (seventh snippet)) ;; omit on purpose
+ (binding (eighth snippet))
+ (uuid (ninth snippet)))
+ (push `(,key
+ ,template-content
+ ,name
+ ,condition
+ ,group
+ ,expand-env
+ ,file
+ ,binding
+ ,uuid)
+ literal-snippets)))
+ (insert (pp-to-string `(yas-define-snippets ',mode ',literal-snippets)))
+ (insert "\n\n")))
+ (yas--load-directory-1
+ (dir mode parents &rest ignore)
+ (let ((output-file (concat (file-name-as-directory dir) ".yas-compiled-snippets.el")))
+ (with-temp-file output-file
+ (insert (format ";;; Compiled snippets and support files for `%s'\n" mode))
+ (yas--load-directory-2 dir mode)
+ (insert (format ";;; Do not edit! File generated at %s\n" (current-time-string)))))))
(yas-load-directory top-level-dir nil)))
(defun yas-recompile-all ()