diff options
| author | Michael Albinus | 2023-04-23 13:37:39 +0200 |
|---|---|---|
| committer | Michael Albinus | 2023-04-23 13:37:39 +0200 |
| commit | 2e85ac2b270700608776ba28ecf41fc8d184db12 (patch) | |
| tree | eadefcaa1165d0fac34e1bfed2f1e44ca85189ca | |
| parent | 3badd2358d5f0af71887ee1cc9d39c2f312b6888 (diff) | |
| download | emacs-2e85ac2b270700608776ba28ecf41fc8d184db12.tar.gz emacs-2e85ac2b270700608776ba28ecf41fc8d184db12.zip | |
Add new Tramp method "flatpak"
* doc/misc/tramp.texi (Inline methods): Add flatpak.
* etc/NEWS: Add new Tramp method "flatpak". Fix typos.
* lisp/net/tramp-container.el (tramp-flatpak-program): New defcustom.
(tramp-flatpak-method): New defconst.
(tramp-flatpak--completion-function): New defun. Set it for "flatpak".
(tramp-methods) <flatpak>: Add.
(tramp-container-connection-local-default-flatpak-variables):
New defconst. Set respective connection-local variables.
| -rw-r--r-- | doc/misc/tramp.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 27 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 1 | ||||
| -rw-r--r-- | lisp/net/tramp-container.el | 85 |
4 files changed, 106 insertions, 17 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 65892f8621e..247d718b59a 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi | |||
| @@ -938,6 +938,16 @@ be used. | |||
| 938 | 938 | ||
| 939 | This method does not support user names. | 939 | This method does not support user names. |
| 940 | 940 | ||
| 941 | @item @option{flatpak} | ||
| 942 | @cindex method @option{flatpak} | ||
| 943 | @cindex @option{flatpak} method | ||
| 944 | |||
| 945 | Integration of Flatpak sandboxes. The host name may be either an | ||
| 946 | application ID, a sandbox instance ID, or a PID, as returned by | ||
| 947 | @samp{flatpak ps}. | ||
| 948 | |||
| 949 | This method does not support user names. | ||
| 950 | |||
| 941 | @end table | 951 | @end table |
| 942 | 952 | ||
| 943 | 953 | ||
| @@ -67,9 +67,10 @@ This is used for displaying the time and date components of | |||
| 67 | 'display-time-mode'. | 67 | 'display-time-mode'. |
| 68 | 68 | ||
| 69 | --- | 69 | --- |
| 70 | ** New icon images for general use | 70 | ** New icon images for general use. |
| 71 | Several symbolic icons are added to etc/images/symbols, including | 71 | Several symbolic icons are added to "etc/images/symbols", including |
| 72 | plus, minus, check-mark, start, etc. | 72 | plus, minus, check-mark, start, etc. |
| 73 | |||
| 73 | 74 | ||
| 74 | * Editing Changes in Emacs 30.1 | 75 | * Editing Changes in Emacs 30.1 |
| 75 | 76 | ||
| @@ -104,7 +105,7 @@ If you want to get back the old behavior, set the user option to the value | |||
| 104 | (setopt gdb-locals-table-row-config | 105 | (setopt gdb-locals-table-row-config |
| 105 | `((type . 0) (name . 0) (value . ,gdb-locals-value-limit))) | 106 | `((type . 0) (name . 0) (value . ,gdb-locals-value-limit))) |
| 106 | 107 | ||
| 107 | ** Compile | 108 | ** Grep |
| 108 | 109 | ||
| 109 | *** New user option 'grep-use-headings'. | 110 | *** New user option 'grep-use-headings'. |
| 110 | When non-nil, the output of Grep is split into sections, one for each | 111 | When non-nil, the output of Grep is split into sections, one for each |
| @@ -203,16 +204,18 @@ point is not in a comment or a string. It is by default bound to | |||
| 203 | ** Tramp | 204 | ** Tramp |
| 204 | 205 | ||
| 205 | +++ | 206 | +++ |
| 206 | *** New connection method "toolbox". | 207 | *** New connection methods "toolbox" and "flatpak". |
| 207 | This allows accessing system containers provided by Toolbox. | 208 | They allow accessing system containers provided by Toolbox or |
| 209 | sandboxes provided by Flatpak. | ||
| 208 | 210 | ||
| 209 | +++ | 211 | +++ |
| 210 | *** Rename 'tramp-use-ssh-controlmaster-options' to 'tramp-use-connection-share. | 212 | *** Rename 'tramp-use-ssh-controlmaster-options' to 'tramp-use-connection-share'. |
| 211 | The old name still exists as defvaralias. This user option controls | 213 | The old name still exists as obsolete variable alias. This user |
| 212 | now connection sharing for both ssh-based and plink-based methods. It | 214 | option controls now connection sharing for both ssh-based and |
| 213 | allows the values t, nil, and 'suppress'. The latter suppresses | 215 | plink-based methods. It allows the values t, nil, and 'suppress'. |
| 214 | also "ControlMaster" settings in the user's "~/.ssh/config" file, | 216 | The latter suppresses also "ControlMaster" settings in the user's |
| 215 | or connection share configuration in PuTTY sessions, respectively. | 217 | "~/.ssh/config" file, or connection share configuration in PuTTY |
| 218 | sessions, respectively. | ||
| 216 | 219 | ||
| 217 | ** EWW | 220 | ** EWW |
| 218 | 221 | ||
| @@ -280,7 +283,7 @@ distracting and easily confused with actual code, or a significant | |||
| 280 | early aid that relieves you from moving the buffer or reaching for the | 283 | early aid that relieves you from moving the buffer or reaching for the |
| 281 | mouse to consult an error message. | 284 | mouse to consult an error message. |
| 282 | 285 | ||
| 283 | ** Python mode | 286 | ** Python Mode |
| 284 | 287 | ||
| 285 | --- | 288 | --- |
| 286 | *** New user option 'python-indent-block-paren-deeper'. | 289 | *** New user option 'python-indent-block-paren-deeper'. |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 14c63ba5834..3f3fb1ea6b3 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -1311,6 +1311,7 @@ connection if a previous connection has died for some reason." | |||
| 1311 | (tramp-set-connection-property p "connected" t))))))) | 1311 | (tramp-set-connection-property p "connected" t))))))) |
| 1312 | 1312 | ||
| 1313 | ;;; Default connection-local variables for Tramp. | 1313 | ;;; Default connection-local variables for Tramp. |
| 1314 | |||
| 1314 | (defconst tramp-adb-connection-local-default-shell-variables | 1315 | (defconst tramp-adb-connection-local-default-shell-variables |
| 1315 | '((shell-file-name . "/system/bin/sh") | 1316 | '((shell-file-name . "/system/bin/sh") |
| 1316 | (shell-command-switch . "-c")) | 1317 | (shell-command-switch . "-c")) |
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el index 5ae9ebaefb2..473cb1c54b8 100644 --- a/lisp/net/tramp-container.el +++ b/lisp/net/tramp-container.el | |||
| @@ -47,9 +47,9 @@ | |||
| 47 | ;; C-x C-f /kubernetes:POD:/path/to/file | 47 | ;; C-x C-f /kubernetes:POD:/path/to/file |
| 48 | ;; | 48 | ;; |
| 49 | ;; Where: | 49 | ;; Where: |
| 50 | ;; POD is the pod to connect to. | 50 | ;; POD is the pod to connect to. |
| 51 | ;; By default, the first container in that pod will be | 51 | ;; By default, the first container in that pod will be |
| 52 | ;; used. | 52 | ;; used. |
| 53 | ;; | 53 | ;; |
| 54 | ;; Completion for POD and accessing it operate in the current | 54 | ;; Completion for POD and accessing it operate in the current |
| 55 | ;; namespace, use this command to change it: | 55 | ;; namespace, use this command to change it: |
| @@ -58,7 +58,7 @@ | |||
| 58 | ;; | 58 | ;; |
| 59 | ;; | 59 | ;; |
| 60 | ;; | 60 | ;; |
| 61 | ;; Open a file on an existing toolbox container via Toolbox: | 61 | ;; Open a file on an existing Toolbox container: |
| 62 | ;; | 62 | ;; |
| 63 | ;; C-x C-f /toolbox:CONTAINER:/path/to/file | 63 | ;; C-x C-f /toolbox:CONTAINER:/path/to/file |
| 64 | ;; | 64 | ;; |
| @@ -67,6 +67,16 @@ | |||
| 67 | ;; | 67 | ;; |
| 68 | ;; If the container is not running, it is started. If no container is | 68 | ;; If the container is not running, it is started. If no container is |
| 69 | ;; specified, the default Toolbox container is used. | 69 | ;; specified, the default Toolbox container is used. |
| 70 | ;; | ||
| 71 | ;; | ||
| 72 | ;; | ||
| 73 | ;; Open a file on a running Flatpak sandbox: | ||
| 74 | ;; | ||
| 75 | ;; C-x C-f /flatpak:SANDBOX:/path/to/file | ||
| 76 | ;; | ||
| 77 | ;; Where: | ||
| 78 | ;; SANDBOX is the running sandbox to connect to. | ||
| 79 | ;; It could be an application ID, an instance ID, or a PID. | ||
| 70 | 80 | ||
| 71 | ;;; Code: | 81 | ;;; Code: |
| 72 | 82 | ||
| @@ -105,6 +115,14 @@ | |||
| 105 | (string))) | 115 | (string))) |
| 106 | 116 | ||
| 107 | ;;;###tramp-autoload | 117 | ;;;###tramp-autoload |
| 118 | (defcustom tramp-flatpak-program "flatpak" | ||
| 119 | "Name of the Flatpak client program." | ||
| 120 | :group 'tramp | ||
| 121 | :version "30.1" | ||
| 122 | :type '(choice (const "flatpak") | ||
| 123 | (string))) | ||
| 124 | |||
| 125 | ;;;###tramp-autoload | ||
| 108 | (defconst tramp-docker-method "docker" | 126 | (defconst tramp-docker-method "docker" |
| 109 | "Tramp method name to use to connect to Docker containers.") | 127 | "Tramp method name to use to connect to Docker containers.") |
| 110 | 128 | ||
| @@ -121,6 +139,10 @@ | |||
| 121 | "Tramp method name to use to connect to Toolbox containers.") | 139 | "Tramp method name to use to connect to Toolbox containers.") |
| 122 | 140 | ||
| 123 | ;;;###tramp-autoload | 141 | ;;;###tramp-autoload |
| 142 | (defconst tramp-flatpak-method "flatpak" | ||
| 143 | "Tramp method name to use to connect to Flatpak sandboxes.") | ||
| 144 | |||
| 145 | ;;;###tramp-autoload | ||
| 124 | (defun tramp-container--completion-function (program) | 146 | (defun tramp-container--completion-function (program) |
| 125 | "List running containers available for connection. | 147 | "List running containers available for connection. |
| 126 | PROGRAM is the program to be run for \"ps\", either | 148 | PROGRAM is the program to be run for \"ps\", either |
| @@ -196,6 +218,30 @@ see its function help for a description of the format." | |||
| 196 | (mapcar (lambda (name) (list nil name)) (delq nil names)))) | 218 | (mapcar (lambda (name) (list nil name)) (delq nil names)))) |
| 197 | 219 | ||
| 198 | ;;;###tramp-autoload | 220 | ;;;###tramp-autoload |
| 221 | (defun tramp-flatpak--completion-function (&rest _args) | ||
| 222 | "List Flatpak sandboxes available for connection. | ||
| 223 | It returns application IDs or, in case there is no application | ||
| 224 | ID, instance IDs. | ||
| 225 | |||
| 226 | This function is used by `tramp-set-completion-function', please | ||
| 227 | see its function help for a description of the format." | ||
| 228 | (when-let ((default-directory tramp-compat-temporary-file-directory) | ||
| 229 | (raw-list | ||
| 230 | (shell-command-to-string | ||
| 231 | (concat tramp-flatpak-program | ||
| 232 | " ps --columns=instance,application"))) | ||
| 233 | (lines (split-string raw-list "\n" 'omit)) | ||
| 234 | (names (mapcar | ||
| 235 | (lambda (line) | ||
| 236 | (when (string-match | ||
| 237 | (rx bol (* space) (group (+ (not space))) | ||
| 238 | (? (+ space) (group (+ (not space)))) eol) | ||
| 239 | line) | ||
| 240 | (or (match-string 2 line) (match-string 1 line)))) | ||
| 241 | lines))) | ||
| 242 | (mapcar (lambda (name) (list nil name)) (delq nil names)))) | ||
| 243 | |||
| 244 | ;;;###tramp-autoload | ||
| 199 | (defvar tramp-default-remote-shell) ;; Silence byte compiler. | 245 | (defvar tramp-default-remote-shell) ;; Silence byte compiler. |
| 200 | 246 | ||
| 201 | ;;;###tramp-autoload | 247 | ;;;###tramp-autoload |
| @@ -253,6 +299,17 @@ see its function help for a description of the format." | |||
| 253 | 299 | ||
| 254 | (add-to-list 'tramp-default-host-alist `(,tramp-toolbox-method nil "")) | 300 | (add-to-list 'tramp-default-host-alist `(,tramp-toolbox-method nil "")) |
| 255 | 301 | ||
| 302 | (add-to-list 'tramp-methods | ||
| 303 | `(,tramp-flatpak-method | ||
| 304 | (tramp-login-program ,tramp-flatpak-program) | ||
| 305 | (tramp-login-args (("enter") | ||
| 306 | ("%h") | ||
| 307 | ("%l"))) | ||
| 308 | (tramp-direct-async (,tramp-default-remote-shell "-c")) | ||
| 309 | (tramp-remote-shell ,tramp-default-remote-shell) | ||
| 310 | (tramp-remote-shell-login ("-l")) | ||
| 311 | (tramp-remote-shell-args ("-c")))) | ||
| 312 | |||
| 256 | (tramp-set-completion-function | 313 | (tramp-set-completion-function |
| 257 | tramp-docker-method | 314 | tramp-docker-method |
| 258 | `((tramp-container--completion-function | 315 | `((tramp-container--completion-function |
| @@ -269,7 +326,25 @@ see its function help for a description of the format." | |||
| 269 | 326 | ||
| 270 | (tramp-set-completion-function | 327 | (tramp-set-completion-function |
| 271 | tramp-toolbox-method | 328 | tramp-toolbox-method |
| 272 | '((tramp-toolbox--completion-function "")))) | 329 | '((tramp-toolbox--completion-function ""))) |
| 330 | |||
| 331 | (tramp-set-completion-function | ||
| 332 | tramp-flatpak-method | ||
| 333 | '((tramp-flatpak--completion-function ""))) | ||
| 334 | |||
| 335 | ;; Default connection-local variables for Tramp. | ||
| 336 | |||
| 337 | (defconst tramp-container-connection-local-default-flatpak-variables | ||
| 338 | `((tramp-remote-path . ,(cons "/app/bin" tramp-remote-path))) | ||
| 339 | "Default connection-local variables for remote flatpak connections.") | ||
| 340 | |||
| 341 | (connection-local-set-profile-variables | ||
| 342 | 'tramp-container-connection-local-default-flatpak-profile | ||
| 343 | tramp-container-connection-local-default-flatpak-variables) | ||
| 344 | |||
| 345 | (connection-local-set-profiles | ||
| 346 | `(:application tramp :protocol ,tramp-flatpak-method) | ||
| 347 | 'tramp-container-connection-local-default-flatpak-profile)) | ||
| 273 | 348 | ||
| 274 | (add-hook 'tramp-unload-hook | 349 | (add-hook 'tramp-unload-hook |
| 275 | (lambda () | 350 | (lambda () |