summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-04-30 22:43:25 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-05-01 22:44:45 +0300
commit1919146b940dde0c7a3ae96400dbfd5f5669f6d0 (patch)
tree1002d5b776c53c4e1cf301106abf73803e1b989c
parent396368d1adbbe86505e3f416ad824a8ac07d4632 (diff)
mu4e: centralize mode-line context setting code
Add mu4e-context-in-modeline to handle all setting of context in the mode-line, to address some corner-cases with the current setup.
-rw-r--r--mu4e/mu4e-compose.el3
-rw-r--r--mu4e/mu4e-context.el7
-rw-r--r--mu4e/mu4e-headers.el5
-rw-r--r--mu4e/mu4e-main.el10
-rw-r--r--mu4e/mu4e-view.el5
5 files changed, 15 insertions, 15 deletions
diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el
index 47697e4..2490e3c 100644
--- a/mu4e/mu4e-compose.el
+++ b/mu4e/mu4e-compose.el
@@ -443,8 +443,7 @@ buffers; lets remap its faces so it uses the ones for mu4e."
\\{message-mode-map}."
(progn
(use-local-map mu4e-compose-mode-map)
- (make-local-variable 'global-mode-string)
- (add-to-list 'global-mode-string '(:eval (mu4e-context-label)))
+ (mu4e-context-in-modeline)
(set (make-local-variable 'message-signature) mu4e-compose-signature)
;; set this to allow mu4e to work when gnus-agent is unplugged in gnus
(set (make-local-variable 'message-send-mail-real-function) nil)
diff --git a/mu4e/mu4e-context.el b/mu4e/mu4e-context.el
index 1c33dac..2360651 100644
--- a/mu4e/mu4e-context.el
+++ b/mu4e/mu4e-context.el
@@ -284,6 +284,13 @@ match, POLICY determines what to do:
(mu4e~context-ask-user "Select context: ")))
(otherwise nil))))))
+(defun mu4e-context-in-modeline ()
+ "Display the mu4e-context (if any) in a (buffer-specific)
+global-mode-line."
+ (add-to-list
+ (make-local-variable 'global-mode-string)
+ '(:eval (mu4e-context-label))))
+
;;; _
(provide 'mu4e-context)
;;; mu4e-context.el ends here
diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el
index 4b226a3..f135335 100644
--- a/mu4e/mu4e-headers.el
+++ b/mu4e/mu4e-headers.el
@@ -1086,9 +1086,10 @@ no user-interaction ongoing."
(use-local-map mu4e-headers-mode-map)
(make-local-variable 'mu4e~headers-proc)
(make-local-variable 'mu4e~highlighted-docid)
- (make-local-variable 'global-mode-string)
(set (make-local-variable 'hl-line-face) 'mu4e-header-highlight-face)
+ (mu4e-context-in-modeline)
+
;; maybe update the current headers upon indexing changes
(add-hook 'mu4e-index-updated-hook 'mu4e~headers-maybe-auto-update)
(add-hook 'mu4e-index-updated-hook
@@ -1233,6 +1234,7 @@ the query history stack."
(setq
mode-name "mu4e-headers"
mu4e~headers-last-query rewritten-expr)
+ (make-local-variable 'global-mode-string)
(add-to-list 'global-mode-string
'(:eval
(concat
@@ -1240,7 +1242,6 @@ the query history stack."
(mu4e~quote-for-modeline mu4e~headers-last-query)
'face 'mu4e-modeline-face)
" "
- (mu4e-context-label)
(if (and mu4e-display-update-status-in-modeline
(buffer-live-p mu4e~update-buffer)
(process-live-p (get-buffer-process
diff --git a/mu4e/mu4e-main.el b/mu4e/mu4e-main.el
index e96b27a..39275d9 100644
--- a/mu4e/mu4e-main.el
+++ b/mu4e/mu4e-main.el
@@ -80,10 +80,7 @@ with SPC and therefore is not visible in buffer list.")
\\{mu4e-main-mode-map}."
(setq truncate-lines t
overwrite-mode 'overwrite-mode-binary)
-
- ;; show context in mode-string
- (make-local-variable 'global-mode-string)
- (add-to-list 'global-mode-string '(:eval (mu4e-context-label)))
+ (mu4e-context-in-modeline)
(set (make-local-variable 'revert-buffer-function) #'mu4e~main-view-real))
@@ -225,7 +222,7 @@ When REFRESH is non nil refresh infos from server."
(mu4e~key-val "personal addresses" (if addrs (mapconcat #'identity addrs ", " ) "none"))))
(if mu4e-main-buffer-hide-personal-addresses ""
- (when (and addrs user-mail-address (not (member user-mail-address addrs)))
+ (when (and user-mail-address (not (member user-mail-address addrs)))
(mu4e-message (concat
"Note: `user-mail-address' ('%s') is not part "
"of mu's addresses; add it with 'mu init --my-address='")
@@ -276,8 +273,7 @@ When REFRESH is non nil refresh infos from server."
(switch-to-buffer buf)
(with-current-buffer buf
(mu4e~main-view-real-1 refresh))
- (goto-char (point-min)))
- (add-to-list 'global-mode-string '(:eval (mu4e-context-label)))))
+ (goto-char (point-min)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interactive functions
diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el
index 47871a1..185fa35 100644
--- a/mu4e/mu4e-view.el
+++ b/mu4e/mu4e-view.el
@@ -989,9 +989,7 @@ FUNC should be a function taking two arguments:
(defun mu4e~view-mode-body ()
"Body of the mode-function."
(use-local-map mu4e-view-mode-map)
- ;; show context in mode-string
- (make-local-variable 'global-mode-string)
- (add-to-list 'global-mode-string '(:eval (mu4e-context-label)))
+ (mu4e-context-in-modeline)
(setq buffer-undo-list t);; don't record undo info
;; autopair mode gives error when pressing RET
;; turn it off
@@ -1840,7 +1838,6 @@ other windows."
(define-derived-mode mu4e-loading-mode special-mode
"mu4e:loading"
(use-local-map mu4e-loading-mode-map)
- (make-local-variable 'global-mode-string)
(let ((inhibit-read-only t))
(erase-buffer)
(insert (propertize "Loading message..."