yasnippet.el (yas-define-snippets): Remove costly no-op

This commit is contained in:
Stefan Monnier 2024-01-22 13:46:05 -05:00
parent 5af84cdb94
commit 47b38b2133

View File

@ -1827,14 +1827,6 @@ the current buffers contents."
(if yas--creating-compiled-snippets (if yas--creating-compiled-snippets
(let ((print-length nil)) (let ((print-length nil))
(insert ";;; Snippet definitions:\n;;;\n") (insert ";;; Snippet definitions:\n;;;\n")
(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
;; compiled file, not LOAD-FILE.
(let ((load-file (nth 6 snippet)))
(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"))
@ -1942,7 +1934,8 @@ With prefix argument USE-JIT do jit-loading of snippets."
(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) 'noerror (<= yas-verbosity 3)) (unless (and (load (expand-file-name ".yas-compiled-snippets" directory)
'noerror (<= yas-verbosity 3))
(progn (yas--message 4 "Loaded compiled snippets from %s" directory) t)) (progn (yas--message 4 "Loaded compiled snippets from %s" directory) t))
(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)))))
@ -2091,7 +2084,7 @@ prefix argument."
This works by stubbing a few functions, then calling This works by stubbing a few functions, then calling
`yas-load-directory'." `yas-load-directory'."
(interactive "DTop level snippet directory?") (interactive "DTop level snippet directory? ")
(let ((yas--creating-compiled-snippets t)) (let ((yas--creating-compiled-snippets t))
(yas-load-directory top-level-dir nil))) (yas-load-directory top-level-dir nil)))
@ -4971,6 +4964,7 @@ When multiple expressions are found, only the last one counts."
;; When not in an undo, check if we must commit the snippet ;; When not in an undo, check if we must commit the snippet
;; (user exited it). ;; (user exited it).
(yas--check-commit-snippet)))) (yas--check-commit-snippet))))
;; FIXME: Why?
((debug error) (signal (car err) (cdr err))))) ((debug error) (signal (car err) (cdr err)))))
;;; Fancy docs: ;;; Fancy docs: