1

How can I enable auto-save based on filename? I use a naming convention (a prefix to the filename) for my notes and I'd like to enable auto-save for those files.

1

I don't know if there is a "correct" way to make this happen.

What comes to my mind is:

(defvar my-auto-save-regexp "/jdigit")

(defun my-auto-save-mode-fn ()
  (when (string-match my-auto-save-regexp buffer-file-name)
    (auto-save-mode 1)))

(add-hook 'find-file-hook 'my-auto-save-mode-fn)
1
  • it works, thank you. – jdigital Jan 13 '20 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.