[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5183123: Add Tramp recompilation
From: |
Michael Albinus |
Subject: |
master 5183123: Add Tramp recompilation |
Date: |
Mon, 19 Apr 2021 05:52:58 -0400 (EDT) |
branch: master
commit 518312346d9440d18e224231cb645cb3aaf373ba
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
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'.
---
doc/misc/tramp.texi | 24 +++++-------------------
lisp/net/tramp-cmds.el | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 19 deletions(-)
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 40245ac..e0f648f 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -5095,35 +5095,21 @@ two forms in your @file{~/.emacs} after loading the
@code{tramp} and
@item
I get a warning @samp{Tramp has been compiled with Emacs a.b, this is Emacs
c.d}
+@item
+I get an error @samp{tramp-file-name-handler: Invalid function:
+tramp-compat-with-mutex}
@value{tramp} comes with compatibility code for different Emacs
versions. When you see this warning, you don't use the Emacs built-in
version of @value{tramp}. In case you have installed @value{tramp}
-from GNU ELPA, you must delete and reinstall it.
+from GNU ELPA, see the package README file for instructions how to
+recompile it.
@ifset installchapter
In case you have installed it from its Git repository, @ref{Recompilation}.
@end ifset
@item
-I get an error @samp{tramp-file-name-handler: Invalid function:
-tramp-compat-with-mutex}
-
-Likely, you have a running Emacs session with loaded @value{tramp},
-and you try to upgrade it to another version from GNU ELPA. Since
-@value{tramp} is not forward compatible, you must unload / reload it.
-Try the following steps:
-
-@example
-@kbd{M-x tramp-unload-tramp @key{RET}}
-@kbd{M-x load-library @key{RET} tramp @key{RET}}
-@end example
-
-If this doesn't work, you must restart Emacs with proper
-@code{load-path} for the new @value{tramp} version.
-
-
-@item
I get an error @samp{Remote file error: Forbidden reentrant call of Tramp}
@vindex remote-file-error
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index d208f0e..6342cf5 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 5183123: Add Tramp recompilation,
Michael Albinus <=