Skip to content

Commit b1b51bb

Browse files
committed
fix(parinfer-rust): disable on some problematic commands
See: justinbarclay/parinfer-rust-mode#91
1 parent c6c465b commit b1b51bb

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

modules/me-emacs-lisp.el

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,25 @@
2525

2626
(defun +parinfer-rust-mode-maybe ()
2727
(when (or parinfer-rust-auto-download (file-exists-p (expand-file-name parinfer-rust--lib-name parinfer-rust-library-directory)))
28-
(parinfer-rust-mode 1))))
28+
(parinfer-rust-mode 1)))
29+
30+
;; HACK: Disable `parinfer-rust-mode' on some commands.
31+
(defvar-local +parinfer-rust--was-enabled-p nil)
32+
33+
(defun +parinfer-rust--restore (&rest _)
34+
(when +parinfer-rust--was-enabled-p
35+
(setq +parinfer-rust--was-enabled-p nil)
36+
(parinfer-rust-mode 1)))
37+
38+
(defun +parinfer-rust--disable (&rest _)
39+
(setq +parinfer-rust--was-enabled-p (bound-and-true-p parinfer-rust-mode))
40+
(when +parinfer-rust--was-enabled-p
41+
(parinfer-rust-mode -1)))
42+
43+
;; Fix the issue of `vundo` (related to `track-changes`) when exploring the undo tree
44+
(with-eval-after-load 'vundo
45+
(add-hook 'vundo-pre-enter-hook #'+parinfer-rust--disable)
46+
(add-hook 'vundo-post-exit-hook #'+parinfer-rust--restore)))
2947

3048
(use-package macrostep
3149
:straight t

modules/me-evil.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,15 @@
12291229

12301230
;;; For `me-emacs-lisp'
12311231

1232+
(with-eval-after-load 'parinfer-rust-mode
1233+
;; The `evil-shif-right' (and `evil-shift-left' which uses it under the hood)
1234+
;; behave strangely when `parinfer-rust-mode' is enabled, so lets disable when
1235+
;; using this command.
1236+
(when (fboundp '+parinfer-rust--disable) ; defined in `me-emacs-lisp'
1237+
(with-eval-after-load 'evil
1238+
(advice-add #'evil-shift-right :before #'+parinfer-rust--disable)
1239+
(advice-add #'evil-shift-right :after #'+parinfer-rust--restore))))
1240+
12321241
(+map-local! :package macrostep :module me-emacs-lisp
12331242
:keymaps '(emacs-lisp-mode-map lisp-mode-map)
12341243
"m" '(macrostep-expand :wk "Expand macro"))

0 commit comments

Comments
 (0)