home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mutt / saveall.mut < prev    next >
Text File  |  1988-04-04  |  1KB  |  55 lines

  1.   ;; saveall.mut : various ways of saving buffers
  2.  
  3.     ; save-all: save all modified buffers that can be saved
  4.     ; ask-save-and-exit: save modified buffers user wants to save
  5.     ;   and exit.
  6.     ; If the key-pressed-hook is installed, a save-all is done
  7.     ;   every n key presses.
  8.     ; All these ignore buffers that are not attached to files.
  9.     ; C Durland
  10.  
  11. (include spoint.mut)
  12.  
  13. (defun
  14.   save-all
  15.   {
  16.     (int j)
  17.     
  18.     (for (j 0) (< j (buffers)) (+= j 1)
  19.       (if (and (buffer-modified j)(!= (file-name j) ""))
  20.       {
  21.     (save-point)
  22.         (switch-to-buffer (buffer-name j))(save-buffer)
  23.     (restore-point)
  24.       })
  25.     )
  26.   }
  27.   ask-save-and-exit
  28.   {
  29.     (int j n)
  30.  
  31.     (n (buffers))(j 0)
  32.     (while (< j n)
  33.     {
  34.       (if (and (buffer-modified j)(!= (file-name j)""))
  35.         (if (yesno "Save "(buffer-name j) " [" (file-name j)"]") ()
  36.     (buffer-modified j FALSE))
  37.       )
  38.       (+= j 1)
  39.     })
  40.     (save-all)
  41.     (exit)
  42.   }
  43. )
  44.  
  45. (const threshold 300)    ; save after this many key presses
  46.  
  47. (int keys-pressed)    ; the number of keys pressed since the last save
  48.  
  49. (defun
  50.   key-pressed-hook
  51.   {
  52.     (if (> (+= keys-pressed 1) threshold) { (save-all)(keys-pressed 0) } )
  53.   }
  54. )
  55.