justinbarclay / parinfer-rust-mode

Simplifying how you write Lisp
https://shaunlebron.github.io/parinfer/
GNU General Public License v3.0
227 stars 16 forks source link

Fails to parse comments #95

Closed dmvianna closed 3 months ago

dmvianna commented 3 months ago

I've noticed recently after updating my libraries that when I run emacs 29.3 with emacs --debug-init and start editing any elisp file, I get this:

Debugger entered--Lisp error: (wrong-type-argument stringp paren)
  parinfer-rust-make-request(paren ";;; languages.el --- Summary  -*- lexical-binding:..." #<user-ptr ptr=0x7bd6410 finalizer=0x7fb8131e9f20>)
  parinfer-rust--execute()
  parinfer-rust--changes-signal(#s(track-changes--tracker :signal parinfer-rust--changes-signal :state #s(track-changes--state :beg 10715 :end 1 :before nil :next nil) :nobefore nil :immediate nil))
  track-changes--call-signal(#<buffer languages.el> #s(track-changes--tracker :signal parinfer-rust--changes-signal :state #s(track-changes--state :beg 10715 :end 1 :before nil :next nil) :nobefore nil :immediate nil))
  apply(track-changes--call-signal (#<buffer languages.el> #s(track-changes--tracker :signal parinfer-rust--changes-signal :state #s(track-changes--state :beg 10715 :end 1 :before nil :next nil) :nobefore nil :immediate nil)))
  timer-event-handler([t 26209 19360 319883 nil track-changes--call-signal (#<buffer languages.el> #s(track-changes--tracker :signal parinfer-rust--changes-signal :state #s(track-changes--state :beg 10715 :end 1 :before nil :next nil) :nobefore nil :immediate nil)) nil 907000 nil])

My interpretation is that parinfer-rust-mode is unable to parse comments, which is very surprising.

dmvianna commented 3 months ago

To trigger the problem I can just open the config after starting and add whitespace. However if I use parinfer-rust-switch-mode after the first error is triggered, then I cease to see the problem. Using that function before the error is triggered does not prevent it.

justinbarclay commented 3 months ago

I dogfood parinfer-rust-mode all the time in emacs-lisp files, and they have lots of comments so this shouldn't be true.

What versions of parinfer-rust-mode and parinfer-rust do you have installed? You can check the library's version by calling the parifner-rust-version function.

(parinfer-rust-version)

Additionally, what does your parinfer-rust-mode config look like?

dmvianna commented 3 months ago

Version 0.4.6

(use-package parinfer-rust-mode
  :custom
  (parinfer-rust-troublesome-modes ;; removed electric-pair-mode from list
   '(hungry-delete-mode global-hungry-delete-mode))
  (parinfer-rust-auto-download t)
  (electric-pair-local-mode -1)
  (parinfer-rust-preferred-mode 'paren)
  :hook
  (emacs-lisp-mode
   ielm-mode
   lisp-mode
   slime-repl-mode
   lisp-interaction-mode
   racket-mode)
  (before-save . delete-trailing-whitespace))
justinbarclay commented 3 months ago

I am not sure if this is your problem but parinfer-rust-preferred-mode should be a string and not a symbol.

From:

(parinfer-rust-preferred-mode 'paren)

To:

(parinfer-rust-preferred-mode "paren")

This might explain why switching modes would fix it.

dmvianna commented 3 months ago

Oh, I'm glad I reported the issue! That was easy, thank you!

Did you change your API? I wouldn't have come up with a symbol were I not copying it from somewhere else šŸ¤” .

Happy to close, after making the change the error disappeared.

justinbarclay commented 3 months ago

I don't think that I changed the API; looking through the git-blame, it looks like it always required a string. However, I also think that this is a pretty reasonable API, so I have added support for symbols when using setq for parinfer-rust-preferred-mode.

Thanks for bringing this up šŸ™‚