home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky gnu.emacs.help:3928 comp.emacs:2996
- Newsgroups: gnu.emacs.help,comp.emacs
- Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!CSD-Newshost!witchel
- From: witchel@Xenon.Stanford.EDU (Emmett Jethro Witchel)
- Subject: Re: Can 1 buffer visit >1 file? - Solution
- In-Reply-To: jym@mica.berkeley.edu's message of 31 Aug 92 09:24:09
- Message-ID: <WITCHEL.92Sep1112621@Xenon.Stanford.EDU>
- Followup-To: gnu.emacs.help,comp.emacs
- Sender: news@CSD-NewsHost.Stanford.EDU
- Organization: Computer Science Department, Stanford University.
- References: <WITCHEL.92Aug26162918@Xenon.Stanford.EDU>
- <JYM.92Aug31092409@remarque.berkeley.edu>
- Date: 1 Sep 92 11:26:21
- Lines: 58
-
-
- I thank all repsonses I got. Everyone mentioned write-file-hooks,
- but the most complete solution follows.
-
- From Vegard@protek.unit.no
-
- You wrote:
- > Is is possible for 1 buffer to be visiting more than one file?
-
- Here is what I picked up from the net some time ago,
- I guess it is what you are looking for.
-
- ------------------ snip ---- snip ------------------
-
- ;;;Authorizing-Users: Ray Nickson <Ray.Nickson@comp.vuw.ac.nz>
-
- ;;;To use, just M-x carbon-buffer-to-file to the remote file name when
- ;;;you find the local one (or vice versa).
- ;;;(I had to chamge it for distribution; hope it still works)
-
- ;;;You can also put the call in the file's Local Variables section with
- ;;;an eval, or just set buffer-carbon-file-names there.
-
- (defvar buffer-carbon-file-names nil
- "List of files to carbon-copy this buffer into.")
- (make-variable-buffer-local 'buffer-carbon-file-names)
-
- (defun carbon-buffer-to-file (file)
- "Make FILE be a carbon-copy of the file visited by this buffer.
- Any time you save the buffer, changes will go both to the buffer's own file
- and to FILE. Yes, you can carbon to many files at once; the list of files
- being carbonned to is in the variable buffer-carbon-file-names."
- (interactive "FCarbon to file: ")
- (setq buffer-carbon-file-names (cons file buffer-carbon-file-names)))
-
- (defun write-carbon-files ()
- "A write-file-hook. See \\[carbon-buffer-to-file]."
- (save-restriction
- (widen)
- (mapcar
- (function (lambda (file)
- (write-region (point-min) (point-max) file)))
- buffer-carbon-file-names))
- nil) ; hook must return nil
-
- (setq write-file-hooks (cons 'write-carbon-files write-file-hooks))
-
-
- ;;; (setq write-file-hooks 'nil)
-
-
- ;;; Local Variables: ***
- ;;; eval: (carbon-buffer-to-file "/vv@vtsg01:Emacs/carbon-copy.el") ***
- ;;; End: ***
- ------------------ snip ---- snip ---------------------
- Vegard Vesterheim : Phone: +47 7 593885
- Production Engineering, SINTEF : Fax: +47 7 597043
- N-7034 Trondheim, NORWAY : Email: vegard@protek.unit.no
-