home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / resync.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  1.7 KB  |  48 lines

  1. ;From UNAUTHENTICATED Mon Jun 11 11:49:49 EDT 1990
  2. ;Article 2929 of gnu.emacs:
  3. ;Path: utkcs2!emory!samsung!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!<UNAUTHENTICATED>+
  4. ;>From: shivers@cs.cmu.edu (Olin Shivers)
  5. ;Newsgroups: gnu.emacs
  6. ;Subject: Re: Emacsdisplay, as opposed to emacsclient
  7. ;Message-ID: <UaPnlYC00htF0wn14m@cs.cmu.edu>
  8. ;Date: 8 Jun 90 05:49:24 GMT
  9. ;Organization: Carnegie Mellon, Pittsburgh, PA
  10. ;Lines: 34
  11. ;
  12. ;fred@cadence.com (Fred Cox) writes:
  13. ;> I work all day in epoch or emacs, then I go home without exiting.
  14. ;> 
  15. ;> Now I log in from home, and want to change a file that is currently
  16. ;> being changed in my emacs at work.  Bummer!
  17. ;> 
  18. ;> What do you people think of the idea of having a program called
  19. ;> something like emacsdisplay that connects to a running emacs or epoch,
  20. ;> and lets you edit all your buffers as though it were a new window?
  21. ;
  22. ;I use instead the following low-tech hack:
  23. (defun resync-files ()
  24.   "Use if you've been editing files elsewhere."
  25.   (interactive)
  26.   (let ((bufs (buffer-list)))
  27.     (while bufs
  28.       (let* ((buf (car bufs))
  29.          (bname (buffer-name buf))
  30.          (fname (buffer-file-name buf)))
  31.     (setq bufs (cdr bufs))
  32.     (cond ((and fname
  33.             (not (verify-visited-file-modtime buf))
  34.             (y-or-n-p (format "Resync %s: %s " bname fname))
  35.             (or (not (buffer-modified-p buf))
  36.             (y-or-n-p (format "Buffer %s modified! Are you sure? "
  37.                       bname))))
  38.            (set-buffer buf)
  39.            (revert-buffer nil t)))))) ; nil=ask if autosave is newer.
  40.   (message "Resync done."))          ; t=no confirmation otherwise.
  41.  
  42. ;When I leave work, I say c-x s to save all my buffers.  Then I can go home
  43. ;and hack away. When I come back to work, I just say M-x resync-files and
  44. ;refresh any stale buffers.
  45. ;    -Olin
  46.  
  47.  
  48.