> Is it possible to associate one buffer with two files? All I really
> want is to do is have the save functions write the buffer to both
> files. (E.g., I don't care about loading the file, or resolving
> differences if the versions on disk are different.) I thought about
> using after-save-hook, but decided to see if someone had already done
> the work before I worried about infinite loops.
> Thanks,
> Troy Daniels
Here is a small elisp package named carbon-buffer.el which does what
you want.
----- snip - snip -------------------------------------------------
;;;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
(add-hook 'write-file-hooks 'write-carbon-files)
----- snip - snip -------------------------------------------------
--
Vegard Vesterheim : Phone: +47 73593002
SINTEF Drift, IT-avdelingen : Fax: +47 73591700