Emacs automatically saves only for org-mode

I use auto save back to the source file for my org-mode, but I just want it to work for this mode and nothing else. Is it easy to do?

Here are my options in org-mode

;; Org-mode options
(add-hook 'org-mode-hook
          'turn-on-visual-line-mode
          'auto-save-mode)
(add-hook 'org-mode-hook '(lambda()
                (setq auto-save-visited-file-name t)
                (setq auto-save-interval 20)))

Note. For my full configuration see https://github.com/map7/simple_emacs

+5
source share
1 answer

This should provide you with the autosave file name setting in org mode only.

(add-hook 'org-mode-hook 'my-org-mode-autosave-settings)
(defun my-org-mode-autosave-settings ()
  ;; (auto-save-mode 1)   ; this is unnecessary as it is on by default
  (set (make-local-variable 'auto-save-visited-file-name) t)
  (setq auto-save-interval 20))

Note. Your addition 'auto-save-modeto 'org-mode-hookdisable auto save as it is enabled by default (unless you have disabled it globally).

+8
source

All Articles