spencer@ttidca.TTI.COM (David Spencer) (08/05/87)
Is there any way to get emacs to do an auto save every "n" seconds? I use version 18.36.1. -- ----------------------------------------------------------------------- spencer@ttidca ...!{philabs, trwrb, csun, mtxinu}!ttidca!spencer
kyle@xanth.UUCP (Kyle Jones) (08/07/87)
> Is there any way to get emacs to do an auto save every "n" seconds? > I use version 18.36.1. I remember this was a nice feature built into the mode line clock of Gosling's Emacs. Here are the diffs for GNU Emacs' (version 18.46) time.el to add this feature. The time between auto-save's is controlled by the variable auto-save-time-interval. Setting this variable to nil turns the feature off (this is the default). Since this is based on the mode line clock, the timer won't be started until you invoke (display-time). So put (display-time) in your .emacs file if it's not there already. Enjoy, kyle jones <kyle@odu.edu> old dominion university, norfolk, va --------------------------------------------------------------------------- *** time.el.old Fri Aug 7 04:14:01 1987 --- time.el Fri Aug 7 04:41:10 1987 *************** *** 26,31 **** --- 26,37 ---- (defvar display-time-string nil) + (defvar auto-save-time-interval nil + "*Number of seconds between auto-save'ing buffers that need it.") + + (defvar auto-save-timer 0 + "Number of seconds since auto-save-timer last expired") + (defun display-time () "Display current time and load level in mode line of each buffer. Updates automatically every minute. *************** *** 42,47 **** --- 48,58 ---- (or (memq 'display-time-string global-mode-string) (setq global-mode-string (append global-mode-string '(display-time-string)))) + ;; + ;; (auto-save-timer) is called the first time before any time has + ;; elapsed, so we do this in anticipation of that. + ;; + (setq auto-save-timer (- display-time-interval)) (setq display-time-string "time and load") (setq display-time-process (start-process "display-time" nil *************** *** 60,65 **** --- 71,81 ---- (sit-for 0)) (defun display-time-filter (proc string) + ;; + ;; First do the necessary auto-save's + ;; + (if (and (boundp 'auto-save-time-interval) (numberp auto-save-time-interval)) + (auto-save-timer)) ;; Desired data can't need more than the last 30 chars, ;; so save time by flushing the rest. ;; This way, if we have many different times all collected at once, *************** *** 82,84 **** --- 98,107 ---- (set-buffer-modified-p (buffer-modified-p)) ;; Do redisplay right now, if no input pending. (sit-for 0)) + + (defun auto-save-timer () + (setq auto-save-timer (+ auto-save-timer display-time-interval)) + (cond + ((>= auto-save-timer auto-save-time-interval) + (do-auto-save) + (setq auto-save-timer (- auto-save-timer auto-save-time-interval)))))