Skip to content

Commit

Permalink
Switch references parinfer-rust-enabled to parinfer-rust-mode
Browse files Browse the repository at this point in the history
`parinfer-rust-enabled` was used when I understood things less
  • Loading branch information
justinbarclay committed May 4, 2024
1 parent 5360d40 commit 398dc4d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
5 changes: 2 additions & 3 deletions parinfer-rust-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

;;; Code:
(eval-when-compile
(defvar parinfer-rust-enabled)
(defvar parinfer-rust--mode)
(defvar parinfer-rust-dim-parens))
(require 'url)
Expand Down Expand Up @@ -186,7 +185,7 @@ This search is bound to occur before LIMIT."

(defun parinfer-rust--dim-parens ()
"Apply paren dimming if appropriate."
(if (and parinfer-rust-enabled
(if (and parinfer-rust-mode
(not (string-equal parinfer-rust--mode "paren"))
parinfer-rust-dim-parens)
(font-lock-add-keywords
Expand Down Expand Up @@ -239,7 +238,7 @@ mode to better emulate users."
(defun parinfer-rust--defer-loading (&rest _)
"Defer loading of `parinfer-rust-mode' until the buffer is in focus."
;; This is a parinfer enabled buffer that started in the background and has now been moved to the foreground
(when (and parinfer-rust-enabled
(when (and parinfer-rust-mode
(eq (current-buffer)
(window-buffer (selected-window))))
(remove-hook 'window-selection-change-functions #'parinfer-rust--defer-loading t)
Expand Down
6 changes: 1 addition & 5 deletions parinfer-rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ command should be run in.")
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Local State
;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar-local parinfer-rust-enabled nil "Tracks if parinfer has been enabled.")
(defvar-local parinfer-rust--in-debug nil
"When enabled, outputs the response input and output of the parinfer response to a file.")
(defvar-local parinfer-rust--mode "paren"
Expand Down Expand Up @@ -521,7 +520,6 @@ Checks if MODE is a valid Parinfer mode, and uses

(defun parinfer-rust-mode-setup ()
"Enable Parinfer."
(setq-local parinfer-rust-enabled t)
(parinfer-rust--detect-troublesome-modes)
(parinfer-rust--set-default-state)
(setq-local parinfer-rust--mode parinfer-rust-preferred-mode)
Expand All @@ -545,7 +543,6 @@ Checks if MODE is a valid Parinfer mode, and uses
(when parinfer-rust--change-tracker
(track-changes-unregister parinfer-rust--change-tracker)
(setq-local parinfer-rust--change-tracker nil))
(setq-local parinfer-rust-enabled nil)
(remove-hook 'first-change-hook #'parinfer-rust--check-for-issues t)
(parinfer-rust--dim-parens))

Expand Down Expand Up @@ -625,15 +622,14 @@ not available."
:init-value nil
:keymap parinfer-rust-mode-map
(cond
(parinfer-rust-enabled ;; FIXME: Why?
(parinfer-rust-mode
(parinfer-rust-mode-disable))
;; Don't do anything if the buffer is not selected
;; TODO: Come up with a better way to defer and disable loading
;; Defer waits for window selection change and disabled waits for a change event
;; there is also the idea of deferring the running of parinfer vs deferring the loading
((not (eq (current-buffer)
(window-buffer (selected-window))))
(setq-local parinfer-rust-enabled t)
(add-hook 'window-selection-change-functions #'parinfer-rust--defer-loading nil t))
(t
(parinfer-rust-mode-enable))))
Expand Down
2 changes: 1 addition & 1 deletion test/test-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
:lighter " parinfer"
:init-value nil
:keymap parinfer-rust-mode-map
(if parinfer-rust-enabled
(if parinfer-rust-mode
(parinfer-rust-mode-disable)
(progn
(parinfer-rust--check-version parinfer-rust-supported-versions
Expand Down

0 comments on commit 398dc4d

Please sign in to comment.