[comp.emacs] Writing a file through a filter

escott%deis.UCI.EDU@ROME.UCI.EDU (Scott Menter) (05/02/87)

(GNU Emacs 18.36.2 of Tue Feb 24 1987 on deis.uci.edu (berkeley-unix))

Hello.  I have a generic question:  what do you GNU Emacs Lisp
programmers think is the best way to solve this problem:

I would like certain buffers, when saved to a file, to have the output
passed through a filter first.  The filter might be, for example,
"sed" or "tr" or "rot13" (actually, in the case of my project, it's
"crypt").  I'd like auto-saves to go through the filter too.  Here's
the various ways I've thought of to do this:

(1)  Set up a function to see if a particular buffer should be
filtered before writing or auto-saving, and if so, take care of it.
The set write-file-hooks and auto-fill-hook to that function.

(2) Basically the same thing, only use (make-variable-buffer-local) so
that most files won't have any write-file-hooks to worry about,
thereby possibly speeding up saves and auto-saves in the general case.

(3) Don't associate the buffer with a file at all;  write special
functions to write and auto-save those buffers;  bind these functions
to the usual "write" keys.

Solution (1) seems like the most elegant one, to me, but I'm concerned
that the general case write, which needs no filtering, will suffer as
a result.  Solution (2) fixes that, but I wonder if it isn't bad
practice to make those variables buffer local.  Solution (3) fixes the
problems of the first two but is more work to implement, and requires
more complicated code.  Seeing as this is my first really serious Lisp
work of any kind, I'd rather avoid complications.

Any thoughts?  Reply to me, please, and if there's any interest at all
I'll summarize.  Thanks !!


+-------------------------------------------------------------------------+
 Scott Menter  UCI ICS Computing Support Group   Univ. of Calif. at Irvine
                     (714) 856 7552              Irvine, California  92717

 Internet:  escott@ics.uci.edu             UUCP:  ...!ucbvax!ucivax!escott
 Bitnet:    escott@uci               CSNet: escott%ics.uci.edu@csnet-relay
 Internet (with Name Server):  escott@deis.uci.edu
+-------------------------------------------------------------------------+