summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2019-12-23 13:58:55 +0100
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2019-12-23 13:58:55 +0100
commit7edcb0729df7c8bcc2dc0b4539bb7371fc468edd (patch)
tree670490bd79f92a263796db3514b8844a5181aa44
parentbfeeb48b792d5ada9c9deffb91b7d851cef53ad2 (diff)
downloaddotfiles-7edcb0729df7c8bcc2dc0b4539bb7371fc468edd.tar.xz
Prevent minibuffer seizures when setting frame title
For reasons not entirely clear, the password prompt would get stuck when trying to sudoedit a file. minibuffer-depth-indicate-mode told me that I was 16 prompts deep. I'll chalk if off to my/project-name calling functions it shouldn't call when TRAMP is busy.
-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))