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

@@ -104,8 +104,7 @@ possible."
delete-old-versions t ; clean up after itself delete-old-versions t ; clean up after itself
kept-old-versions 5 kept-old-versions 5
kept-new-versions 5 kept-new-versions 5
backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/"))) backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/"))))
tramp-backup-directory-alist backup-directory-alist)
;; But turn on auto-save, so we have a fallback in case of crashes or lost data. ;; But turn on auto-save, so we have a fallback in case of crashes or lost data.
;; Use `recover-file' or `recover-session' to recover them. ;; Use `recover-file' or `recover-session' to recover them.
@@ -116,12 +115,8 @@ possible."
auto-save-include-big-deletions t auto-save-include-big-deletions t
;; Keep it out of `doom-emacs-dir' or the local directory. ;; Keep it out of `doom-emacs-dir' or the local directory.
auto-save-list-file-prefix (concat doom-cache-dir "autosave/") auto-save-list-file-prefix (concat doom-cache-dir "autosave/")
tramp-auto-save-directory (concat doom-cache-dir "tramp-autosave/")
auto-save-file-name-transforms auto-save-file-name-transforms
(list (list "\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" (list (list ".*" auto-save-list-file-prefix t)))
;; Prefix tramp autosaves to prevent conflicts with local ones
(concat auto-save-list-file-prefix "tramp-\\2") t)
(list ".*" auto-save-list-file-prefix t)))
(add-hook! 'after-save-hook (add-hook! 'after-save-hook
(defun doom-guess-mode-h () (defun doom-guess-mode-h ()
@@ -417,13 +412,9 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(server-start))) (server-start)))
(after! tramp (after! vc-hooks
(setq remote-file-name-inhibit-cache 60 (setq vc-ignore-dir-regexp (format "%s\\|%s"
tramp-completion-reread-directory-timeout 60
tramp-verbose 1
vc-ignore-dir-regexp (format "%s\\|%s\\|%s"
vc-ignore-dir-regexp vc-ignore-dir-regexp
tramp-file-name-regexp
"[/\\\\]node_modules"))) "[/\\\\]node_modules")))

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))

View File

@@ -72,6 +72,7 @@
electric ; smarter, keyword-based electric-indent electric ; smarter, keyword-based electric-indent
;;eww ; the internet is gross ;;eww ; the internet is gross
;;ibuffer ; interactive buffer management ;;ibuffer ; interactive buffer management
tramp ; remote files at your arthritic fingertips
undo ; persistent, smarter undo for your inevitable mistakes undo ; persistent, smarter undo for your inevitable mistakes
vc ; version-control and Emacs, sitting in a tree vc ; version-control and Emacs, sitting in a tree