summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2022-09-24 18:44:32 +0200
committerMichael Albinus <michael.albinus@gmx.de>2022-09-24 18:44:32 +0200
commit4c66a4addcc1e282f73f77ad11a1c14093c21d07 (patch)
tree3da204ebacdeab82c74758cb19eadd358e925b39
parent3a0a0d616ecb13eece6c0f07c779d7f094836174 (diff)
downloademacs-4c66a4addcc1e282f73f77ad11a1c14093c21d07.tar.gz
Adapt tramp-docker integration
* doc/misc/tramp.texi (Inline methods): Add docker. (Customizing Methods): Remove docker-tramp. Adapt references to this. * etc/NEWS: Mention new Tramp method "docker". Fix typos. * lisp/net/tramp-compat.el (docker-tramp): Warn, if that package is used. * lisp/net/tramp-docker.el: Format header lines. (tramp-docker): Remove custom group. (tramp-docker-program, tramp-docker-method): Add ;;;###tramp-autoload cookie. (tramp-docker-program): Change group to `tramp'. Add version. (tramp-docker--completion-function): Fix docstring. (tramp-docker--add-method, tramp-docker--remove-method) (tramp-docker-unload-function, tramp-docker-setup): Remove functions. (tramp-methods, tramp-set-completion-function): Initialize via `tramp--with-startup'. (tramp-unload-hook): Unload `tramp-docker'.
-rw-r--r--doc/misc/tramp.texi31
-rw-r--r--etc/NEWS12
-rw-r--r--lisp/net/tramp-compat.el4
-rw-r--r--lisp/net/tramp-docker.el110
4 files changed, 70 insertions, 87 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 0e55b6c1d2a..455e145a818 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -903,6 +903,15 @@ supports changing the remote login shell @command{/bin/sh}.
Check the @samp{Share SSH connections if possible} control for that
session.
+@item @option{docker}
+@cindex method @option{docker}
+@cindex @option{docker} method
+
+Integration for Docker containers. A container is accessed via
+@file{@trampfn{docker,user@@container,/path/to/file}}, where
+@samp{user} is the (optional) user that you want to use, and
+@samp{container} is the id or name of the container.
+
@end table
@@ -1763,36 +1772,30 @@ They can be installed with Emacs's Package Manager. This includes
@c @item ibuffer-tramp.el
@c Contact Svend Sorensen <svend@@ciffer.net>
-@item docker-tramp
-@cindex method @option{docker}
-@cindex @option{docker} method
-Integration for Docker containers. A container is accessed via
-@file{@trampfn{docker,user@@container,/path/to/file}}, where
-@samp{user} is the (optional) user that you want to use, and
-@samp{container} is the id or name of the container.
-
@item kubernetes-tramp
@cindex method @option{kubectl}
@cindex @option{kubectl} method
-Integration for Docker containers deployed in a Kubernetes cluster.
-It is derived from @samp{docker-tramp}. A container is accessed via
+Integration for Docker containers deployed in a Kubernetes cluster. A
+container is accessed via
@file{@trampfn{kubectl,user@@container,/path/to/file}}, @samp{user}
-and @samp{container} have the same meaning as in @samp{docker-tramp}.
+and @samp{container} have the same meaning as with the @option{docker}
+method.
@item lxc-tramp
@cindex method @option{lxc}
@cindex @option{lxc} method
Integration for LXC containers. A container is accessed via
@file{@trampfn{lxc,container,/path/to/file}}, @samp{container} has the
-same meaning as in @samp{docker-tramp}. A @samp{user} specification
-is ignored.
+same meaning as with the @option{docker} method. A @samp{user}
+specification is ignored.
@item lxd-tramp
@cindex method @option{lxd}
@cindex @option{lxd} method
Integration for LXD containers. A container is accessed via
@file{@trampfn{lxd,user@@container,/path/to/file}}, @samp{user} and
-@samp{container} have the same meaning as in @samp{docker-tramp}.
+@samp{container} have the same meaning as with the @option{docker}
+method.
@item magit-tramp
@cindex method @option{git}
diff --git a/etc/NEWS b/etc/NEWS
index 037368d1ec8..5b15e9dcb60 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -400,7 +400,7 @@ performance, but the latter is closer to a drop-in replacement.
---
** The thumbs.el library is now obsolete.
-We recommend using `M-x image-dired' instead.
+We recommend using 'M-x image-dired' instead.
---
** The autoarg.el library is now marked obsolete.
@@ -1371,7 +1371,7 @@ This controls how statements like the following are indented:
foo &&
bar
-*** New Flymake backend using the ShellCheck program
+*** New Flymake backend using the ShellCheck program.
It is enabled by default, but requires that the external "shellcheck"
command is installed.
@@ -2311,6 +2311,10 @@ and friends.
** Tramp
++++
+*** New connection method "docker".
+It allows accessing environments provided by Docker.
+
---
*** Tramp supports abbreviating remote home directories now.
When calling 'abbreviate-file-name' on a Tramp file name, the result
@@ -2640,7 +2644,7 @@ didn't work well in most files in the past, either, but it will now
signal an error in any file.)
In addition, files are scanned in a slightly different way.
-Previously ';;;###' specs inside a top-level form (i.e., something
+Previously, ';;;###' specs inside a top-level form (i.e., something
like '(when ... ;;;### ...)' would be ignored. They are now parsed as
normal.
@@ -2919,7 +2923,7 @@ functions.
---
** '?\' at the end of a line now signals an error.
-Previously it produced a nonsense value, -1, that was never intended.
+Previously, it produced a nonsense value, -1, that was never intended.
---
** Some libraries obsolete since Emacs 24.1 and 24.3 have been removed:
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index a7dd9c03f32..f6cc1034ca5 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -50,6 +50,10 @@
(warn "Tramp has been compiled with Emacs %s, this is Emacs %s"
tramp-compat-emacs-compiled-version emacs-version))
+(with-eval-after-load 'docker-tramp
+ (warn (concat "Package `docker-tramp' has been obsoleted, "
+ "please use integrated package `tramp-docker'")))
+
;; For not existing functions, obsolete functions, or functions with a
;; changed argument list, there are compiler warnings. We want to
;; avoid them in cases we know what we do.
diff --git a/lisp/net/tramp-docker.el b/lisp/net/tramp-docker.el
index 3953e4d2721..40257a4a12c 100644
--- a/lisp/net/tramp-docker.el
+++ b/lisp/net/tramp-docker.el
@@ -3,39 +3,31 @@
;; Copyright © 2022 Free Software Foundation, Inc.
;; Author: Brian Cully <bjc@kublai.com>
-;; Maintainer: Brian Cully <bjc@kublai.com>
-;; URL: https://git.spork.org/tramp-docker
-;; Keywords: tramp, docker
-;; Version: 0.99.1
-;; Package-Requires: ((emacs "23"))
+;; Keywords: comm, processes
+;; Package: tramp
-;;; License:
+;; This file is part of GNU Emacs.
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation, either version 3 of the
-;; License, or (at your option) any later version.
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;; General Public License for more details.
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
-;;
;; ‘tramp-docker’ allows Tramp access to environments provided by
;; Docker.
;;
;; ## Usage
;;
-;; Call ‘tramp-docker-setup’ in your Emacs initialization.
-;;
-;; (add-hook 'after-init-hook 'tramp-docker-setup)
-;;
;; Open a file on a running systemd-docker container:
;;
;; C-x C-f /docker:USER@CONTAINER:/path/to/file
@@ -43,33 +35,28 @@
;; Where:
;; USER is the user on the container to connect as (optional)
;; CONTAINER is the container to connect to
-;;
;;; Code:
-
-(require 'tramp)
-(defgroup tramp-docker nil
- "Tramp integration for Docker containers."
- :prefix "tramp-docker-"
- :group 'applications
- :link '(url-link :tag "repo" "https://git.spork.org/tramp-docker.git")
- :link '(emacs-commentary-link :tag "Commentary" "tramp-docker"))
+(require 'tramp)
+;;;###tramp-autoload
(defcustom tramp-docker-program "docker"
"Name of the Docker client program."
+ :group 'tramp
+ :version "29.1"
:type '(choice (const "docker")
(const "podman")
- (string))
- :group 'tramp-docker)
+ (string)))
+;;;###tramp-autoload
(defconst tramp-docker-method "docker"
"Tramp method name to use to connect to Docker containers.")
(defun tramp-docker--completion-function (&rest _args)
"List Docker containers available for connection.
-This function is used by ‘tramp-set-completion-function’, please
+This function is used by `tramp-set-completion-function', please
see its function help for a description of the format."
(let* ((raw-list (shell-command-to-string
(concat tramp-docker-program
@@ -83,43 +70,28 @@ see its function help for a description of the format."
(mapcar (lambda (m) (list nil m)) machines)))
;; todo: check tramp-async-args and tramp-direct-async
-(defun tramp-docker--add-method ()
- "Add Tramp method handler for Docker containers."
- (push `(,tramp-docker-method
- (tramp-login-program ,tramp-docker-program)
- (tramp-login-args (("exec")
- ("-it")
- ("-u" "%u")
- ("%h")
- ("/bin/sh")))
- (tramp-remote-shell "/bin/sh")
- (tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-i" "-c")))
- tramp-methods))
-
-(defun tramp-docker--remove-method ()
- "Remove Tramp method handler for docker containers."
- (setf (alist-get tramp-docker-method tramp-methods nil t 'string=) nil))
-
-(defun tramp-docker-unload-function ()
- "Remove Tramp method handler and completion functions."
- (tramp-set-completion-function tramp-docker-method nil)
- (tramp-docker--remove-method)
- nil)
-
-(when nil
- (load-file (buffer-file-name))
- (setq tramp-docker-program "doas podman")
- (setq tramp-verbose 7) ;; default 3
- (tramp-docker-setup)
- (tramp-docker-unload-function))
-
-;;;###autoload
-(defun tramp-docker-setup ()
- "Initialize Docker support for Tramp."
- (tramp-docker--add-method)
- (tramp-set-completion-function tramp-docker-method
- '((tramp-docker--completion-function ""))))
+;;;###tramp-autoload
+(tramp--with-startup
+ (push `(,tramp-docker-method
+ (tramp-login-program ,tramp-docker-program)
+ (tramp-login-args (("exec")
+ ("-it")
+ ("-u" "%u")
+ ("%h")
+ ("/bin/sh")))
+ (tramp-remote-shell "/bin/sh")
+ (tramp-remote-shell-login ("-l"))
+ (tramp-remote-shell-args ("-i" "-c")))
+ tramp-methods)
+
+ (tramp-set-completion-function
+ tramp-docker-method
+ '((tramp-docker--completion-function ""))))
+
+(add-hook 'tramp-unload-hook
+ (lambda ()
+ (unload-feature 'tramp-docker 'force)))
(provide 'tramp-docker)
+
;;; tramp-docker.el ends here