Fix #4127: arrayp error on some snippets via +snippets/edit
This commit is contained in:
parent
ed1996e6f9
commit
523ced6e9a
2 changed files with 34 additions and 31 deletions
|
@ -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)))
|
(abbreviate-file-name (yas--template-load-file tpl)))
|
||||||
collect
|
collect
|
||||||
(progn
|
(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))
|
path ,(yas--template-load-file tpl))
|
||||||
txt)
|
txt)
|
||||||
txt))
|
txt))
|
||||||
|
@ -169,9 +169,9 @@ buggy behavior when <delete> is pressed in an empty field."
|
||||||
(interactive
|
(interactive
|
||||||
(list
|
(list
|
||||||
(+snippet--completing-read-uuid "Visit snippet: " current-prefix-arg)))
|
(+snippet--completing-read-uuid "Visit snippet: " current-prefix-arg)))
|
||||||
(if-let (template (yas--get-template-by-uuid major-mode template-uuid))
|
(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)))
|
||||||
(template-path (yas--template-load-file template)))
|
(progn
|
||||||
(unless (file-readable-p template-path)
|
(unless (file-readable-p template-path)
|
||||||
(user-error "Cannot read %S" template-path))
|
(user-error "Cannot read %S" template-path))
|
||||||
(find-file template-path)
|
(find-file template-path)
|
||||||
|
@ -239,21 +239,22 @@ shadow the default snippet)."
|
||||||
(list
|
(list
|
||||||
(+snippet--completing-read-uuid "Select snippet to alias: "
|
(+snippet--completing-read-uuid "Select snippet to alias: "
|
||||||
current-prefix-arg)))
|
current-prefix-arg)))
|
||||||
(let* ((major-mode (if (eq major-mode 'snippet-mode)
|
(if-let* ((major-mode (if (eq major-mode 'snippet-mode)
|
||||||
(intern (file-name-base (directory-file-name default-directory)))
|
(intern (file-name-base (directory-file-name default-directory)))
|
||||||
major-mode))
|
major-mode))
|
||||||
(template (yas--get-template-by-uuid major-mode template-uuid))
|
(template (yas--get-template-by-uuid major-mode template-uuid))
|
||||||
(template-path (yas--template-load-file template)))
|
(template-path (yas--template-load-file template)))
|
||||||
(if (file-in-directory-p template-path +snippets-dir)
|
(if (file-in-directory-p template-path +snippets-dir)
|
||||||
(find-file template-path)
|
(find-file template-path)
|
||||||
(let ((buf (get-buffer-create (format "*%s*" (file-name-nondirectory template-path)))))
|
(let ((buf (get-buffer-create (format "*%s*" (file-name-nondirectory template-path)))))
|
||||||
(with-current-buffer (switch-to-buffer buf)
|
(with-current-buffer (switch-to-buffer buf)
|
||||||
(insert-file-contents template-path)
|
(insert-file-contents template-path)
|
||||||
(snippet-mode)
|
(snippet-mode)
|
||||||
(setq default-directory
|
(setq default-directory
|
||||||
(expand-file-name (file-name-nondirectory template-path)
|
(expand-file-name (file-name-nondirectory template-path)
|
||||||
(expand-file-name (symbol-name major-mode)
|
(expand-file-name (symbol-name major-mode)
|
||||||
+snippets-dir))))))))
|
+snippets-dir))))))
|
||||||
|
(user-error "Couldn't find a snippet with uuid %S" template-uuid)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +snippets-show-hints-in-header-line-h ()
|
(defun +snippets-show-hints-in-header-line-h ()
|
||||||
|
|
|
@ -78,18 +78,20 @@
|
||||||
;; Enable `read-only-mode' for built-in snippets (in `doom-local-dir')
|
;; Enable `read-only-mode' for built-in snippets (in `doom-local-dir')
|
||||||
(add-hook 'snippet-mode-hook #'+snippets-read-only-maybe-h)
|
(add-hook 'snippet-mode-hook #'+snippets-read-only-maybe-h)
|
||||||
|
|
||||||
(map! :map yas-keymap
|
(map! (:map yas-keymap
|
||||||
"C-e" #'+snippets/goto-end-of-field
|
"C-e" #'+snippets/goto-end-of-field
|
||||||
"C-a" #'+snippets/goto-start-of-field
|
"C-a" #'+snippets/goto-start-of-field
|
||||||
[M-right] #'+snippets/goto-end-of-field
|
[M-right] #'+snippets/goto-end-of-field
|
||||||
[M-left] #'+snippets/goto-start-of-field
|
[M-left] #'+snippets/goto-start-of-field
|
||||||
[M-backspace] #'+snippets/delete-to-start-of-field
|
[M-backspace] #'+snippets/delete-to-start-of-field
|
||||||
[backspace] #'+snippets/delete-backward-char
|
[backspace] #'+snippets/delete-backward-char
|
||||||
[delete] #'+snippets/delete-forward-char-or-field
|
[delete] #'+snippets/delete-forward-char-or-field
|
||||||
;; Replace commands with superior alternatives
|
;; Replace commands with superior alternatives
|
||||||
:map yas-minor-mode-map
|
:map yas-minor-mode-map
|
||||||
[remap yas-new-snippet] #'+snippets/new
|
[remap yas-new-snippet] #'+snippets/new
|
||||||
[remap yas-visit-snippet-file] #'+snippets/edit)
|
[remap yas-visit-snippet-file] #'+snippets/edit)
|
||||||
|
(:map snippet-mode-map
|
||||||
|
"C-c C-k" #'+snippet--abort))
|
||||||
|
|
||||||
;; REVIEW Fix #2639: For some reason `yas--all-templates' returns duplicates
|
;; REVIEW Fix #2639: For some reason `yas--all-templates' returns duplicates
|
||||||
;; of some templates. Until I figure out the real cause this fixes it.
|
;; of some templates. Until I figure out the real cause this fixes it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue