Skip to content

Commit

Permalink
fix: Add handler for when preferred-mode is a symbol
Browse files Browse the repository at this point in the history
Normally, it's expected to be a string, but it's perfectly reasonable
for a user to want to use a symbol so let's support that.
  • Loading branch information
justinbarclay committed Jun 10, 2024
1 parent f74f7b8 commit a96c768
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions parinfer-rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,10 @@ CHANGES."
;; those parinfer expects.
(setq parinfer-rust--changes nil)
mode)
parinfer-rust--mode))
;; Through impropriety or mistakes parinfer-rust--mode _could_ be set to nil.
;; So let's make sure a sensible default is set just in case.
(or parinfer-rust--mode
"paren")))
(old-options (or (parinfer-rust--local-bound-and-true parinfer-rust--previous-options)
(parinfer-rust-make-option)))
(changes (if (> (length parinfer-rust--changes) 0)
Expand Down Expand Up @@ -718,7 +721,11 @@ Checks if MODE is a valid Parinfer mode, and uses
"Enable Parinfer."
(parinfer-rust--detect-troublesome-modes)
(parinfer-rust--set-default-state)
(setq-local parinfer-rust--mode parinfer-rust-preferred-mode)
(setq-local parinfer-rust--mode (if (stringp parinfer-rust-preferred-mode)
parinfer-rust-preferred-mode
(and (symbolp parinfer-rust-preferred-mode)
(symbol-name parinfer-rust-preferred-mode))))

(advice-add 'undo :around #'parinfer-rust--track-undo)
(advice-add 'undo-tree-undo :around #'parinfer-rust--track-undo)
(if (fboundp 'track-changes-register)
Expand Down

0 comments on commit a96c768

Please sign in to comment.