Accept documented snippet list formats

yas-define-snippets was making assumptions that happended to be true for
its current calls, but could fail if given differently formatted snippet
lists that still meet the docstring description.

* yasnippet.el (yas-define-snippets): Handle incomplete snippet lists.
This commit is contained in:
Noam Postavsky 2015-09-05 13:41:12 -04:00
parent 215ad9bcf2
commit 68b0ab66ca

View File

@ -1660,11 +1660,13 @@ the current buffers contents."
(let ((print-length nil)) (let ((print-length nil))
(insert ";;; Snippet definitions:\n;;;\n") (insert ";;; Snippet definitions:\n;;;\n")
(dolist (snippet snippets) (dolist (snippet snippets)
;; Fill in missing elements with nil.
(setq snippet (append snippet (make-list (- 10 (length snippet)) nil)))
;; Move LOAD-FILE to SAVE-FILE because we will load from the ;; Move LOAD-FILE to SAVE-FILE because we will load from the
;; compiled file, not LOAD-FILE. ;; compiled file, not LOAD-FILE.
(let ((load-file-cell (nthcdr 6 snippet))) (let ((load-file (nth 6 snippet)))
(setcdr (last snippet) (list (car load-file-cell))) (setcar (nthcdr 6 snippet) nil)
(setcar (nthcdr 6 snippet) nil))) (setcar (nthcdr 9 snippet) load-file)))
(insert (pp-to-string (insert (pp-to-string
`(yas-define-snippets ',mode ',snippets))) `(yas-define-snippets ',mode ',snippets)))
(insert "\n\n")) (insert "\n\n"))