At present rcp.el attempts to manage auto-saving with code like the
following: 

        ;; Is this the right way to go about auto-saving?
        (when auto-save-default
          (auto-save-mode 1)
          (when rcp-auto-save-directory
            (setq buffer-auto-save-file-name
                  (rcp-make-auto-save-name filename)))))

It essentially replaces the value of buffer-auto-save-file-name set by
auto-save-mode by a new value referring to the local directory, at the
time the buffer is being initialised.  But I don't think this is good
enough.  For one thing, auto-saving can be switched on and off during
the buffer's life; and this is even sometimes done automatically, for
example if the buffer becomes significantly shorter.  Switching
auto-saving off is done by setting buffer-auto-save-file-name to nil,
and switching it on again is done by recomputing its value.  So the
special value computed by rcp-make-auto-save-name would not survive.
Indeed, it might not even survive later stages of the buffer's
initialisation.

I think we have to attack make-auto-save-file-name itself.  I've found
the following to work (but if you think I ought to be doing clever
things with eval-when-compile, I'd be grateful if you'd explain to me).

(or (fboundp 'real-make-auto-save-file-name)
    (fset 'real-make-auto-save-file-name 
          (symbol-function 'make-auto-save-file-name)))

(defun make-auto-save-file-name ()
  "Return file name to use for auto-saves of current buffer.
If this is an rcp file, uses `rcp-auto-save-directory' if non-nil.
Does not consider `auto-save-visited-file-name' as that variable is checked
before calling this function.  You can redefine this for customization.
See also `auto-save-file-name-p'."
  (if (rcp-rcp-file-p buffer-file-name)
      (rcp-make-auto-save-name buffer-file-name)
    (real-make-auto-save-file-name)))

Having made this change, most of the other explicit stuff about
auto-saving in rcp.el can be deleted.

Best wishes,

joe stoy

(PS A version of rcp.el incorporating this change, as well as others to
allow the use of ssh/scp from NT systems, can be found in
ftp://ftp.comlab.ox.ac.uk/tmp/Joe.Stoy/ .  jes)




Reply via email to