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

Disable parinfer-rust-mode on background writes #52

Closed markokocic closed 5 months ago

markokocic commented 3 years ago

Is it possible to disable parinfer-rust-mode when buffer is modified non-interactively?

For example, when calling list-packages it automatically updates custom init file. Every time I get prompt if I want to enable parinfer-mode or not, since the file doesn't conform to parinfer-mode.

Alternative 1: Have a blacklist of files where parinfer-mode will not be disabled, althoug it was requested by mode hook

Alternative 2: Having another option to parinfer-rust-check-before-enable that will disable parinfer-mode without prompt if indentation check fails.

choffee commented 3 years ago

I've tried setting "eval (parinfer-rust-toggle-disable)" the the file local variables but that's not fixed it. I'm fairly sure this is happening when custom config file is updated but it does not say which buffer it's trying to fix.

justinbarclay commented 3 years ago

Hey, thanks for the feedback and feature request.

Unfortunately, this is not something I'm going to add right now.

However, if this is something you want, you could add a hook onto parinfer-rust-mode that checks for what file (or folder) it is running in and disables itself. Note: I only tested this very superficially so it might not work as intended, but it should be enough to get something working.

  (add-hook 'parinfer-rust-mode-hook (lambda ()
                                       (when (or (string-match-p "\/.emacs.d\/" buffer-file-name)
                                                 (seq-contains-p '("/full/file/name"
                                                                   "/user/justin/.emacs.d/init.el"
                                                                   "/some/other/file")
                                                                 buffer-file-name))
                                         (message "Disabling parinfer-rust-mode")
                                         ;; Disables `parinfer-rust-mode'
                                         (parinfer-rust-mode-disable))))
                                         ;; Temporarily disables `parinfer-rust-mode' so you can can
                                         ;; use a `parinfer-rust-mode-toggle' to enable it with a
                                         ;; keychord. However, if one uses this approach they
                                         ;; will have to also turn off the "Check Before Enable"
                                         ;; feature as that uses parinfer-rust-toggle-disable
                                         ;; internally
                                         ;;
                                         ;; (setq-local parinfer-rust-check-before-enable nil)
                                         ;; (parinfer-rust-toggle-disable))))
justinbarclay commented 5 months ago

This is just a scant 3 years late but #79 addresses this. Where parinfer-rust-mode will defer being turned on until it becomes the active buffer for the first time. After that, all bets are off though :)