Fix #4127: arrayp error on some snippets via +snippets/edit

This commit is contained in:
Henrik Lissner 2020-11-14 14:16:01 -05:00
parent ed1996e6f9
commit 523ced6e9a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 34 additions and 31 deletions

View file

@ -47,7 +47,7 @@ ignored. This makes it easy to override built-in snippets with private ones."
(abbreviate-file-name (yas--template-load-file tpl)))
collect
(progn
(set-text-properties 0 (length txt) `(uuid ,(yas--template-name tpl)
(set-text-properties 0 (length txt) `(uuid ,(yas--template-uuid tpl)
path ,(yas--template-load-file tpl))
txt)
txt))
@ -169,9 +169,9 @@ buggy behavior when <delete> is pressed in an empty field."
(interactive
(list
(+snippet--completing-read-uuid "Visit snippet: " current-prefix-arg)))
(if-let (template (yas--get-template-by-uuid major-mode template-uuid))
(let* ((template (yas--get-template-by-uuid major-mode template-uuid))
(template-path (yas--template-load-file template)))
(if-let* ((template (yas--get-template-by-uuid major-mode template-uuid))
(template-path (yas--template-load-file template)))
(progn
(unless (file-readable-p template-path)
(user-error "Cannot read %S" template-path))
(find-file template-path)
@ -239,21 +239,22 @@ shadow the default snippet)."
(list
(+snippet--completing-read-uuid "Select snippet to alias: "
current-prefix-arg)))
(let* ((major-mode (if (eq major-mode 'snippet-mode)
(intern (file-name-base (directory-file-name default-directory)))
major-mode))
(template (yas--get-template-by-uuid major-mode template-uuid))
(template-path (yas--template-load-file template)))
(if (file-in-directory-p template-path +snippets-dir)
(find-file template-path)
(let ((buf (get-buffer-create (format "*%s*" (file-name-nondirectory template-path)))))
(with-current-buffer (switch-to-buffer buf)
(insert-file-contents template-path)
(snippet-mode)
(setq default-directory
(expand-file-name (file-name-nondirectory template-path)
(expand-file-name (symbol-name major-mode)
+snippets-dir))))))))
(if-let* ((major-mode (if (eq major-mode 'snippet-mode)
(intern (file-name-base (directory-file-name default-directory)))
major-mode))
(template (yas--get-template-by-uuid major-mode template-uuid))
(template-path (yas--template-load-file template)))
(if (file-in-directory-p template-path +snippets-dir)
(find-file template-path)
(let ((buf (get-buffer-create (format "*%s*" (file-name-nondirectory template-path)))))
(with-current-buffer (switch-to-buffer buf)
(insert-file-contents template-path)
(snippet-mode)
(setq default-directory
(expand-file-name (file-name-nondirectory template-path)
(expand-file-name (symbol-name major-mode)
+snippets-dir))))))
(user-error "Couldn't find a snippet with uuid %S" template-uuid)))
;;;###autoload
(defun +snippets-show-hints-in-header-line-h ()