Function: tramp-rename-these-files

tramp-rename-these-files is an autoloaded, interactive and byte-compiled function defined in tramp-cmds.el.gz.

Signature

(tramp-rename-these-files TARGET)

Documentation

Replace visiting file names to TARGET.

The current buffer must be related to a remote connection. In all buffers, which are visiting a file with the same directory name, the buffer file name is changed.

Interactively, TARGET is selected from tramp-default-rename-alist without confirmation if the prefix argument is non-nil.

For details, see tramp-rename-files.

Probably introduced at or before Emacs version 27.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-cmds.el.gz
;;;###tramp-autoload
(defun tramp-rename-these-files (target)
  "Replace visiting file names to TARGET.
The current buffer must be related to a remote connection.  In
all buffers, which are visiting a file with the same directory
name, the buffer file name is changed.

Interactively, TARGET is selected from `tramp-default-rename-alist'
without confirmation if the prefix argument is non-nil.

For details, see `tramp-rename-files'."
  ;; (declare (completion tramp-command-completion-p))
  (interactive
   (let ((source default-directory)
	 target
	 ;; Completion packages do their voodoo in `completing-read'
	 ;; and `read-file-name', which is often incompatible with
	 ;; Tramp.  Ignore them.
	 (completing-read-function #'completing-read-default)
	 (read-file-name-function #'read-file-name-default))
     (if (not (tramp-tramp-file-p source))
	 (tramp-user-error
	  nil
	  (substitute-command-keys
	   (concat "Current buffer is not remote.  "
		   "Consider `\\[tramp-rename-files]' instead")))
       (setq target
	     (when (null current-prefix-arg)
	       ;; The source remote connection shall not trigger any action.
	       ;; FIXME: Better error prompt when trying to access source host.
	       (let* ((default (or (tramp-default-rename-file source) source))
		      (dir (tramp-rename-read-file-name-dir default))
		      (init (tramp-rename-read-file-name-init default))
		      (tramp-ignored-file-name-regexp
		       (tramp-compat-rx (literal (file-remote-p source)))))
		 (read-file-name-default
		  (format "Change Tramp connection `%s': " source)
		  dir default 'confirm init #'file-directory-p)))))
     (list target)))

  (tramp-rename-files default-directory target))