summaryrefslogtreecommitdiff
path: root/.emacs
diff options
context:
space:
mode:
Diffstat (limited to '.emacs')
-rw-r--r--.emacs26
1 files changed, 21 insertions, 5 deletions
diff --git a/.emacs b/.emacs
index 6774532..9c4ccaf 100644
--- a/.emacs
+++ b/.emacs
@@ -343,11 +343,27 @@
(when (not (file-equal-p root "~"))
(file-name-nondirectory (string-trim-right root "/")))))
-(setq frame-title-format
- '(:eval
- (save-match-data ; cf. bug#33697
- (let ((project (my/project-name)))
- (concat (when project (format "[%s] " project)) "%b")))))
+(defun my/connection-name ()
+ (when-let ((method (file-remote-p default-directory 'method)))
+ (if (string-match-p "sudo" method)
+ method
+ (format "%s:%s" method (file-remote-p default-directory 'host)))))
+
+(defun my/frame-title-format ()
+ (let ((prefix
+ ;; Messing with match data during redisplay is dangerous
+ ;; (cf. bug#33697).
+ (save-match-data
+ ;; For some reason, calling filename-parsing functions
+ ;; while TRAMP is busy opens the gates to Infinite
+ ;; Minibuffer Recursion Hell. Cautiously side-step that.
+ (or
+ (my/connection-name)
+ (my/project-name)))))
+ (concat (when prefix (format "[%s] " prefix))
+ "%b")))
+
+(setq frame-title-format '(:eval (my/frame-title-format)))
(setq-default paragraph-start (concat "[ ]*- \\|" paragraph-start))