[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0fd206b: Add `completion-predicate' to some Tramp commands
From: |
Michael Albinus |
Subject: |
master 0fd206b: Add `completion-predicate' to some Tramp commands |
Date: |
Sun, 28 Feb 2021 12:23:38 -0500 (EST) |
branch: master
commit 0fd206badc761df0a2eb18cd5d9c7506c3bd0d2a
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
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.
---
lisp/net/tramp-cmds.el | 13 +++++++++++++
lisp/net/tramp.el | 8 ++++++++
2 files changed, 21 insertions(+)
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index f0bbe31..2aacf26 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 e99e439..14d5f8c 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0fd206b: Add `completion-predicate' to some Tramp commands,
Michael Albinus <=