module: add :emacs tramp

This commit is contained in:
Henrik Lissner
2025-09-14 21:25:04 -04:00
parent 0d41af1ef7
commit 71eae252ac
4 changed files with 116 additions and 13 deletions

View File

@@ -0,0 +1,61 @@
:PROPERTIES:
:ID: 68a51608-e252-421a-bb79-bb1f038fbf5b
:END:
#+title: :emacs tramp
#+subtitle: Remote files at your arthritic fingertips
#+created: September 14, 2025
#+since: 25.10.0
* Description :unfold:
This module provides sensible and performant defaults for TRAMP, a built-in
Emacs packages that provides remote file editing over various protocols like
SSH, SCP, FTP, and more.
#+begin_quote
 The performance enhancements in this module have the greatest effects in
later versions of Emacs (at least 30.1 is recommended).
#+end_quote
** Maintainers
- [[doom-user:][@hlissner]]
[[doom-contrib-maintainer:][Become a maintainer?]]
** Module flags
/This module has no flags./
** Packages
/This module doesn't install any packages./
** Hacks
#+begin_quote
󱌣 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]]
#+end_quote
** TODO Changelog
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
* Usage
#+begin_quote
󱌣 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]]
#+end_quote
* TODO Configuration
#+begin_quote
󱌣 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]]
#+end_quote
* Troubleshooting
/There are no known problems with this module./ [[doom-report:][Report one?]]
* Frequently asked questions
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
* TODO Appendix
#+begin_quote
󱌣 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
#+end_quote

View File

@@ -0,0 +1,50 @@
;;; emacs/tramp/config.el -*- lexical-binding: t; -*-
;; Prefix tramp autosaves to prevent conflicts with local ones
(cl-pushnew (list "\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
(concat auto-save-list-file-prefix "tramp-\\2") t)
auto-save-file-name-transforms
:test #'equal)
(after! tramp
(setq remote-file-name-inhibit-cache 60
remote-file-name-inhibit-locks t
tramp-copy-size-limit (* 1024 1024) ; 1mb
tramp-use-scp-direct-remote-copying t
tramp-completion-reread-directory-timeout 60
tramp-backup-directory-alist backup-directory-alist
tramp-auto-save-directory (concat doom-cache-dir "tramp-autosave/"))
;; the ssh method is faster tha nthe default ssh on Windows
(unless (featurep :system 'windows)
(setq tramp-default-method "ssh")))
;; PERF: When creating a new process in Emacs, you have two options: synchronous
;; or asynchronous. Async processes have historically been really slow over
;; TRAMP, because it has to create a new connection for every async process.
;; However recent version of TRAMP have added a feature called direct async
;; process that makes this significantly faster. This feature alone will take
;; many packages (like magit or git-gutter) from completely unusable to
;; bearable over TRAMP. Here is how you configure it with TRAMP 2.7.
(connection-local-set-profile-variables
'remote-direct-async-process
'((tramp-direct-async-process . t)))
(connection-local-set-profiles
`(:application tramp :protocol "scp")
'remote-direct-async-process)
;; See magit/magit#5220
(after! magit
(setq magit-tramp-pipe-stty-setings 'pty))
;; PERF: Newer versions of TRAMP will use SSH connection sharing for much faster
;; connections. These dont require you to reenter your password each time you
;; connect. The compile command disables this feature, so we want to turn it
;; back on.
(after! (tramp compile)
(remove-hook 'compilation-mode-hook #'tramp-compile-disable-ssh-controlmaster-options))