[EMAIL PROTECTED] (Kai Großjohann) writes:
> On 30 Jul 2001, Joe Wells wrote:
>
> > I visit a file in an unwritable remote directory. I modify the
> > buffer. I try to save my changes. The operation fails. The only
> > error message is "tramp_exit_status 2" in the "*tramp/METHOD
> > HOST*" buffer.
> >
> > Turning on tramp-debug-buffer reveals that what failed was
> > attempting to copy the file to a backup file name.
> >
> > This works fine locally and via ange-ftp, so I think it should
> > work in TRAMP.
>
> I agree. Hm. I need to find out a way to have Emacs proceed even
> if auto-save from within Tramp files.
>
> As a workaround, you can set tramp-auto-save-directory (which will
> do all auto-saves locally). Oh, wait, you're talking about backups.
> Hm.
>
> Maybe setting backup-by-copying won't work, either: that might allow
> you to rename the file but not to save the buffer. Hm. Or does it
> work? Could you try that for me?
I have a "fix" (patch included below) which works for just this case.
My "fix" highlights a larger issue which may require changes
throughout TRAMP.
The problem is that the signals raised in exceptional circumstances by
the TRAMP replacement functions should be as close as possible to the
signals raised by the Emacs built-ins.
In this case, when TRAMP's copy-file operation fails due to file
permissions, it should raise a signal whose name is the symbol
`file-error' rather than the symbol `error', because that is what the
built-in copy-file does and the backup-buffer function in files.el
depends on this. To do this one must use the `signal' function rather
than the `error' function (which is just a special case combination of
`signal', `format', and `list').
I duplicated and edited the tramp-barf-unless-okay function to make
the new tramp-file-error-unless-okay function, which I used in the
appropriate place. I would have preferred to add an optional
parameter to tramp-barf-unless-okay, but it already had an &rest
parameter, making that impossible without changing every use of it.
That may be the correct general solution, but that is not up to me to
decide.
The fix is still a bit gross, because the new
tramp-file-error-unless-okay does (pop-to-buffer (current-buffer))
just like tramp-barf-unless-okay, which is something that should be
done only if the signal is not caught. This means that a buffer pops
up even during normal, correct operation. I don't know what the
correct solution is to this except maybe abandoning the idea of having
a buffer pop up as part of an error message.
I hope this helps.
--
Joe
----------------------------------------------------------------------
--- tramp.el-dist Mon Jul 16 10:59:12 2001
+++ tramp.el Mon Jul 30 20:17:48 2001
@@ -1910,7 +1910,7 @@
"Unknown operation `%s', must be `copy' or `rename'"
op)))))
(save-excursion
- (tramp-barf-unless-okay
+ (tramp-file-error-unless-okay
multi-method method user host
(format "%s %s %s"
cmd
@@ -3907,6 +3907,16 @@
multi-method method user host command subshell))
(pop-to-buffer (current-buffer))
(apply 'error fmt args)))
+
+(defun tramp-file-error-unless-okay (multi-method method user host command subshell
+ fmt &rest args)
+ "Run COMMAND, check exit status, signal file-error if exit status not okay.
+Similar to `tramp-send-command-and-check' but accepts two more arguments
+FMT and ARGS which are used to make a message to pass to `signal'."
+ (unless (zerop (tramp-send-command-and-check
+ multi-method method user host command subshell))
+ (pop-to-buffer (current-buffer))
+ (signal 'file-error (format fmt args))))
(defun tramp-send-region (multi-method method user host start end)
"Send the region from START to END to remote command