;; This function takes action since Emacs 28.1, when
;; `read-extended-command-predicate' is set to
;; `command-completion-default-include-p'.
-(defun tramp-crypt-enabled-p (_symbol _buffer)
+(defun tramp-crypt-command-completion-p (symbol _buffer)
"A predicate for Tramp interactive commands.
They are completed by \"M-x TAB\" only when encryption support is enabled."
- tramp-crypt-enabled)
+ (and tramp-crypt-enabled
+ ;; `tramp-crypt-remove-directory' needs to be completed only in
+ ;; case we have already crypted directories.
+ (or (not (eq symbol #'tramp-crypt-remove-directory))
+ tramp-crypt-directories)))
;;;###tramp-autoload
(defconst tramp-crypt-encfs-config ".encfs6.xml"
(setq tramp-crypt-directories (cons name tramp-crypt-directories)))
(tramp-register-file-name-handlers))
-;; `tramp-crypt-enabled-p' is not autoloaded, and this setting isn't either.
+;; `tramp-crypt-command-completion-p' is not autoloaded, and this
+;; setting isn't either.
(function-put
- #'tramp-crypt-add-directory 'completion-predicate #'tramp-crypt-enabled-p)
+ #'tramp-crypt-add-directory 'completion-predicate
+ #'tramp-crypt-command-completion-p)
(defun tramp-crypt-remove-directory (name)
"Unmark remote directory NAME for encryption.
Existing files in that directory and its subdirectories will be
kept in their encrypted form."
- ;; (declare (completion tramp-crypt-enabled-p))
+ ;; (declare (completion tramp-crypt-command-completion-p))
(interactive "DRemote directory name: ")
(unless tramp-crypt-enabled
(tramp-user-error nil "Feature is not enabled."))
;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
(function-put
- #'tramp-crypt-remove-directory 'completion-predicate #'tramp-crypt-enabled-p)
+ #'tramp-crypt-remove-directory 'completion-predicate
+ #'tramp-crypt-command-completion-p)
;; `auth-source' requires a user.
(defun tramp-crypt-dissect-file-name (name)