mirror of https://github.com/djcb/mu.git
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.
This commit is contained in:
parent
396368d1ad
commit
1919146b94
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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..."
|
||||
|
|
Loading…
Reference in New Issue