
(defadvice save-buffers-kill-emacs (before d-exit-stub activate)
  (interactive "P")
  (when (not noninteractive)
    (save-some-buffers 'NO-QUESTIONS)
    ;;(shell-command "cd ~; make tar")
    ;;(if os-type--linux-p (copy-to-archive))
    ;;(if (and os-type--linux-p (y-or-n-p "Email .emacs? "))
    ;;    (email-file "~/.emacs")
    ;;  )
    )
  )

(defun email-file (filename)
  (interactive "fEnter file: ")
  (save-some-buffers t)
  (message "Emailing file %s" filename)
  (save-window-excursion
    (shell-command (concat "mail davin.pearson@gmail.com -s "
                           "\"VSENT " (upcase (file-name-nondirectory filename)) "\""
                           " <"
                           filename)))
  (sit-for 2)
  )

(defun copy-to-archive ()
  (save-window-excursion
   (save-some-buffers 'NO-QUESTIONS)
   ;;(make-directory "~/archive" t)
   ;;(copy-file "~/.emacs"                "~/archive/.emacs"      'OK-IF-ALREADY-EXISTS)
   ;;(copy-file "~/.bashrc"               "~/archive/.bashrc"     'OK-IF-ALREADY-EXISTS)
   ;;(copy-file "~/.xmodmaprc"            "~/archive/.xmodmaprc"  'OK-IF-ALREADY-EXISTS)
   ;;(copy-file "~/caps"                  "~/archive/caps"        'OK-IF-ALREADY-EXISTS)
   ;;(copy-file "~/workspace/Makefile"    "~/archive/Makefile-workspace.mk"    'OK-IF-ALREADY-EXISTS)
   ;;(copy-file "~/tmp-project/Makefile"  "~/archive/Makefile-tmp-project.mk" 'OK-IF-ALREADY-EXISTS)
   ;;(let ((default-directory "~/archive/"))
   ;;  (shell-command "make tar"))
   ;;(safe-require 'cull-same-dates)
   ;;(cull-same-dates "~/bak")
   )
 )

(provide 'd-exit)
;;; d-exit.el ends here
