Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs auto save for org-mode only

I'm using auto save back to the original file for my org-mode but I only want it to work for this mode and nothing else. Is that easy to do?

Here are my org-mode options

;; 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 config please refer to https://github.com/map7/simple_emacs

like image 211
map7 Avatar asked Nov 16 '11 03:11

map7


People also ask

Does Emacs auto save?

By default, Emacs automatically saves your changes to a file intermittently. If anything should happen, you can recover a file with 'M-x recover-file' . Auto-saving can be turned on globally or on a per-buffer basis with 'M-x auto-save-mode' (users of Emacs 26.1 and later may prefer 'M-x auto-save-visited-mode' ).

How do I turn on Org Mode in Emacs?

Emacs does not actually understand you are editing an Org document, yet. To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document.

What does Org mode do?

Org Mode (also: org-mode; /ˈɔːrɡ moʊd/) is a document editing, formatting, and organizing mode, designed for notes, planning, and authoring within the free software text editor Emacs.


1 Answers

This should provide you with the customization of the auto-save file name just in org-mode.

(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 of 'auto-save-mode in the 'org-mode-hook would turn off auto save as it is on by default (unless you've turned it off globally).

like image 94
Trey Jackson Avatar answered Sep 22 '22 00:09

Trey Jackson