2011-11-16 113 views
5

我使用自動保存回原始文件爲我的組織模式,但我只希望它適用於此模式,沒有別的。這很容易做到嗎?emacs自動保存爲組織模式

這裏是我的組織模式選項

;; 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))) 

注:我的全配置請參考https://github.com/map7/simple_emacs

回答

8

這應該爲您提供自動保存的文件名的org-的定製只是模式。

(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)) 

注:您在'org-mode-hook添加'auto-save-mode會變成關閉自動保存,因爲它是在默認情況下(除非你把它關閉全球)。

+0

這對我使用Ubuntu 14.10提供的org-mode 8.2.7和Emacs軟件包無效24.3.1 – David

+0

解決方法:爲此,必須運行'(自動保存模式t)'_after_製作本地變量'auto-save-visited-file-name'作爲更改在現有緩衝區中不生效而不自動保存被重新啓用。 – David