diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 9f1a1d02867..5bc28580cf1 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -3380,13 +3380,23 @@ of the secretfile is now owned by the user logged in from When @code{backup-directory-alist} is @code{nil} (the default), such problems do not occur. -To ``turn off'' the backup feature for remote files and stop -@value{tramp} from saving to the backup directory, use this: +@vindex make-backup-files +In case you do not want to use backup files for remote files, use +connection-local variable @code{make-backup-files} +@ifinfo +(@pxref{Connection Variables, , , emacs}) +@end ifinfo +like this: @lisp @group -(add-to-list 'backup-directory-alist - (cons tramp-file-name-regexp nil)) +(connection-local-set-profile-variables + 'no-remote-backup-files '((make-backup-files . nil))) +@end group + +@group +(connection-local-set-profiles + '(:application tramp) 'no-remote-backup-files) @end group @end lisp @@ -3396,13 +3406,13 @@ Disabling backups can be targeted to just the @option{su} and @lisp @group -(setq backup-enable-predicate - (lambda (name) - (and (normal-backup-enable-predicate name) - (not - (let ((method (file-remote-p name 'method))) - (when (stringp method) - (member method '("su" "sudo")))))))) +(connection-local-set-profiles + '(:application tramp :protocol "su") 'no-remote-backup-files) +@end group + +@group +(connection-local-set-profiles + '(:application tramp :protocol "sudo") 'no-remote-backup-files) @end group @end lisp diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi index 8b5e429d0cd..07f017403f9 100644 --- a/doc/misc/trampver.texi +++ b/doc/misc/trampver.texi @@ -7,7 +7,7 @@ @c In the Tramp GIT, the version number and the bug report address @c are auto-frobbed from configure.ac. -@set trampver 2.8.2.31.1 +@set trampver 2.8.3-pre @set trampurl https://www.gnu.org/software/tramp/ @set tramp-bug-report-address tramp-devel@@gnu.org @set emacsver 28.1 diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index e6ab0630d7a..af661770371 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -678,33 +678,35 @@ Run BODY." "Convert FILENAME into a multi-hop file name with \"sudo\". An alternative method could be chosen with `tramp-file-name-with-method'." (setq filename (expand-file-name filename)) - (let ((default-method (tramp-get-file-name-with-method))) - (if (tramp-tramp-file-p filename) - (with-parsed-tramp-file-name filename nil - (cond - ;; Remote file with proper method. - ((string-equal method default-method) - filename) - ;; Remote file on the local host. - ((and - (stringp tramp-local-host-regexp) (stringp host) - (string-match-p tramp-local-host-regexp host)) - (tramp-make-tramp-file-name - (make-tramp-file-name - :method default-method :localname localname))) - ;; Remote file with multi-hop capable method. - ((tramp-multi-hop-p v) - (tramp-make-tramp-file-name - (make-tramp-file-name - :method (tramp-find-method default-method nil host) - :user (tramp-find-user default-method nil host) - :host (tramp-find-host default-method nil host) - :localname localname :hop (tramp-make-tramp-hop-name v)))) - ;; Other remote file. - (t (tramp-user-error v "Multi-hop with `%s' not applicable" method)))) - ;; Local file. - (tramp-make-tramp-file-name - (make-tramp-file-name :method default-method :localname filename))))) + (expand-file-name + (let ((default-method (tramp-get-file-name-with-method))) + (if (tramp-tramp-file-p filename) + (with-parsed-tramp-file-name filename nil + (cond + ;; Remote file with proper method. + ((string-equal method default-method) + filename) + ;; Remote file on the local host. + ((and + (stringp tramp-local-host-regexp) (stringp host) + (string-match-p tramp-local-host-regexp host)) + (tramp-make-tramp-file-name + (make-tramp-file-name + :method default-method :localname localname))) + ;; Remote file with multi-hop capable method. + ((tramp-multi-hop-p v) + (tramp-make-tramp-file-name + (make-tramp-file-name + :method (tramp-find-method default-method nil host) + :user (tramp-find-user default-method nil host) + :host (tramp-find-host default-method nil host) + :localname localname :hop (tramp-make-tramp-hop-name v)))) + ;; Other remote file. + (t + (tramp-user-error v "Multi-hop with `%s' not applicable" method)))) + ;; Local file. + (tramp-make-tramp-file-name + (make-tramp-file-name :method default-method :localname filename)))))) ;; FIXME: We would like to rename this for Emacs 31.1 to a name that ;; does not encode the default method. It is intended as a generic diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index cd6cfdfe949..5956e56e6f1 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -23,7 +23,7 @@ ;;; Commentary: -;; Tramp's main Emacs version for development is Emacs 30. This +;; Tramp's main Emacs version for development is Emacs 31. This ;; package provides compatibility functions for Emacs 28, Emacs 29 and ;; Emacs 30. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 792887da772..ff2da0b208d 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2259,10 +2259,13 @@ without a visible progress reporter." (or tramp-inhibit-progress-reporter tm))) ,@body) (setq cookie "done")) - ;; Stop progress reporter. + ;; Stop progress reporter. We suppress the message in the + ;; message buffer and echo area; proper handling is performed + ;; by `tramp-message'. (when (and tm pr) (cancel-timer tm) - (let (message-log-max) + (let ((inhibit-message t) + message-log-max) (progress-reporter-done pr))) (tramp-message ,vec ,level "%s...%s" ,message cookie))))) @@ -2575,7 +2578,9 @@ Must be handled by the callers." ((bufferp (nth 0 args)) (get-buffer (nth 0 args))) ((stringp (nth 0 args)) ;; Process or buffer name. - (or (get-process (nth 0 args)) (get-buffer (nth 0 args))))))) + (or (and-let* ((proc (get-process (nth 0 args)))) + (process-buffer proc)) + (get-buffer (nth 0 args))))))) (tramp-get-default-directory buf)) "")) @@ -4792,40 +4797,42 @@ existing) are returned." (defun tramp-handle-find-backup-file-name (filename) "Like `find-backup-file-name' for Tramp files." - (with-parsed-tramp-file-name filename nil - (let ((backup-directory-alist - (if tramp-backup-directory-alist - (mapcar - (lambda (x) - (cons - (car x) - (if (and (stringp (cdr x)) - (file-name-absolute-p (cdr x)) - (not (tramp-tramp-file-p (cdr x)))) - (tramp-make-tramp-file-name v (cdr x)) - (cdr x)))) - tramp-backup-directory-alist) - backup-directory-alist)) - result) - (prog1 ;; Run plain `find-backup-file-name'. - (setq result - (tramp-run-real-handler - #'find-backup-file-name (list filename))) - ;; Protect against security hole. - (when (and (not tramp-allow-unsafe-temporary-files) - (not backup-inhibited) - (file-in-directory-p (car result) temporary-file-directory) - (= (or (file-attribute-user-id - (file-attributes filename 'integer)) - tramp-unknown-id-integer) - tramp-root-id-integer) - (not (with-tramp-connection-property - (tramp-get-process v) "unsafe-temporary-file" - (yes-or-no-p - (concat - "Backup file on local temporary directory, " - "do you want to continue?"))))) - (tramp-error v 'file-error "Unsafe backup file name")))))) + (when-let* ((default-directory (file-name-directory filename)) + ((tramp-compat-connection-local-value make-backup-files))) + (with-parsed-tramp-file-name filename nil + (let ((backup-directory-alist + (if tramp-backup-directory-alist + (mapcar + (lambda (x) + (cons + (car x) + (if (and (stringp (cdr x)) + (file-name-absolute-p (cdr x)) + (not (tramp-tramp-file-p (cdr x)))) + (tramp-make-tramp-file-name v (cdr x)) + (cdr x)))) + tramp-backup-directory-alist) + backup-directory-alist)) + result) + (prog1 ;; Run plain `find-backup-file-name'. + (setq result + (tramp-run-real-handler + #'find-backup-file-name (list filename))) + ;; Protect against security hole. + (when (and (not tramp-allow-unsafe-temporary-files) + (not backup-inhibited) + (file-in-directory-p (car result) temporary-file-directory) + (= (or (file-attribute-user-id + (file-attributes filename 'integer)) + tramp-unknown-id-integer) + tramp-root-id-integer) + (not (with-tramp-connection-property + (tramp-get-process v) "unsafe-temporary-file" + (yes-or-no-p + (concat + "Backup file on local temporary directory, " + "do you want to continue?"))))) + (tramp-error v 'file-error "Unsafe backup file name"))))))) (defun tramp-handle-insert-directory (filename switches &optional wildcard full-directory-p) diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el index 1366147cec4..d65cffbabec 100644 --- a/lisp/net/trampver.el +++ b/lisp/net/trampver.el @@ -7,7 +7,7 @@ ;; Maintainer: Michael Albinus ;; Keywords: comm, processes ;; Package: tramp -;; Version: 2.8.2.31.1 +;; Version: 2.8.3-pre ;; Package-Requires: ((emacs "28.1")) ;; Package-Type: multi ;; URL: https://www.gnu.org/software/tramp/ @@ -40,7 +40,7 @@ ;; ./configure" to change them. ;;;###tramp-autoload -(defconst tramp-version "2.8.2.31.1" +(defconst tramp-version "2.8.3-pre" "This version of Tramp.") ;;;###tramp-autoload @@ -76,7 +76,7 @@ ;; Check for Emacs version. (let ((x (if (not (string-version-lessp emacs-version "28.1")) "ok" - (format "Tramp 2.8.2.31.1 is not fit for %s" + (format "Tramp 2.8.3-pre is not fit for %s" (replace-regexp-in-string "\n" "" (emacs-version)))))) (unless (string-equal "ok" x) (error "%s" x))) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index d9571174439..c2c1b0a9241 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -7361,7 +7361,25 @@ INPUT, if non-nil, is a string sent to the process." ;; Cleanup. (ignore-errors (delete-file tmp-name1)) - (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password))))) + (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)) + + ;; Check connection-local `make-backup-files'. + (let ((clpa connection-local-profile-alist) + (clca connection-local-criteria-alist)) + (connection-local-set-profile-variables + 'no-remote-backup-files '((make-backup-files . nil))) + (connection-local-set-profiles + `(:application tramp + :protocol ,(file-remote-p default-directory 'method) + :user ,(file-remote-p default-directory 'user) + :machine ,(file-remote-p default-directory 'host)) + 'no-remote-backup-files) + + (should-not (find-backup-file-name tmp-name1)) + + (custom-set-variables + `(connection-local-profile-alist ',clpa now) + `(connection-local-criteria-alist ',clca now)))))) (ert-deftest tramp-test39-make-lock-file-name () "Check `make-lock-file-name', `lock-file', `unlock-file' and `file-locked-p'."