summaryrefslogtreecommitdiff
path: root/lisp/net
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 /lisp/net
parent3a0a0d616ecb13eece6c0f07c779d7f094836174 (diff)
downloademacs-4c66a4addcc1e282f73f77ad11a1c14093c21d07.tar.gz
emacs-4c66a4addcc1e282f73f77ad11a1c14093c21d07.tar.bz2
emacs-4c66a4addcc1e282f73f77ad11a1c14093c21d07.zip
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'.
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/tramp-compat.el4
-rw-r--r--lisp/net/tramp-docker.el110
2 files changed, 45 insertions, 69 deletions
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