Skip to content

Commit

Permalink
[Compatibility] Persist all tramp-based paths as is.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Miller committed May 15, 2024
1 parent d45032e commit b94a436
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/elisp/treemacs-compatibility.el
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
(require 'treemacs-scope)
(require 'treemacs-core-utils)
(require 'treemacs-interface)
(require 'treemacs-persistence)

(eval-when-compile
(require 'treemacs-macros))
Expand All @@ -38,10 +39,13 @@
(push '(treemacs-workspace . :never) frameset-filter-alist))

(with-eval-after-load 'tramp
(setf treemacs--file-name-handler-alist
(with-no-warnings
(list
(cons tramp-file-name-regexp #'tramp-file-name-handler)))))
(setf
treemacs--no-abbr-on-persist-prefixes
(--map (format "/%s:" (car it)) (with-no-warnings tramp-methods))
treemacs--file-name-handler-alist
(with-no-warnings
(list
(cons tramp-file-name-regexp #'tramp-file-name-handler)))))

(with-eval-after-load 'recentf
(with-no-warnings
Expand Down
6 changes: 5 additions & 1 deletion src/elisp/treemacs-persistence.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
(:constructor treemacs-iter->create!))
list)

(defvar treemacs--no-abbr-on-persist-prefixes nil
"Prefixes for paths that should be saved as is, without `abbreviate-file-name'.
Set the all the `tramp-methods', after it has been loaded.'")

(define-inline treemacs-iter->next! (self)
"Get the next element of iterator SELF.
Expand Down Expand Up @@ -201,7 +205,7 @@ ITER: Treemacs-Iter Struct"
(push (format
" - path :: %s\n"
(-let [path (treemacs-project->path pr)]
(if (string-prefix-p "/ssh:" path)
(if (--any? (string-prefix-p it path) treemacs--no-abbr-on-persist-prefixes)
path
(abbreviate-file-name path))))
txt)))
Expand Down

0 comments on commit b94a436

Please sign in to comment.