diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2021-04-19 11:52:48 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2021-04-19 11:52:48 +0200 |
commit | 518312346d9440d18e224231cb645cb3aaf373ba (patch) | |
tree | b569f0bcfc97ebc522c2c33f2a48743d4bac22e0 /lisp | |
parent | 07bb2cbf5558d3ec048ab02be95060aa6efceff5 (diff) | |
download | emacs-518312346d9440d18e224231cb645cb3aaf373ba.tar.gz emacs-518312346d9440d18e224231cb645cb3aaf373ba.tar.bz2 emacs-518312346d9440d18e224231cb645cb3aaf373ba.zip |
Add Tramp recompilation
* doc/misc/tramp.texi (Frequently Asked Questions): Refer to GNU
ELPA Tramp README.
* lisp/net/tramp-cmds.el (tramp-recompile-elpa-command-completion-p)
(tramp-recompile-elpa): New defuns. Add property `completion-predicate'.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/net/tramp-cmds.el | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index d208f0e044a..6342cf52873 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -472,6 +472,48 @@ For details, see `tramp-rename-files'." (function-put #'tramp-rename-these-files 'completion-predicate #'tramp-command-completion-p) +;; This function takes action since Emacs 28.1, when +;; `read-extended-command-predicate' is set to +;; `command-completion-default-include-p'. +;;;###tramp-autoload +(defun tramp-recompile-elpa-command-completion-p (_symbol _buffer) + "A predicate for `tramp-recompile-elpa'. +It is completed by \"M-x TAB\" only if package.el is loaded, and +Tramp is an installed ELPA package." + ;; We cannot apply `package-installed-p', this would also return the + ;; builtin package. + (tramp-compat-funcall 'package--user-installed-p 'tramp)) + +;;;###tramp-autoload +(defun tramp-recompile-elpa () + "Recompile the installed Tramp ELPA package. +This is needed if there are compatibility problems." + ;; (declare (completion tramp-recompile-elpa-command-completion-p)) + (interactive) + ;; We expect just one Tramp package is installed. + (when-let + ((dir (tramp-compat-funcall + 'package-desc-dir + (car (alist-get 'tramp (bound-and-true-p package-alist)))))) + (dolist (elc (directory-files dir 'full "\\.elc$")) + (delete-file elc)) + (with-current-buffer (get-buffer-create byte-compile-log-buffer) + (let ((inhibit-read-only t)) + (compilation-mode) + (goto-char (point-max)) + (insert "\f\n") + (call-process + (expand-file-name invocation-name invocation-directory) nil t t + "-Q" "-batch" "-L" dir + "--eval" (format "(byte-recompile-directory %S 0 t)" dir)) + (message "Package `tramp' recompiled."))))) + +;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form. +;;;###tramp-autoload +(function-put + #'tramp-recompile-elpa 'completion-predicate + #'tramp-recompile-elpa-command-completion-p) + ;; Tramp version is useful in a number of situations. ;;;###tramp-autoload |