Closed LemonBreezes closed 8 months ago
It's not quite clear where things are going wrong just from this backtrace. We get to the preview stage and then an error. If you could:
Then it would be easier to see where things are going wrong.
It's not quite clear where things are going wrong just from this backtrace. We get to the preview stage and then an error. If you could:
- Load consult-yasnippet.el directly instead of the bytecompiled elc file and reproduce the stacktrace.
- Share which snippet this is happening with.
Then it would be easier to see where things are going wrong.
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
-(9762 nil)
(let* ((yas-verbosity 0) (inhibit-redisplay t) (inhibit-read-only t) (orig-offset (- (point-max) (cdr region))) (yas-prompt-functions '(yas-no-prompt))) (delete-region (car region) (cdr region)) (goto-char (car region)) (setq region (cons (car initial-region) (cdr initial-region))) (insert initial-region-contents) (if (not region-active-initially) (progn (setq region (consult-yasnippet--bounds-of-thing-at-point template)) (setq initial-region region) (setq initial-region-contents (buffer-substring (car region) (cdr region))))) (if (and region-active-initially (eq action 'return)) (progn (activate-mark) (set-mark (car region)) (goto-char (cdr region)))) (if (and template (not (eq action 'return))) (progn (unwind-protect (consult-yasnippet--expand-template template region) (unwind-protect (mapc #'yas--commit-snippet (yas-active-snippets (point-min) (point-max))) (setcdr region (- (point-max) orig-offset)) (deactivate-mark))) (redisplay))))
(save-current-buffer (set-buffer buf) (let* ((yas-verbosity 0) (inhibit-redisplay t) (inhibit-read-only t) (orig-offset (- (point-max) (cdr region))) (yas-prompt-functions '(yas-no-prompt))) (delete-region (car region) (cdr region)) (goto-char (car region)) (setq region (cons (car initial-region) (cdr initial-region))) (insert initial-region-contents) (if (not region-active-initially) (progn (setq region (consult-yasnippet--bounds-of-thing-at-point template)) (setq initial-region region) (setq initial-region-contents (buffer-substring (car region) (cdr region))))) (if (and region-active-initially (eq action 'return)) (progn (activate-mark) (set-mark (car region)) (goto-char (cdr region)))) (if (and template (not (eq action 'return))) (progn (unwind-protect (consult-yasnippet--expand-template template region) (unwind-protect (mapc #'yas--commit-snippet (yas-active-snippets ... ...)) (setcdr region (- ... orig-offset)) (deactivate-mark))) (redisplay)))))
(closure ((region) (initial-region-contents . "") (initial-region) (region-active-initially) (buf . #<buffer consult-yasnippet.el>)) (action template) (save-current-buffer (set-buffer buf) (let* ((yas-verbosity 0) (inhibit-redisplay t) (inhibit-read-only t) (orig-offset (- (point-max) (cdr region))) (yas-prompt-functions '(yas-no-prompt))) (delete-region (car region) (cdr region)) (goto-char (car region)) (setq region (cons (car initial-region) (cdr initial-region))) (insert initial-region-contents) (if (not region-active-initially) (progn (setq region (consult-yasnippet--bounds-of-thing-at-point template)) (setq initial-region region) (setq initial-region-contents (buffer-substring ... ...)))) (if (and region-active-initially (eq action 'return)) (progn (activate-mark) (set-mark (car region)) (goto-char (cdr region)))) (if (and template (not (eq action ...))) (progn (unwind-protect (consult-yasnippet--expand-template template region) (unwind-protect ... ... ...)) (redisplay))))))(return #s(yas--template :key "sb" :content "(save-buffer $0)" :name "save-buffer" :condition nil :expand-env nil :load-file "/home/st/.config/emacs/.local/straight/build-30.0.50/doom-snippets/emacs-lisp-mode/save-buffer" :save-file nil :keybinding nil :uuid "save-buffer" :menu-binding-pair ((menu-item "save-buffer" (lambda nil (interactive) (yas--expand-or-visit-from-menu 'emacs-lisp-mode "save-buffer")) :keys "sb =>")) :group nil :perm-group nil :table #s(yas--table :name "emacs-lisp-mode" :hash #<hash-table equal 183/217 0x1c0b9f5 ...> :uuidhash #<hash-table equal 187/217 0x101c951 ...> :parents nil :direct-keymap (keymap))))
#f(compiled-function () #<bytecode 0x1beef0cfc218267a>)()
consult--with-preview-1((:debounce 0.4 any) (closure ((region) (initial-region-contents . "") (initial-region) (region-active-initially) (buf . #<buffer consult-yasnippet.el>)) (action template) (save-current-buffer (set-buffer buf) (let* ((yas-verbosity 0) (inhibit-redisplay t) (inhibit-read-only t) (orig-offset (- (point-max) (cdr region))) (yas-prompt-functions '(yas-no-prompt))) (delete-region (car region) (cdr region)) (goto-char (car region)) (setq region (cons (car initial-region) (cdr initial-region))) (insert initial-region-contents) (if (not region-active-initially) (progn (setq region (consult-yasnippet--bounds-of-thing-at-point template)) (setq initial-region region) (setq initial-region-contents (buffer-substring ... ...)))) (if (and region-active-initially (eq action 'return)) (progn (activate-mark) (set-mark (car region)) (goto-char (cdr region)))) (if (and template (not (eq action ...))) (progn (unwind-protect (consult-yasnippet--expand-template template region) (unwind-protect ... ... ...)) (redisplay)))))) #f(compiled-function (narrow input cand) #<bytecode -0x136ddb195b37c32c>) #f(compiled-function (&rest args2) #<bytecode -0x14b9583db153fd7f>) #f(compiled-function () #<bytecode 0x1d2ebe30b58b9a74>))
consult--read-1((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :prompt "Choose a snippet: " :annotate (closure ... ... ...) :initial nil :lookup consult--lookup-cdr :require-match t :state (closure ... ... ...) :category ...)
consult--read((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :prompt "Choose a snippet: " :annotate (closure ... ... ...) :initial nil :lookup consult--lookup-cdr :require-match t :state (closure ... ... ...) :category ...)
(let* ((buffer-undo-list t) (candidates (consult-yasnippet--candidates (if all-templates (yas--all-templates (map-values yas--tables)) (yas--all-templates (yas--get-snippet-tables)))))) (consult--read candidates :prompt "Choose a snippet: " :annotate (consult-yasnippet--annotate candidates) :initial (if consult-yasnippet-use-thing-at-point (progn (thing-at-point 'symbol))) :lookup 'consult--lookup-cdr :require-match t :state (consult-yasnippet--preview) :category 'yasnippet))
consult-yasnippet--read-template(nil)
(and t (consult-yasnippet--read-template arg))
(let* ((template (and t (consult-yasnippet--read-template arg)))) (if template (let* ((thing-bounds (if (region-active-p) (cons nil nil) (consult-yasnippet--bounds-of-thing-at-point template))) (thing-start (car thing-bounds)) (thing-end (cdr thing-bounds))) (yas-expand-snippet (let* ((cl-x template)) (progn (or (let* ... ...) (signal ... ...)) (aref cl-x 2))) thing-start thing-end (let* ((cl-x template)) (progn (or (let* ... ...) (signal ... ...)) (aref cl-x 5))))) nil))
consult-yasnippet(nil)
funcall-interactively(consult-yasnippet nil)
call-interactively(consult-yasnippet)
(cond (t (call-interactively #'consult-yasnippet)) (t (call-interactively #'yas-insert-snippet)))
+default/insert-snippet()
funcall-interactively(+default/insert-snippet)
command-execute(+default/insert-snippet)
based on this new backtrace, what's happening is that in consult-yasnippet--preview
, (let (... (orig-offset (- (point-max) (cdr region)))))
is doing (- 9762 nil)
.
For me, it's happening with every snippet.
Replacing that let binding with
(initial-region (if (use-region-p)
(cons (region-beginning) (region-end))
(or (bounds-of-thing-at-point 'symbol)
(cons (point) (point)))))
fixes that error and seems to use the symbol at point that way for me.
@LemonBreezes
Sorry for the delay. That's interesting. I'm unsure why adding a bounds-of-thing check there would solve the problem. Something else seems to be clearing out the region and causing an error for you but I can't reproduce :cry:. Do you have any extra customisations set for consult-yasnippet or are you just using the default options?
@LemonBreezes
Sorry for the delay. That's interesting. I'm unsure why adding a bounds-of-thing check there would solve the problem. Something else seems to be clearing out the region and causing an error for you but I can't reproduce 😢. Do you have any extra customisations set for consult-yasnippet or are you just using the default options?
Hi. Sorry, I had forgotten about this issue. I think it is no longer reproducible for me so it must've been Emacs30-related or something. I opened a PR, #14, for a separate issue though.
Hi. I am using Emacs30 and the latest versions of all packages (not sure if that is related). When I have
consult-yasnippet-use-thing-at-point
set tot
and I useconsult-yasnippet
, I get the following error: