mu4e: show short counts next to maildir/bookmark entry
When you ask for bookmarks or maildirs through mu4e-ask-bookmark, mu4e-ask-maildir, the counts are displayed in the (default) completions next to the maildirs. This is a shorter version of the full display, just showing either the delta or the number of unread messages, if any. If you don't want to see these counts, there is mu4e-hide-short-counts.
This commit is contained in:
5
NEWS.org
5
NEWS.org
@ -66,6 +66,11 @@
|
|||||||
server interpreted the last query; this can be useful if you don't get the
|
server interpreted the last query; this can be useful if you don't get the
|
||||||
result you expected.
|
result you expected.
|
||||||
|
|
||||||
|
- When you ask for bookmarks or maildirs through ~mu4e-ask-bookmark~ or
|
||||||
|
~mu4e-ask-maildir~, unread counts are displayed in the (default) completions UI
|
||||||
|
next to the maildir or bookmark. If you don't want to see these counts, set
|
||||||
|
~mu4e-hide-short-counts~ to non-~nil~.
|
||||||
|
|
||||||
* 1.12 (released on February 24, 2024)
|
* 1.12 (released on February 24, 2024)
|
||||||
|
|
||||||
** Some highlights
|
** Some highlights
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
;;; mu4e-bookmarks.el --- Bookmarks handling -*- lexical-binding: t -*-
|
;;; mu4e-bookmarks.el --- Bookmarks handling -*- lexical-binding: t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2011-2023 Dirk-Jan C. Binnema
|
;; Copyright (C) 2011-2025 Dirk-Jan C. Binnema
|
||||||
|
|
||||||
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
@ -28,7 +28,6 @@
|
|||||||
(require 'mu4e-folders)
|
(require 'mu4e-folders)
|
||||||
(require 'mu4e-query-items)
|
(require 'mu4e-query-items)
|
||||||
|
|
||||||
|
|
||||||
;;; Configuration
|
;;; Configuration
|
||||||
|
|
||||||
(defgroup mu4e-bookmarks nil
|
(defgroup mu4e-bookmarks nil
|
||||||
@ -79,19 +78,33 @@ query."
|
|||||||
:type '(repeat (plist))
|
:type '(repeat (plist))
|
||||||
:group 'mu4e-bookmarks)
|
:group 'mu4e-bookmarks)
|
||||||
|
|
||||||
|
(declare-function mu4e-query-items "mu4e-query-items")
|
||||||
|
(declare-function mu4e--query-item-display-short-counts "mu4e-query-items")
|
||||||
|
|
||||||
(defun mu4e-ask-bookmark (prompt)
|
(defun mu4e-ask-bookmark (prompt)
|
||||||
"Ask user for bookmark using PROMPT.
|
"Ask user for bookmark using PROMPT.
|
||||||
Return the corresponding query. The bookmark are as defined in
|
Return the corresponding query. The bookmark are as defined in
|
||||||
`mu4e-bookmarks'."
|
`mu4e-bookmarks'.
|
||||||
|
|
||||||
|
The names of the bookmarks are displayed in the minibuffer,
|
||||||
|
suffixed with the short version of the unread counts, as per
|
||||||
|
`mu4e--query-item-display-short-counts'."
|
||||||
(unless (mu4e-bookmarks) (mu4e-error "No bookmarks defined"))
|
(unless (mu4e-bookmarks) (mu4e-error "No bookmarks defined"))
|
||||||
(let* ((bmarks (seq-map (lambda (bm)
|
(let* ((bmarks
|
||||||
(cons (format "%c%s"
|
(seq-map
|
||||||
(plist-get bm :key)
|
(lambda (bm) ;; find query-item for bookmark
|
||||||
(plist-get bm :name))
|
(let* ((qitem (seq-find
|
||||||
(plist-get bm :query)))
|
(lambda (qitem)
|
||||||
(mu4e-filter-single-key (mu4e-bookmarks)))))
|
(equal (plist-get bm :query) (plist-get qitem :query)))
|
||||||
(mu4e-read-option prompt bmarks)))
|
(mu4e-query-items 'bookmarks)))
|
||||||
|
(unreads (mu4e--query-item-display-short-counts qitem)))
|
||||||
|
(cons (format "%c%s%s"
|
||||||
|
(plist-get bm :key)
|
||||||
|
(plist-get bm :name)
|
||||||
|
unreads)
|
||||||
|
(plist-get bm :query))))
|
||||||
|
(mu4e-filter-single-key (mu4e-bookmarks)))))
|
||||||
|
(mu4e-read-option prompt bmarks)))
|
||||||
|
|
||||||
(defun mu4e-get-bookmark-query (kar)
|
(defun mu4e-get-bookmark-query (kar)
|
||||||
"Get the corresponding bookmarked query for shortcut KAR.
|
"Get the corresponding bookmarked query for shortcut KAR.
|
||||||
@ -190,6 +203,5 @@ one, creates a propertized string for display in the modeline."
|
|||||||
(mouse-1 . mu4e-jump-to-favorite)
|
(mouse-1 . mu4e-jump-to-favorite)
|
||||||
(mouse-2 . mu4e-jump-to-favorite)
|
(mouse-2 . mu4e-jump-to-favorite)
|
||||||
(mouse-3 . mu4e-jump-to-favorite))))))
|
(mouse-3 . mu4e-jump-to-favorite))))))
|
||||||
|
|
||||||
(provide 'mu4e-bookmarks)
|
(provide 'mu4e-bookmarks)
|
||||||
;;; mu4e-bookmarks.el ends here
|
;;; mu4e-bookmarks.el ends here
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
;;; mu4e-context.el --- Switching between settings -*- lexical-binding: t -*-
|
;;; mu4e-context.el --- Switching between settings -*- lexical-binding: t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2015-2023 Dirk-Jan C. Binnema
|
;; Copyright (C) 2015-2025 Dirk-Jan C. Binnema
|
||||||
|
|
||||||
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
@ -87,6 +87,9 @@ none."
|
|||||||
(cl-defstruct mu4e-context
|
(cl-defstruct mu4e-context
|
||||||
"A mu4e context object with the following members:
|
"A mu4e context object with the following members:
|
||||||
- `name': the name of the context, eg. \"Work\" or \"Private\".
|
- `name': the name of the context, eg. \"Work\" or \"Private\".
|
||||||
|
When using mu4e's default completion, it uses the first letter of
|
||||||
|
the name for this, so you should ensure those are different for
|
||||||
|
all contexts.
|
||||||
- `enter-func': a parameterless function invoked when entering
|
- `enter-func': a parameterless function invoked when entering
|
||||||
this context, or nil
|
this context, or nil
|
||||||
- `leave-func':a parameterless function invoked when leaving this
|
- `leave-func':a parameterless function invoked when leaving this
|
||||||
@ -104,7 +107,6 @@ none."
|
|||||||
;; if it matches, nil otherwise
|
;; if it matches, nil otherwise
|
||||||
vars) ;; alist of variables.
|
vars) ;; alist of variables.
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e--context-ask-user (prompt)
|
(defun mu4e--context-ask-user (prompt)
|
||||||
"Let user choose some context based on its name with PROMPT."
|
"Let user choose some context based on its name with PROMPT."
|
||||||
(when mu4e-contexts
|
(when mu4e-contexts
|
||||||
@ -168,7 +170,7 @@ match, return the first. For MSG and POLICY, see
|
|||||||
nil (mu4e-context-name context))))))
|
nil (mu4e-context-name context))))))
|
||||||
|
|
||||||
(defun mu4e-context-determine (msg &optional policy)
|
(defun mu4e-context-determine (msg &optional policy)
|
||||||
"Return the first context where match-func evaluate to non-nil.
|
"Return first context for which match-func returns non-nil.
|
||||||
|
|
||||||
MSG points to the plist for the message replied to or forwarded,
|
MSG points to the plist for the message replied to or forwarded,
|
||||||
or nil if there is no such MSG; similar to what
|
or nil if there is no such MSG; similar to what
|
||||||
|
|||||||
@ -177,6 +177,16 @@ Converts from the old format if needed."
|
|||||||
item))
|
item))
|
||||||
mu4e-maildir-shortcuts))
|
mu4e-maildir-shortcuts))
|
||||||
|
|
||||||
|
(declare-function mu4e-query-items "mu4e-query-items")
|
||||||
|
(declare-function mu4e--query-item-display-short-counts "mu4e-query-items")
|
||||||
|
|
||||||
|
(defun mu4e--query-item-for-maildir-shortcut (mds)
|
||||||
|
"Find the corresponding query-item for some maildir shortcut MDS.
|
||||||
|
This is based on their query. Return nil if not found."
|
||||||
|
(seq-find (lambda (qitem)
|
||||||
|
(equal (plist-get qitem :maildir) (plist-get mds :maildir)))
|
||||||
|
(mu4e-query-items 'maildirs)))
|
||||||
|
|
||||||
;; the standard folders can be functions too
|
;; the standard folders can be functions too
|
||||||
(defun mu4e--get-folder (foldervar msg)
|
(defun mu4e--get-folder (foldervar msg)
|
||||||
"Within the mu-context of MSG, get message folder FOLDERVAR.
|
"Within the mu-context of MSG, get message folder FOLDERVAR.
|
||||||
@ -231,7 +241,7 @@ to create it; otherwise return nil."
|
|||||||
(let ((seems-to-exist (file-directory-p dir)))
|
(let ((seems-to-exist (file-directory-p dir)))
|
||||||
(when (or seems-to-exist
|
(when (or seems-to-exist
|
||||||
(yes-or-no-p (mu4e-format "%s does not exist yet. Create now?" dir)))
|
(yes-or-no-p (mu4e-format "%s does not exist yet. Create now?" dir)))
|
||||||
;; even when the maildir already seems to exist, call mkdir for a deeper
|
;; even when the maildir already seems to exist, call mkdir for a deepe
|
||||||
;; check. However only get an update when the maildir is totally new.
|
;; check. However only get an update when the maildir is totally new.
|
||||||
(mu4e--server-mkdir dir (not seems-to-exist))
|
(mu4e--server-mkdir dir (not seems-to-exist))
|
||||||
t)))
|
t)))
|
||||||
@ -245,14 +255,23 @@ to create it; otherwise return nil."
|
|||||||
|
|
||||||
If the special shortcut \"o\" (for _o_ther) is used, or
|
If the special shortcut \"o\" (for _o_ther) is used, or
|
||||||
if (mu4e-maildir-shortcuts) evaluates to nil, let user choose
|
if (mu4e-maildir-shortcuts) evaluates to nil, let user choose
|
||||||
from all maildirs under `mu4e-maildir'."
|
from all maildirs under `mu4e-maildir'.
|
||||||
|
|
||||||
|
The names of the maildirs are displayed in the minibuffer,
|
||||||
|
suffixed with the short version of the unread counts, as per
|
||||||
|
`mu4e--query-item-display-short-counts'."
|
||||||
(let* ((options
|
(let* ((options
|
||||||
(seq-map (lambda (md)
|
(seq-map
|
||||||
(cons
|
(lambda (md)
|
||||||
(format "%c%s" (plist-get md :key)
|
(let* ((qitem (mu4e--query-item-for-maildir-shortcut md))
|
||||||
(or (plist-get md :name)
|
(unreads (mu4e--query-item-display-short-counts qitem)))
|
||||||
(plist-get md :maildir)))
|
(cons
|
||||||
(plist-get md :maildir)))
|
(format "%c%s%s"
|
||||||
|
(plist-get md :key)
|
||||||
|
(or (plist-get md :name)
|
||||||
|
(plist-get md :maildir))
|
||||||
|
unreads)
|
||||||
|
(plist-get md :maildir))))
|
||||||
(mu4e-filter-single-key (mu4e-maildir-shortcuts))))
|
(mu4e-filter-single-key (mu4e-maildir-shortcuts))))
|
||||||
(response
|
(response
|
||||||
(if (not options)
|
(if (not options)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
;;; mu4e-query-items.el --- Manage query results -*- lexical-binding: t -*-
|
;;; mu4e-query-items.el --- Manage query results -*- lexical-binding: t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2023-2024 Dirk-Jan C. Binnema
|
;; Copyright (C) 2023-2025 Dirk-Jan C. Binnema
|
||||||
|
|
||||||
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
@ -61,6 +61,12 @@ incorrect results for the various unread counts."
|
|||||||
:type 'function
|
:type 'function
|
||||||
:group 'mu4e-search)
|
:group 'mu4e-search)
|
||||||
|
|
||||||
|
(defcustom mu4e-hide-short-counts nil
|
||||||
|
"Hide the short count of unread messages.
|
||||||
|
As used in `mu4e-ask-bookmark' and `mu4e-ask-folder'."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'mu4e)
|
||||||
|
|
||||||
(defvar mu4e--query-items-baseline nil
|
(defvar mu4e--query-items-baseline nil
|
||||||
"Some previous version of the query-items.
|
"Some previous version of the query-items.
|
||||||
This is used as the baseline to track updates by comparing it to
|
This is used as the baseline to track updates by comparing it to
|
||||||
@ -98,7 +104,9 @@ If ITEMS does not yet have a favorite item, pick the first."
|
|||||||
(declare-function mu4e-maildir-shortcuts "mu4e-folders")
|
(declare-function mu4e-maildir-shortcuts "mu4e-folders")
|
||||||
|
|
||||||
(defun mu4e--query-item-display-counts (item)
|
(defun mu4e--query-item-display-counts (item)
|
||||||
"Get the count display string for some query-data ITEM."
|
"Get the count display string for some query-data ITEM.
|
||||||
|
If the items has its `:hide-unread' at a non-nil value, return
|
||||||
|
an empty string."
|
||||||
;; purely for display, but we need it in the main menu, modeline
|
;; purely for display, but we need it in the main menu, modeline
|
||||||
;; so let's keep it consistent.
|
;; so let's keep it consistent.
|
||||||
(cl-destructuring-bind (&key unread hide-unread delta-unread count
|
(cl-destructuring-bind (&key unread hide-unread delta-unread count
|
||||||
@ -116,6 +124,25 @@ If ITEMS does not yet have a favorite item, pick the first."
|
|||||||
(propertize (number-to-string count)
|
(propertize (number-to-string count)
|
||||||
'help-echo "Total number")))))
|
'help-echo "Total number")))))
|
||||||
|
|
||||||
|
(defun mu4e--query-item-display-short-counts (item)
|
||||||
|
"Get the short count display string for some query-data ITEM.
|
||||||
|
This gets the delta if it is greater than zero. Otherwise, the
|
||||||
|
total unread count if is greater than zero. Otherwise, an empty
|
||||||
|
string.
|
||||||
|
|
||||||
|
If the items has its `:hide-unread' at a non-nil value, or if
|
||||||
|
`mu4e-hide-short-counts' is non-nil, returns an empty string."
|
||||||
|
(cl-destructuring-bind (&key unread hide-unread delta-unread
|
||||||
|
&allow-other-keys) item
|
||||||
|
(if (or hide-unread mu4e-hide-short-counts)
|
||||||
|
""
|
||||||
|
(concat
|
||||||
|
(if (> (or delta-unread 0) 0)
|
||||||
|
(concat "(" (propertize (format "+%d" delta-unread) 'face 'mu4e-unread-face) ")")
|
||||||
|
(if (> (or unread 0) 0)
|
||||||
|
(concat "(" (propertize (format "%d" unread) 'face 'mu4e-header-key-face) ")")
|
||||||
|
""))))))
|
||||||
|
|
||||||
(defun mu4e--query-items-refresh (&optional reset-baseline)
|
(defun mu4e--query-items-refresh (&optional reset-baseline)
|
||||||
"Get the latest query data from the mu4e server.
|
"Get the latest query data from the mu4e server.
|
||||||
With RESET-BASELINE, reset the baseline first."
|
With RESET-BASELINE, reset the baseline first."
|
||||||
@ -210,7 +237,8 @@ bookmark or maildir."
|
|||||||
;; useful for debugging.
|
;; useful for debugging.
|
||||||
(unless (string= query effective-query)
|
(unless (string= query effective-query)
|
||||||
(plist-put value :effective-query effective-query))
|
(plist-put value :effective-query effective-query))
|
||||||
|
;;for matching maildir shortcuts
|
||||||
|
(when maildir (plist-put value :maildir maildir))
|
||||||
;; nil props bring me discomfort
|
;; nil props bring me discomfort
|
||||||
(when (plist-get item :favorite)
|
(when (plist-get item :favorite)
|
||||||
(plist-put value :favorite t))
|
(plist-put value :favorite t))
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
;;; mu4e-search.el --- Search-related functions -*- lexical-binding: t -*-
|
;;; mu4e-search.el --- Search-related functions -*- lexical-binding: t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2021,2024 Dirk-Jan C. Binnema
|
;; Copyright (C) 2021-2025 Dirk-Jan C. Binnema
|
||||||
|
|
||||||
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
|
|||||||
@ -847,7 +847,7 @@ attention:
|
|||||||
;; bookmark for message that require quick attention
|
;; bookmark for message that require quick attention
|
||||||
'( :name "Urgent"
|
'( :name "Urgent"
|
||||||
:key ?u
|
:key ?u
|
||||||
:query "maildir:/inbox AND from:boss@@exmaple.com"))
|
:query "maildir:/inbox AND from:boss@@example.com"))
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
Note that @t{mu4e} resets the baseline when you are interacting with it (for
|
Note that @t{mu4e} resets the baseline when you are interacting with it (for
|
||||||
@ -859,6 +859,13 @@ as being a special kind of bookmark query that matches a Maildir. You can
|
|||||||
configure this using the variable @code{mu4e-maildir-shortcuts}; see its
|
configure this using the variable @code{mu4e-maildir-shortcuts}; see its
|
||||||
docstring and @ref{Maildir searches} for more details.
|
docstring and @ref{Maildir searches} for more details.
|
||||||
|
|
||||||
|
When you ask for bookmarks or maildirs through @code{mu4e-ask-bookmark},
|
||||||
|
@code{mu4e-ask-maildir}, the counts are displayed in the (default) completions
|
||||||
|
next to the maildir or bookmark entry. This is a shorter version of the full
|
||||||
|
display, just showing either the delta or the number of unread messages, if any.
|
||||||
|
If you do not want to see these counts, set @t{mu4e-hide-short-counts} to
|
||||||
|
non-@t{nil}.
|
||||||
|
|
||||||
@node Miscellaneous
|
@node Miscellaneous
|
||||||
@section Miscellaneous
|
@section Miscellaneous
|
||||||
|
|
||||||
@ -2610,6 +2617,8 @@ Let's see what's contained in a context. Most of it is optional.
|
|||||||
A @code{mu4e-context} is Lisp object with the following members:
|
A @code{mu4e-context} is Lisp object with the following members:
|
||||||
@itemize
|
@itemize
|
||||||
@item @t{name}: the name of the context, e.g. @t{work} or @t{private}
|
@item @t{name}: the name of the context, e.g. @t{work} or @t{private}
|
||||||
|
in the default completion UI, @t{mu4e} uses the first letter of the context to
|
||||||
|
select them, so you should ensure all start with a different letter
|
||||||
@item @t{vars}:
|
@item @t{vars}:
|
||||||
an association-list (alist) of variable settings for this account.
|
an association-list (alist) of variable settings for this account.
|
||||||
@item @t{enter-func}:
|
@item @t{enter-func}:
|
||||||
|
|||||||
Reference in New Issue
Block a user