mu/mu4e: implement mu4e-compose-complete-max

Allow limiting number of contacts for auto-completion to a specific number;
defaulting to 2000.
This commit is contained in:
Dirk-Jan C. Binnema
2022-05-06 21:58:51 +03:00
parent ffce3dda21
commit 836bfc9062
5 changed files with 35 additions and 12 deletions

View File

@ -56,6 +56,17 @@ time-based restriction."
:type 'string
:group 'mu4e-compose)
(defcustom mu4e-compose-complete-max 2000
"Consider only the top-n contacts.
After considering the other
constraints (`mu4e-compose-complete-addresses' and
`mu4e-compose-complete-only-after'), pick only the highest-ranked n.
This reduce start-up time and memory usage. Set to nil for no
limits."
:type 'string
:group 'mu4e-compose)
;; names and mail-addresses can be mapped onto their canonical
;; counterpart. use the customizeable function
;; mu4e-canonical-contact-function to do that. below the identity
@ -293,6 +304,7 @@ nothing."
(mu4e--server-contacts
mu4e-compose-complete-only-personal
mu4e-compose-complete-only-after
mu4e-compose-complete-max
mu4e--contacts-tstamp)))
(provide 'mu4e-contacts)

View File

@ -441,17 +441,21 @@ The result is delivered to the function registered as
:decrypt ,(and decrypt t)
:docid ,docid)))
(defun mu4e--server-contacts (personal after tstamp)
"Ask for contacts with PERSONAL AFTER TSTAMP.
S-expression (:contacts (<list>) :tstamp \"<tstamp>\") is expected in
response. If PERSONAL is non-nil, only get personal contacts, if
AFTER is non-nil, get only contacts seen AFTER (the time_t
value)."
(defun mu4e--server-contacts (personal after maxnum tstamp)
"Ask for contacts with PERSONAL AFTER MAXNUM TSTAMP.
S-expression (:contacts (<list>) :tstamp \"<tstamp>\")
is expected in response.
If PERSONAL is non-nil, only get personal contacts, if AFTER is
non-nil, get only contacts seen AFTER (the time_t value). If MAX is non-nil,
get at most MAX contacts."
(mu4e--server-call-mu
`(contacts
:personal ,(and personal t)
:after ,(or after nil)
:tstamp ,(or tstamp nil))))
:tstamp ,(or tstamp nil)
:maxnum ,(or maxnum nil))))
(defun mu4e--server-find (query threads sortfield sortdir maxnum skip-dups
include-related)