2019-08-19 12:41:33 +02:00
|
|
|
|
;;; mu4e-main.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*-
|
2020-02-11 12:23:40 +01:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
;; Copyright (C) 2011-2022 Dirk-Jan C. Binnema
|
2011-12-04 22:49:15 +01:00
|
|
|
|
|
|
|
|
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|
|
|
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2012-04-01 11:29:24 +02:00
|
|
|
|
|
2011-12-04 22:49:15 +01:00
|
|
|
|
;; This file is not part of GNU Emacs.
|
2020-02-11 12:23:40 +01:00
|
|
|
|
|
2021-05-29 23:36:13 +02:00
|
|
|
|
;; mu4e is free software: you can redistribute it and/or modify
|
2011-12-04 22:49:15 +01:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2021-05-29 23:36:13 +02:00
|
|
|
|
;; mu4e is distributed in the hope that it will be useful,
|
2011-12-04 22:49:15 +01:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2021-05-29 23:36:13 +02:00
|
|
|
|
;; along with mu4e. If not, see <http://www.gnu.org/licenses/>.
|
2011-12-04 22:49:15 +01:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
2020-02-11 15:10:35 +01:00
|
|
|
|
|
2019-11-06 16:13:39 +01:00
|
|
|
|
(require 'smtpmail) ;; the queueing stuff (silence elint)
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(require 'mu4e-helpers) ;; utility functions
|
2015-12-13 16:42:27 +01:00
|
|
|
|
(require 'mu4e-context) ;; the context
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(require 'mu4e-bookmarks)
|
|
|
|
|
(require 'mu4e-folders)
|
|
|
|
|
(require 'mu4e-update)
|
|
|
|
|
(require 'mu4e-contacts)
|
2021-08-28 21:21:00 +02:00
|
|
|
|
(require 'mu4e-search)
|
2020-05-28 09:21:16 +02:00
|
|
|
|
(require 'mu4e-vars) ;; mu-wide variables
|
2022-12-09 10:01:18 +01:00
|
|
|
|
(require 'mu4e-window)
|
2021-08-28 21:21:00 +02:00
|
|
|
|
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(declare-function mu4e-compose-new "mu4e-compose")
|
|
|
|
|
(declare-function mu4e~headers-jump-to-maildir "mu4e-headers")
|
|
|
|
|
(declare-function mu4e-quit "mu4e")
|
|
|
|
|
|
2019-08-19 12:41:33 +02:00
|
|
|
|
(require 'cl-lib)
|
2012-08-14 09:20:27 +02:00
|
|
|
|
|
2021-08-29 16:30:10 +02:00
|
|
|
|
|
|
|
|
|
;; Configuration
|
2020-02-11 15:10:35 +01:00
|
|
|
|
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(defcustom mu4e-main-hide-personal-addresses nil
|
2022-01-23 09:29:45 +01:00
|
|
|
|
"Whether to hide the personal address in the main view.
|
2020-04-06 19:49:39 +02:00
|
|
|
|
|
2022-12-31 16:47:33 +01:00
|
|
|
|
This can be useful to avoid the noise when there are many, and
|
2022-01-23 09:29:45 +01:00
|
|
|
|
also hides the warning if your `user-mail-address' is not part of
|
2022-12-31 16:47:33 +01:00
|
|
|
|
the personal addresses."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'mu4e-main)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-main-hide-fully-read nil
|
|
|
|
|
"Whether to hide bookmarks or maildirs without unread messages."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'mu4e-main)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-main-hide-baseline-delta nil
|
|
|
|
|
"Whether to hide the baseline-from-delta from the message counts
|
|
|
|
|
for bookmarks and maildirs."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'mu4e-main)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-main-auto-reset-baseline t
|
|
|
|
|
"Automatically reset the baseline when explicitly (interactively)
|
|
|
|
|
swiching to the main-view (using the `mu4e' command."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'mu4e-main)
|
2020-05-27 16:27:00 +02:00
|
|
|
|
|
2021-08-29 16:30:10 +02:00
|
|
|
|
|
|
|
|
|
;;; Mode
|
|
|
|
|
(define-derived-mode mu4e-org-mode org-mode "mu4e:org"
|
2022-01-23 09:29:45 +01:00
|
|
|
|
"Major mode for mu4e documents.")
|
2021-08-29 16:30:10 +02:00
|
|
|
|
|
|
|
|
|
(defun mu4e-info (path)
|
|
|
|
|
"Show a buffer with the information (an org-file) at PATH."
|
|
|
|
|
(unless (file-exists-p path)
|
|
|
|
|
(mu4e-error "Cannot find %s" path))
|
|
|
|
|
(let ((curbuf (current-buffer)))
|
|
|
|
|
(find-file path)
|
|
|
|
|
(mu4e-org-mode)
|
|
|
|
|
(setq buffer-read-only t)
|
|
|
|
|
(define-key mu4e-org-mode-map (kbd "q")
|
|
|
|
|
`(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(bury-buffer)
|
|
|
|
|
(switch-to-buffer ,curbuf)))))
|
|
|
|
|
|
|
|
|
|
(defun mu4e-about ()
|
2022-05-27 20:00:37 +02:00
|
|
|
|
"Show the mu4e \"About\" page."
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(interactive)
|
|
|
|
|
(mu4e-info (concat mu4e-doc-dir "/mu4e-about.org")))
|
|
|
|
|
|
|
|
|
|
(defun mu4e-news ()
|
2022-05-27 20:00:37 +02:00
|
|
|
|
"Show page with news for the current version of mu4e."
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(interactive)
|
|
|
|
|
(mu4e-info (concat mu4e-doc-dir "/NEWS.org")))
|
|
|
|
|
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(defun mu4e--main-reset-baseline-query-results ()
|
|
|
|
|
"Main-view version of `mu4e-reset-baseline-query-results'.
|
|
|
|
|
This version handles updating the current screen as well."
|
|
|
|
|
(interactive)
|
|
|
|
|
(mu4e-reset-baseline-query-results)
|
|
|
|
|
(revert-buffer))
|
2021-08-29 16:30:10 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defvar mu4e-main-mode-map
|
2011-12-04 22:49:15 +01:00
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(define-key map "q" #'mu4e-quit)
|
|
|
|
|
(define-key map "j" #'mu4e~headers-jump-to-maildir)
|
|
|
|
|
(define-key map "C" #'mu4e-compose-new)
|
2011-12-04 22:49:15 +01:00
|
|
|
|
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(define-key map "m" #'mu4e--main-toggle-mail-sending-mode)
|
|
|
|
|
(define-key map "f" #'smtpmail-send-queued-mail)
|
2012-10-25 10:59:50 +02:00
|
|
|
|
;;
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(define-key map "U" #'mu4e-update-mail-and-index)
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(define-key map "R" #'mu4e--main-reset-baseline-query-results)
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(define-key map (kbd "C-S-u") #'mu4e-update-mail-and-index)
|
2015-02-13 10:47:25 +01:00
|
|
|
|
;; for terminal users
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(define-key map (kbd "C-c C-u") #'mu4e-update-mail-and-index)
|
2015-02-13 10:47:25 +01:00
|
|
|
|
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(define-key map "S" #'mu4e-kill-update-mail)
|
|
|
|
|
(define-key map (kbd "C-S-u") #'mu4e-update-mail-and-index)
|
2021-07-29 22:24:13 +02:00
|
|
|
|
(define-key map ";"
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(lambda()(interactive)(mu4e-context-switch)(revert-buffer)))
|
2013-06-16 22:01:06 +02:00
|
|
|
|
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(define-key map "$" #'mu4e-show-log)
|
|
|
|
|
(define-key map "A" #'mu4e-about)
|
|
|
|
|
(define-key map "N" #'mu4e-news)
|
|
|
|
|
(define-key map "H" #'mu4e-display-manual)
|
2011-12-04 22:49:15 +01:00
|
|
|
|
map)
|
2011-12-14 08:13:10 +01:00
|
|
|
|
"Keymap for the *mu4e-main* buffer.")
|
2011-12-04 22:49:15 +01:00
|
|
|
|
|
2012-03-27 20:15:47 +02:00
|
|
|
|
(define-derived-mode mu4e-main-mode special-mode "mu4e:main"
|
2012-01-14 10:05:23 +01:00
|
|
|
|
"Major mode for the mu4e main screen.
|
|
|
|
|
\\{mu4e-main-mode-map}."
|
2020-02-21 08:33:07 +01:00
|
|
|
|
(setq truncate-lines t
|
|
|
|
|
overwrite-mode 'overwrite-mode-binary)
|
2021-08-28 13:56:31 +02:00
|
|
|
|
(mu4e-context-minor-mode)
|
2021-08-28 21:21:00 +02:00
|
|
|
|
(mu4e-search-minor-mode)
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(mu4e-update-minor-mode)
|
2022-09-04 23:54:24 +02:00
|
|
|
|
(set (make-local-variable 'revert-buffer-function) #'mu4e--main-view-real)
|
|
|
|
|
(add-hook 'mu4e-index-updated-hook #'mu4e--main-update-after-index))
|
2011-12-04 22:49:15 +01:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-action-str (str &optional func-or-shortcut)
|
2019-11-06 16:13:39 +01:00
|
|
|
|
"Highlight the first occurrence of [.] in STR.
|
2012-11-10 14:01:17 +01:00
|
|
|
|
If FUNC-OR-SHORTCUT is non-nil and if it is a function, call it
|
2014-01-12 12:07:36 +01:00
|
|
|
|
when STR is clicked (using RET or mouse-2); if FUNC-OR-SHORTCUT is
|
|
|
|
|
a string, execute the corresponding keyboard action when it is
|
2011-12-28 18:47:39 +01:00
|
|
|
|
clicked."
|
2011-12-25 12:38:44 +01:00
|
|
|
|
(let ((newstr
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"\\[\\(..?\\)\\]"
|
|
|
|
|
(lambda(m)
|
|
|
|
|
(format "[%s]"
|
|
|
|
|
(propertize (match-string 1 m) 'face 'mu4e-highlight-face)))
|
|
|
|
|
str))
|
|
|
|
|
(map (make-sparse-keymap))
|
|
|
|
|
(func (if (functionp func-or-shortcut)
|
|
|
|
|
func-or-shortcut
|
|
|
|
|
(if (stringp func-or-shortcut)
|
|
|
|
|
(lambda()(interactive)
|
|
|
|
|
(execute-kbd-macro func-or-shortcut))))))
|
2011-12-25 12:38:44 +01:00
|
|
|
|
(define-key map [mouse-2] func)
|
|
|
|
|
(define-key map (kbd "RET") func)
|
2011-12-26 11:17:28 +01:00
|
|
|
|
(put-text-property 0 (length newstr) 'keymap map newstr)
|
2014-01-26 05:08:16 +01:00
|
|
|
|
(put-text-property (string-match "\\[.+$" newstr)
|
2020-05-13 07:25:11 +02:00
|
|
|
|
;; only subtract one from length of newstr if we're
|
|
|
|
|
;; actually consuming the first letter (e.g.
|
|
|
|
|
;; `func-or-shortcut' is a function, meaning we put
|
|
|
|
|
;; braces around the first letter of `str')
|
|
|
|
|
(if (stringp func-or-shortcut)
|
|
|
|
|
(length newstr)
|
|
|
|
|
(- (length newstr) 1))
|
|
|
|
|
'mouse-face 'highlight newstr)
|
2017-05-06 11:57:09 +02:00
|
|
|
|
newstr))
|
2011-12-25 12:38:44 +01:00
|
|
|
|
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(defun mu4e--longest-of-maildirs-and-bookmarks ()
|
|
|
|
|
"Return the length of longest name of bookmarks and maildirs."
|
|
|
|
|
(cl-loop for b in (append (mu4e-bookmarks)
|
|
|
|
|
(mu4e--maildirs-with-query))
|
|
|
|
|
maximize (string-width (plist-get b :name))))
|
|
|
|
|
|
2022-12-30 22:30:45 +01:00
|
|
|
|
(defun mu4e--main-item (fullkey name qcounts max-length)
|
2022-12-31 16:47:33 +01:00
|
|
|
|
"Display a main-view bookmarks/maildir item.
|
2022-12-30 22:30:45 +01:00
|
|
|
|
- FULLKEY is a 2-character string describing the item's shortcut
|
|
|
|
|
- NAME is the name of the of the item
|
|
|
|
|
- QCOUNTS is a structure with unread information
|
|
|
|
|
for this item (or nil)
|
|
|
|
|
- MAX-LENGTH is the maximum length for an item name
|
|
|
|
|
(used for alignment)."
|
|
|
|
|
(concat
|
|
|
|
|
(mu4e--main-action-str
|
|
|
|
|
(concat "\t* [" fullkey "] " name) fullkey)
|
|
|
|
|
;; append all/unread numbers, if available.
|
|
|
|
|
(if qcounts
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(let* ((unread (plist-get qcounts :unread))
|
|
|
|
|
(count (plist-get qcounts :count))
|
|
|
|
|
(baseline (plist-get qcounts :baseline))
|
|
|
|
|
(baseline-unread
|
|
|
|
|
(or (when baseline (plist-get baseline :unread)) unread))
|
|
|
|
|
(delta (- unread baseline-unread)))
|
|
|
|
|
(format"%s (%s%s/%s)"
|
|
|
|
|
(make-string (- max-length (string-width name)) ? )
|
|
|
|
|
(propertize
|
|
|
|
|
(number-to-string unread) 'face 'mu4e-header-key-face
|
|
|
|
|
'help-echo "Number of unread messages")
|
|
|
|
|
(if (not mu4e-main-hide-baseline-delta)
|
|
|
|
|
(propertize (format "/%+d" delta) 'face
|
|
|
|
|
(if (> delta 0) 'mu4e-unread-face 'default)
|
|
|
|
|
'help-echo "Unread messsages baseline-delta")
|
|
|
|
|
"")
|
|
|
|
|
(propertize (number-to-string count)
|
|
|
|
|
'help-echo "Total number of messages")))
|
2022-12-30 22:30:45 +01:00
|
|
|
|
"") "\n"))
|
|
|
|
|
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(defun mu4e--main-items (shortcut items max-length)
|
2022-12-30 22:30:45 +01:00
|
|
|
|
"Display the entries for the bookmark/maildir menu.
|
|
|
|
|
- SHORTCUT is a single character which is the first
|
|
|
|
|
character of the keyboard shortcut
|
|
|
|
|
- ITEMS is a list of items, for format see `(mu4e-bookmarks)'.
|
|
|
|
|
- MAX-LENGTH is the maximum length for an item name
|
|
|
|
|
(used for alignment)."
|
|
|
|
|
(cl-loop for item in items
|
|
|
|
|
for fullkey = (format "%c%c" shortcut (plist-get item :key))
|
|
|
|
|
for name = (plist-get item :name)
|
2021-10-31 10:26:58 +01:00
|
|
|
|
for query = (funcall (or mu4e-query-rewrite-function #'identity)
|
2022-12-30 22:30:45 +01:00
|
|
|
|
(plist-get item :query))
|
2022-12-31 16:47:33 +01:00
|
|
|
|
for qcounts = (mu4e-last-query-result query)
|
2020-05-27 16:27:00 +02:00
|
|
|
|
for unread = (and qcounts (plist-get (car qcounts) :unread))
|
2022-12-30 22:30:45 +01:00
|
|
|
|
when (not (plist-get item :hide))
|
2020-05-27 16:27:00 +02:00
|
|
|
|
when (not (and mu4e-main-hide-fully-read (eq unread 0)))
|
2022-12-30 22:30:45 +01:00
|
|
|
|
concat (mu4e--main-item fullkey name qcounts max-length)))
|
2020-02-24 22:32:52 +01:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--key-val (key val &optional unit)
|
|
|
|
|
"Show a KEY / VAL pair, with optional UNIT."
|
2020-02-06 19:28:24 +01:00
|
|
|
|
(concat
|
2020-05-08 18:24:31 +02:00
|
|
|
|
"\t* "
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(propertize (format "%-20s" key) 'face 'mu4e-header-title-face)
|
|
|
|
|
": "
|
|
|
|
|
(propertize val 'face 'mu4e-header-key-face)
|
|
|
|
|
(if unit
|
|
|
|
|
(propertize (concat " " unit) 'face 'mu4e-header-title-face)
|
2022-12-30 22:30:45 +01:00
|
|
|
|
"") "\n"))
|
2020-02-06 19:28:24 +01:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
;; NEW This is the old `mu4e--main-view' function but without
|
2014-05-21 20:38:19 +02:00
|
|
|
|
;; buffer switching at the end.
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-view-real (_ignore-auto _noconfirm)
|
2020-02-21 08:33:07 +01:00
|
|
|
|
"The revert buffer function for `mu4e-main-mode'."
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-view-real-1 'refresh))
|
2020-02-21 08:33:07 +01:00
|
|
|
|
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(declare-function mu4e--start "mu4e")
|
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-view-real-1 (&optional refresh)
|
2020-02-28 11:17:13 +01:00
|
|
|
|
"Create `mu4e-main-buffer-name' and set it up.
|
2020-02-21 08:33:07 +01:00
|
|
|
|
When REFRESH is non nil refresh infos from server."
|
2020-05-28 09:21:16 +02:00
|
|
|
|
(let ((inhibit-read-only t))
|
2020-02-21 08:33:07 +01:00
|
|
|
|
;; Maybe refresh infos from server.
|
|
|
|
|
(if refresh
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--start 'mu4e--main-redraw-buffer)
|
|
|
|
|
(mu4e--main-redraw-buffer))))
|
2020-02-21 08:33:07 +01:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-redraw-buffer ()
|
2022-07-06 23:52:32 +02:00
|
|
|
|
"Redraw the main buffer."
|
2020-02-28 11:17:13 +01:00
|
|
|
|
(with-current-buffer mu4e-main-buffer-name
|
2020-02-21 08:33:07 +01:00
|
|
|
|
(let ((inhibit-read-only t)
|
2020-04-06 19:49:39 +02:00
|
|
|
|
(pos (point))
|
2022-12-30 22:30:45 +01:00
|
|
|
|
(addrs (mu4e-personal-addresses))
|
|
|
|
|
(max-length (mu4e--longest-of-maildirs-and-bookmarks)))
|
2011-12-13 06:43:49 +01:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert
|
2020-02-11 12:00:46 +01:00
|
|
|
|
"* "
|
|
|
|
|
(propertize "mu4e" 'face 'mu4e-header-key-face)
|
|
|
|
|
(propertize " - mu for emacs version " 'face 'mu4e-title-face)
|
|
|
|
|
(propertize mu4e-mu-version 'face 'mu4e-header-key-face)
|
2020-12-06 12:03:18 +01:00
|
|
|
|
"\n\n"
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(propertize " Basics\n\n" 'face 'mu4e-title-face)
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-action-str
|
2022-01-29 18:53:37 +01:00
|
|
|
|
"\t* [j]ump to some maildir\n" #'mu4e~headers-jump-to-maildir)
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-action-str
|
2022-01-29 18:53:37 +01:00
|
|
|
|
"\t* enter a [s]earch query\n" #'mu4e-search)
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-action-str
|
2022-01-29 18:53:37 +01:00
|
|
|
|
"\t* [C]ompose a new message\n" #'mu4e-compose-new)
|
2020-02-11 12:00:46 +01:00
|
|
|
|
"\n"
|
|
|
|
|
(propertize " Bookmarks\n\n" 'face 'mu4e-title-face)
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(mu4e--main-items ?b (mu4e-bookmarks) max-length)
|
2020-02-11 12:00:46 +01:00
|
|
|
|
"\n"
|
2020-02-24 22:32:52 +01:00
|
|
|
|
(propertize " Maildirs\n\n" 'face 'mu4e-title-face)
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(mu4e--main-items ?j (mu4e--maildirs-with-query) max-length)
|
2020-02-24 22:32:52 +01:00
|
|
|
|
"\n"
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(propertize " Misc\n\n" 'face 'mu4e-title-face)
|
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-action-str "\t* [;]Switch context\n"
|
|
|
|
|
(lambda()(interactive)
|
2022-12-13 08:36:16 +01:00
|
|
|
|
(mu4e-context-switch)(revert-buffer)))
|
2020-02-11 12:00:46 +01:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-action-str "\t* [U]pdate email & database\n"
|
2022-12-31 16:47:33 +01:00
|
|
|
|
#'mu4e-update-mail-and-index)
|
|
|
|
|
(mu4e--main-action-str "\t* [R]eset query-results baseline\n"
|
|
|
|
|
#'mu4e--main-reset-baseline-query-results)
|
2020-02-11 12:00:46 +01:00
|
|
|
|
|
|
|
|
|
;; show the queue functions if `smtpmail-queue-dir' is defined
|
|
|
|
|
(if (file-directory-p smtpmail-queue-dir)
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-view-queue)
|
2020-02-11 12:00:46 +01:00
|
|
|
|
"")
|
|
|
|
|
"\n"
|
2022-01-29 18:53:37 +01:00
|
|
|
|
(mu4e--main-action-str "\t* [N]ews\n" #'mu4e-news)
|
|
|
|
|
(mu4e--main-action-str "\t* [A]bout mu4e\n" #'mu4e-about)
|
|
|
|
|
(mu4e--main-action-str "\t* [H]elp\n" #'mu4e-display-manual)
|
|
|
|
|
(mu4e--main-action-str "\t* [q]uit\n" #'mu4e-quit)
|
2020-02-11 12:00:46 +01:00
|
|
|
|
|
|
|
|
|
"\n"
|
|
|
|
|
(propertize " Info\n\n" 'face 'mu4e-title-face)
|
2022-12-30 22:30:45 +01:00
|
|
|
|
(mu4e--key-val "last updated"
|
|
|
|
|
(current-time-string
|
|
|
|
|
(plist-get mu4e-index-update-status :tstamp)))
|
2022-12-31 16:47:33 +01:00
|
|
|
|
(if (and (not mu4e-main-hide-baseline-delta)
|
|
|
|
|
mu4e--baseline-query-results-tstamp)
|
|
|
|
|
(mu4e--key-val "baseline"
|
|
|
|
|
(current-time-string mu4e--baseline-query-results-tstamp))
|
|
|
|
|
"")
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--key-val "database-path" (mu4e-database-path))
|
|
|
|
|
(mu4e--key-val "maildir" (mu4e-root-maildir))
|
|
|
|
|
(mu4e--key-val "in store"
|
|
|
|
|
(format "%d" (plist-get mu4e--server-props :doccount))
|
2022-12-13 08:36:16 +01:00
|
|
|
|
"messages")
|
2021-01-03 13:57:41 +01:00
|
|
|
|
(if mu4e-main-hide-personal-addresses ""
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--key-val "personal addresses"
|
2022-12-13 08:36:16 +01:00
|
|
|
|
(if addrs (mapconcat #'identity addrs ", " ) "none"))))
|
2020-04-06 19:49:39 +02:00
|
|
|
|
|
2021-01-03 13:57:41 +01:00
|
|
|
|
(if mu4e-main-hide-personal-addresses ""
|
2020-10-17 09:14:04 +02:00
|
|
|
|
(unless (mu4e-personal-address-p user-mail-address)
|
2020-04-06 19:49:39 +02:00
|
|
|
|
(mu4e-message (concat
|
2020-10-17 09:14:04 +02:00
|
|
|
|
"Tip: `user-mail-address' ('%s') is not part "
|
|
|
|
|
"of mu's addresses; add it with 'mu init
|
|
|
|
|
--my-address='") user-mail-address)))
|
2020-02-21 08:33:07 +01:00
|
|
|
|
(mu4e-main-mode)
|
|
|
|
|
(goto-char pos))))
|
2014-05-21 20:38:19 +02:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-view-queue ()
|
2015-01-19 10:36:55 +01:00
|
|
|
|
"Display queue-related actions in the main view."
|
|
|
|
|
(concat
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-action-str "\t* toggle [m]ail sending mode "
|
|
|
|
|
'mu4e--main-toggle-mail-sending-mode)
|
2020-02-11 12:00:46 +01:00
|
|
|
|
"(currently "
|
|
|
|
|
(propertize (if smtpmail-queue-mail "queued" "direct")
|
|
|
|
|
'face 'mu4e-header-key-face)
|
|
|
|
|
")\n"
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(let ((queue-size (mu4e--main-queue-size)))
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(if (zerop queue-size)
|
|
|
|
|
""
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(mu4e--main-action-str
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(format "\t* [f]lush %s queued %s\n"
|
|
|
|
|
(propertize (int-to-string queue-size)
|
|
|
|
|
'face 'mu4e-header-key-face)
|
|
|
|
|
(if (> queue-size 1) "mails" "mail"))
|
|
|
|
|
'smtpmail-send-queued-mail)))))
|
2015-01-19 10:36:55 +01:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-queue-size ()
|
2015-01-19 10:36:55 +01:00
|
|
|
|
"Return, as an int, the number of emails in the queue."
|
|
|
|
|
(condition-case nil
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents (expand-file-name smtpmail-queue-index-file
|
|
|
|
|
smtpmail-queue-dir))
|
|
|
|
|
(count-lines (point-min) (point-max)))
|
2015-01-19 10:36:55 +01:00
|
|
|
|
(error 0)))
|
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-view (&optional refresh)
|
2022-12-28 23:23:32 +01:00
|
|
|
|
"Create the mu4e main-view, and switch to it or show the menu.
|
|
|
|
|
When REFRESH is non nil refresh infos from server.
|
|
|
|
|
|
2022-12-29 07:43:42 +01:00
|
|
|
|
If `mu4e-split-view' equals \='single-window, show a mu4e menu
|
2022-12-28 23:23:32 +01:00
|
|
|
|
instead."
|
|
|
|
|
(if (eq mu4e-split-view 'single-window)
|
|
|
|
|
(mu4e--main-menu)
|
|
|
|
|
(let ((buf (get-buffer-create mu4e-main-buffer-name)))
|
|
|
|
|
;; `mu4e--main-view' is called from `mu4e--start', so don't call it
|
|
|
|
|
;; a second time here i.e. do not refresh unless specified
|
|
|
|
|
;; explicitly with REFRESH arg.
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(mu4e--main-view-real-1 refresh))
|
|
|
|
|
(mu4e-display-buffer buf t)
|
|
|
|
|
(goto-char (point-min)))))
|
2020-02-21 08:33:07 +01:00
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; Interactive functions
|
|
|
|
|
;; NEW
|
|
|
|
|
;; Toggle mail sending mode without switching
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-toggle-mail-sending-mode ()
|
2014-05-21 21:33:02 +02:00
|
|
|
|
"Toggle sending mail mode, either queued or direct."
|
2011-12-04 22:49:15 +01:00
|
|
|
|
(interactive)
|
2017-05-18 03:42:52 +02:00
|
|
|
|
(unless (file-directory-p smtpmail-queue-dir)
|
|
|
|
|
(mu4e-error "`smtpmail-queue-dir' does not exist"))
|
|
|
|
|
(setq smtpmail-queue-mail (not smtpmail-queue-mail))
|
|
|
|
|
(message (concat "Outgoing mail will now be "
|
2020-02-11 12:00:46 +01:00
|
|
|
|
(if smtpmail-queue-mail "queued" "sent directly")))
|
2020-02-21 08:33:07 +01:00
|
|
|
|
(unless (or (eq mu4e-split-view 'single-window)
|
2020-02-28 11:17:13 +01:00
|
|
|
|
(not (buffer-live-p (get-buffer mu4e-main-buffer-name))))
|
|
|
|
|
(with-current-buffer mu4e-main-buffer-name
|
2020-02-21 08:33:07 +01:00
|
|
|
|
(revert-buffer))))
|
2017-05-18 03:42:52 +02:00
|
|
|
|
|
2022-01-23 09:29:45 +01:00
|
|
|
|
(defun mu4e--main-menu ()
|
2022-07-06 23:52:32 +02:00
|
|
|
|
"The mu4e main menu in the mini-buffer."
|
|
|
|
|
(let ((func (mu4e-read-option
|
2022-12-13 08:36:16 +01:00
|
|
|
|
"Do: "
|
|
|
|
|
'(("jump" . mu4e~headers-jump-to-maildir)
|
|
|
|
|
("search" . mu4e-search)
|
|
|
|
|
("Compose" . mu4e-compose-new)
|
|
|
|
|
("bookmarks" . mu4e-headers-search-bookmark)
|
|
|
|
|
(";Switch context" . mu4e-context-switch)
|
|
|
|
|
("Update" . mu4e-update-mail-and-index)
|
|
|
|
|
("News" . mu4e-news)
|
|
|
|
|
("About" . mu4e-about)
|
|
|
|
|
("Help " . mu4e-display-manual)))))
|
2022-07-06 23:52:32 +02:00
|
|
|
|
(call-interactively func)
|
|
|
|
|
(when (eq func 'mu4e-context-switch)
|
|
|
|
|
(sit-for 1)
|
|
|
|
|
(mu4e--main-menu))))
|
|
|
|
|
|
2022-09-04 23:54:24 +02:00
|
|
|
|
(defun mu4e--main-update-after-index ()
|
|
|
|
|
"Update the main view buffer after indexing."
|
2022-11-18 13:54:27 +01:00
|
|
|
|
(when (buffer-live-p mu4e-main-buffer-name)
|
|
|
|
|
(with-current-buffer mu4e-main-buffer-name
|
|
|
|
|
(revert-buffer))))
|
2022-09-04 23:54:24 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(provide 'mu4e-main)
|
2020-02-11 12:38:01 +01:00
|
|
|
|
;;; mu4e-main.el ends here
|