Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bypass save hooks #41

Open
dustinfarris opened this issue Jul 25, 2022 · 1 comment
Open

bypass save hooks #41

dustinfarris opened this issue Jul 25, 2022 · 1 comment

Comments

@dustinfarris
Copy link

would it be possible for super-save to not trigger save hooks — reserving those for when a file is manually saved?

for my specific use-case, i'm using org-roam which binds:

(add-hook 'after-save-hook #'org-roam-db-autosync--try-update-on-save-h nil t)

the db autosync is cpu intensive so there's a periodic bit of a lag when i have super-save-auto-save-when-idle turned on (which I would like to keep).

is there a way i can adjust the org-roam hook and/or configure super-save to make the two mutually exclusive?

@peterhoeg
Copy link

I work around it by conditionally disabling save on idle if certain modes are enabled. Specifically those involved with formatting-on-save.

(use-package super-save :defer t
  :init
  (doom-load-packages-incrementally '(super-save))

  :config
  (defvar +super-save-disabled-major-modes '()
    "Major modes in which super-save on idle is disabled.")

  (defvar +super-save-disabled-minor-modes '(apheleia-mode format-all-mode)
    "Modes when enabled cause super-save to be disabled.")

  (defvar +super-save-auto-disable-idle 't
    "Automatically disable idle based on major and minor modes.")

  (defun +super-save-auto-disable-idle ()
    "Automatically disable based on major and minor modes."
    (not (or (member major-mode +super-save-disabled-major-modes)
             ;; bound-and-true-p takes a variable, not a symbol
             (-some (lambda (elm) (and (boundp elm) elm))
                    +super-save-disabled-minor-modes))))

  (when +super-save-auto-disable-idle
    (add-to-list 'super-save-predicates #'+super-save-auto-disable-idle))

  (setq auto-save-default nil
        super-save-auto-save-when-idle t
        super-save-idle-duration 30
        super-save-remote-files nil
        super-save-exclude '(".gpg"))
  (super-save-mode +1))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants