From: Michael Albinus Date: Sun, 28 Feb 2021 17:23:27 +0000 (+0100) Subject: Add `completion-predicate' to some Tramp commands X-Git-Tag: emacs-28.0.90~3497 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0fd206badc761df0a2eb18cd5d9c7506c3bd0d2a;p=emacs.git Add `completion-predicate' to some Tramp commands * lisp/net/tramp-cmds.el (tramp-cleanup-this-connection) (tramp-rename-these-files): Add property `completion-predicate'. * lisp/net/tramp.el (tramp-command-completion-p): New defun. --- diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index f0bbe31cea0..2aacf266f2b 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -144,11 +144,18 @@ When called interactively, a Tramp connection has to be selected." ;;;###tramp-autoload (defun tramp-cleanup-this-connection () "Flush all connection related objects of the current buffer's connection." + ;; (declare (completion tramp-command-completion-p))) (interactive) (and (tramp-tramp-file-p default-directory) (tramp-cleanup-connection (tramp-dissect-file-name default-directory 'noexpand)))) +;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form. +;;;###tramp-autoload +(function-put + #'tramp-cleanup-this-connection 'completion-predicate + #'tramp-command-completion-p) + ;;;###tramp-autoload (defvar tramp-cleanup-all-connections-hook nil "List of functions to be called after all Tramp connections are cleaned up.") @@ -431,6 +438,7 @@ 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 @@ -461,6 +469,11 @@ For details, see `tramp-rename-files'." (tramp-rename-files default-directory target)) +;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form. +;;;###tramp-autoload +(function-put + #'tramp-rename-these-files 'completion-predicate #'tramp-command-completion-p) + ;; Tramp version is useful in a number of situations. ;;;###tramp-autoload diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index e99e43938f2..14d5f8c3b6b 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2591,6 +2591,14 @@ Add operations defined in `HANDLER-alist' to `tramp-file-name-handler'." ;;; File name handler functions for completion mode: +;; This function takes action since Emacs 28.1, when +;; `read-extended-command-predicate' is set to +;; `command-completion-default-include-p'. +(defun tramp-command-completion-p (_symbol buffer) + "A predicate for Tramp interactive commands. +They are completed by \"M-x TAB\" only if the current buffer is remote." + (with-current-buffer buffer (tramp-tramp-file-p default-directory))) + (defun tramp-connectable-p (vec-or-filename) "Check, whether it is possible to connect the remote host w/o side-effects. This is true, if either the remote host is already connected, or if we are