mu4e: Replace cl with cl-lib

This commit is contained in:
Alex Branham 2018-09-17 19:53:27 -05:00
parent 53c1b0a069
commit 2674ca5583
No known key found for this signature in database
GPG Key ID: 1E4227A253E99AC7
14 changed files with 98 additions and 118 deletions

View File

@ -26,8 +26,7 @@
;; manual) ;; manual)
;;; Code: ;;; Code:
(eval-when-compile (byte-compile-disable-warning 'cl-functions)) (require 'cl-lib)
(require 'cl)
(require 'ido) (require 'ido)
(require 'mu4e-utils) (require 'mu4e-utils)
@ -78,7 +77,7 @@ return the filename."
(let* ((html (mu4e-message-field msg :body-html)) (let* ((html (mu4e-message-field msg :body-html))
(txt (mu4e-message-field msg :body-txt)) (txt (mu4e-message-field msg :body-txt))
(tmpfile (mu4e-make-temp-file "html")) (tmpfile (mu4e-make-temp-file "html"))
(attachments (remove-if (lambda (part) (attachments (cl-remove-if (lambda (part)
(or (null (plist-get part :attachment)) (or (null (plist-get part :attachment))
(null (plist-get part :cid)))) (null (plist-get part :cid))))
(mu4e-message-field msg :parts)))) (mu4e-message-field msg :parts))))

View File

@ -67,10 +67,8 @@
;; ;;
;;; Code: ;;; Code:
(eval-when-compile
(eval-when-compile (byte-compile-disable-warning 'cl-functions)) (require 'cl))
(require 'cl)
(require 'message) (require 'message)
(require 'mail-parse) (require 'mail-parse)
(require 'smtpmail) (require 'smtpmail)
@ -259,7 +257,7 @@ If needed, set the Fcc header, and register the handler function."
(funcall mu4e-sent-messages-behavior) (funcall mu4e-sent-messages-behavior)
mu4e-sent-messages-behavior))) mu4e-sent-messages-behavior)))
(mdir (mdir
(case sent-behavior (cl-case sent-behavior
(delete nil) (delete nil)
(trash (mu4e-get-trash-folder mu4e-compose-parent-message)) (trash (mu4e-get-trash-folder mu4e-compose-parent-message))
(sent (mu4e-get-sent-folder mu4e-compose-parent-message)) (sent (mu4e-get-sent-folder mu4e-compose-parent-message))
@ -536,7 +534,7 @@ buffers; lets remap its faces so it uses the ones for mu4e."
(let* ((subj (message-field-value "subject")) (let* ((subj (message-field-value "subject"))
(subj (unless (and subj (string-match "^[:blank:]*$" subj)) subj)) (subj (unless (and subj (string-match "^[:blank:]*$" subj)) subj))
(str (or subj (str (or subj
(case compose-type (cl-case compose-type
(reply "*reply*") (reply "*reply*")
(forward "*forward*") (forward "*forward*")
(otherwise "*draft*"))))) (otherwise "*draft*")))))
@ -552,19 +550,20 @@ automatically encrypt that reply. When the message is unencrypted,
we can decide what we want to do." we can decide what we want to do."
(if (and (eq compose-type 'reply) (if (and (eq compose-type 'reply)
(and parent (member 'encrypted (mu4e-message-field parent :flags)))) (and parent (member 'encrypted (mu4e-message-field parent :flags))))
(case mu4e-compose-crypto-reply-encrypted-policy (cl-case mu4e-compose-crypto-reply-encrypted-policy
(sign (mml-secure-message-sign)) (sign (mml-secure-message-sign))
(encrypt (mml-secure-message-encrypt)) (encrypt (mml-secure-message-encrypt))
(sign-and-encrypt (mml-secure-message-sign-encrypt)) (sign-and-encrypt (mml-secure-message-sign-encrypt))
(message "Do nothing")) (message "Do nothing"))
(case mu4e-compose-crypto-reply-plain-policy (cl-case mu4e-compose-crypto-reply-plain-policy
(sign (mml-secure-message-sign)) (sign (mml-secure-message-sign))
(encrypt (mml-secure-message-encrypt)) (encrypt (mml-secure-message-encrypt))
(sign-and-encrypt (mml-secure-message-sign-encrypt)) (sign-and-encrypt (mml-secure-message-sign-encrypt))
(message "Do nothing"))) (message "Do nothing")))
) )
(defun* mu4e~compose-handler (compose-type &optional original-msg includes)
(cl-defun mu4e~compose-handler (compose-type &optional original-msg includes)
"Create a new draft message, or open an existing one. "Create a new draft message, or open an existing one.
COMPOSE-TYPE determines the kind of message to compose and is a COMPOSE-TYPE determines the kind of message to compose and is a
@ -601,7 +600,7 @@ tempfile)."
(mu4e-draft-open compose-type original-msg) (mu4e-draft-open compose-type original-msg)
(quit (set-window-configuration winconf) (quit (set-window-configuration winconf)
(mu4e-message "Operation aborted") (mu4e-message "Operation aborted")
(return-from mu4e~compose-handler)))) (cl-return-from mu4e~compose-handler))))
;; insert mail-header-separator, which is needed by message mode to separate ;; insert mail-header-separator, which is needed by message mode to separate
;; headers and body. will be removed before saving to disk ;; headers and body. will be removed before saving to disk
(mu4e~draft-insert-mail-header-separator) (mu4e~draft-insert-mail-header-separator)
@ -624,7 +623,7 @@ tempfile)."
(if (member compose-type '(new forward)) (if (member compose-type '(new forward))
(message-goto-to) (message-goto-to)
;; otherwise, it depends... ;; otherwise, it depends...
(case message-cite-reply-position (cl-case message-cite-reply-position
((above traditional) ((above traditional)
(message-goto-body)) (message-goto-body))
(t (t

View File

@ -24,10 +24,7 @@
;; A mu4e 'context' is a a set of variable-settings and functions, which can be ;; A mu4e 'context' is a a set of variable-settings and functions, which can be
;; used e.g. to switch between accounts. ;; used e.g. to switch between accounts.
(require 'cl-lib)
(eval-when-compile (byte-compile-disable-warning 'cl-functions))
(require 'cl)
(require 'mu4e-utils) (require 'mu4e-utils)
(defvar mu4e-contexts nil "The list of `mu4e-context' objects (defvar mu4e-contexts nil "The list of `mu4e-context' objects
@ -61,7 +58,7 @@ none."
(mu4e-context-name (mu4e-context-current))) (mu4e-context-name (mu4e-context-current)))
'face 'mu4e-context-face) "]") "")) 'face 'mu4e-context-face) "]") ""))
(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\".
- `enter-func': a parameterless function invoked when entering - `enter-func': a parameterless function invoked when entering
@ -83,7 +80,7 @@ none."
(defun mu4e~context-ask-user (prompt) (defun mu4e~context-ask-user (prompt)
"Let user choose some context based on its name." "Let user choose some context based on its name."
(when mu4e-contexts (when mu4e-contexts
(let* ((names (map 'list (lambda (context) (let* ((names (cl-map 'list (lambda (context)
(cons (mu4e-context-name context) context)) (cons (mu4e-context-name context) context))
mu4e-contexts)) mu4e-contexts))
(context (mu4e-read-option prompt names))) (context (mu4e-read-option prompt names)))
@ -99,7 +96,7 @@ non-nil."
(interactive "P") (interactive "P")
(unless mu4e-contexts (unless mu4e-contexts
(mu4e-error "No contexts defined")) (mu4e-error "No contexts defined"))
(let* ((names (map 'list (lambda (context) (let* ((names (cl-map 'list (lambda (context)
(cons (mu4e-context-name context) context)) (cons (mu4e-context-name context) context))
mu4e-contexts)) mu4e-contexts))
(context (context
@ -156,12 +153,12 @@ match, POLICY determines what to do:
(if (eq policy 'always-ask) (if (eq policy 'always-ask)
(mu4e~context-ask-user "Select context: ") (mu4e~context-ask-user "Select context: ")
(or ;; is there a matching one? (or ;; is there a matching one?
(find-if (lambda (context) (cl-find-if (lambda (context)
(when (mu4e-context-match-func context) (when (mu4e-context-match-func context)
(funcall (mu4e-context-match-func context) msg))) (funcall (mu4e-context-match-func context) msg)))
mu4e-contexts) mu4e-contexts)
;; no context found yet; consult policy ;; no context found yet; consult policy
(case policy (cl-case policy
(pick-first (car mu4e-contexts)) (pick-first (car mu4e-contexts))
(ask (mu4e~context-ask-user "Select context: ")) (ask (mu4e~context-ask-user "Select context: "))
(ask-if-none (or (mu4e-context-current) (ask-if-none (or (mu4e-context-current)

View File

@ -25,10 +25,7 @@
;; In this file, various functions to create draft messages ;; In this file, various functions to create draft messages
;; Code ;; Code
(require 'cl-lib)
(eval-when-compile (byte-compile-disable-warning 'cl-functions))
(require 'cl)
(require 'mu4e-vars) (require 'mu4e-vars)
(require 'mu4e-utils) (require 'mu4e-utils)
(require 'mu4e-message) (require 'mu4e-message)
@ -134,7 +131,7 @@ References. If both are empty, return nil."
(refs (if (and msgid (not (string= msgid ""))) (refs (if (and msgid (not (string= msgid "")))
(append refs (list msgid)) refs)) (append refs (list msgid)) refs))
;; no doubles ;; no doubles
(refs (delete-duplicates refs :test #'equal)) (refs (cl-delete-duplicates refs :test #'equal))
(refnum (length refs)) (refnum (length refs))
(cut 2)) (cut 2))
;; remove some refs when there are too many ;; remove some refs when there are too many
@ -179,11 +176,11 @@ Special case: if we were the sender of the original, we simple copy
the list form the original." the list form the original."
(let ((reply-to (let ((reply-to
(or (plist-get origmsg :reply-to) (plist-get origmsg :from)))) (or (plist-get origmsg :reply-to) (plist-get origmsg :from))))
(delete-duplicates reply-to :test #'mu4e~draft-address-cell-equal) (cl-delete-duplicates reply-to :test #'mu4e~draft-address-cell-equal)
(if mu4e-compose-dont-reply-to-self (if mu4e-compose-dont-reply-to-self
(delete-if (cl-delete-if
(lambda (to-cell) (lambda (to-cell)
(member-if (cl-member-if
(lambda (addr) (lambda (addr)
(string= (downcase addr) (downcase (cdr to-cell)))) (string= (downcase addr) (downcase (cdr to-cell))))
mu4e-user-mail-address-list)) mu4e-user-mail-address-list))
@ -198,7 +195,7 @@ the list form the original."
((null mu4e-compose-reply-ignore-address) ((null mu4e-compose-reply-ignore-address)
addrs) addrs)
((functionp mu4e-compose-reply-ignore-address) ((functionp mu4e-compose-reply-ignore-address)
(remove-if (cl-remove-if
(lambda (elt) (lambda (elt)
(funcall mu4e-compose-reply-ignore-address (cdr elt))) (funcall mu4e-compose-reply-ignore-address (cdr elt)))
addrs)) addrs))
@ -209,7 +206,7 @@ the list form the original."
(mapconcat (lambda (elt) (concat "\\(" elt "\\)")) (mapconcat (lambda (elt) (concat "\\(" elt "\\)"))
regexp "\\|") regexp "\\|")
regexp))) regexp)))
(remove-if (cl-remove-if
(lambda (elt) (lambda (elt)
(string-match regexp (cdr elt))) (string-match regexp (cdr elt)))
addrs))))) addrs)))))
@ -220,7 +217,7 @@ the list form the original."
the original message ORIGMSG, and whether it's a reply-all." the original message ORIGMSG, and whether it's a reply-all."
(when reply-all (when reply-all
(let* ((cc-lst ;; get the cc-field from the original, remove dups (let* ((cc-lst ;; get the cc-field from the original, remove dups
(delete-duplicates (cl-delete-duplicates
(append (append
(plist-get origmsg :to) (plist-get origmsg :to)
(plist-get origmsg :cc)) (plist-get origmsg :cc))
@ -228,9 +225,9 @@ the original message ORIGMSG, and whether it's a reply-all."
;; now we have the basic list, but we must remove ;; now we have the basic list, but we must remove
;; addresses also in the to list ;; addresses also in the to list
(cc-lst (cc-lst
(delete-if (cl-delete-if
(lambda (cc-cell) (lambda (cc-cell)
(find-if (cl-find-if
(lambda (to-cell) (lambda (to-cell)
(mu4e~draft-address-cell-equal cc-cell to-cell)) (mu4e~draft-address-cell-equal cc-cell to-cell))
(mu4e~draft-create-to-lst origmsg))) (mu4e~draft-create-to-lst origmsg)))
@ -242,9 +239,9 @@ the original message ORIGMSG, and whether it's a reply-all."
(cc-lst (cc-lst
(if (or mu4e-compose-keep-self-cc (null user-mail-address)) (if (or mu4e-compose-keep-self-cc (null user-mail-address))
cc-lst cc-lst
(delete-if (cl-delete-if
(lambda (cc-cell) (lambda (cc-cell)
(member-if (cl-member-if
(lambda (addr) (lambda (addr)
(string= (downcase addr) (downcase (cdr cc-cell)))) (string= (downcase addr) (downcase (cdr cc-cell))))
mu4e-user-mail-address-list)) mu4e-user-mail-address-list))
@ -257,7 +254,7 @@ symbol, :to or :cc), based on the original message ORIGMSG,
and (optionally) REPLY-ALL which indicates this is a reply-to-all and (optionally) REPLY-ALL which indicates this is a reply-to-all
message. Return nil if there are no recipients for the particular field." message. Return nil if there are no recipients for the particular field."
(mu4e~draft-recipients-list-to-string (mu4e~draft-recipients-list-to-string
(case field (cl-case field
(:to (:to
(mu4e~draft-create-to-lst origmsg)) (mu4e~draft-create-to-lst origmsg))
(:cc (:cc
@ -479,7 +476,7 @@ will be created from either `mu4e~draft-reply-construct', or
`mu4e~draft-forward-construct' or `mu4e~draft-newmsg-construct'." `mu4e~draft-forward-construct' or `mu4e~draft-newmsg-construct'."
(unless mu4e-maildir (mu4e-error "mu4e-maildir not set")) (unless mu4e-maildir (mu4e-error "mu4e-maildir not set"))
(let ((draft-dir nil)) (let ((draft-dir nil))
(case compose-type (cl-case compose-type
(edit (edit
;; case-1: re-editing a draft messages. in this case, we do know the ;; case-1: re-editing a draft messages. in this case, we do know the
@ -502,7 +499,7 @@ will be created from either `mu4e~draft-reply-construct', or
(setq draft-dir (mu4e-get-drafts-folder msg)) (setq draft-dir (mu4e-get-drafts-folder msg))
(let ((draft-path (mu4e~draft-determine-path draft-dir)) (let ((draft-path (mu4e~draft-determine-path draft-dir))
(initial-contents (initial-contents
(case compose-type (cl-case compose-type
(reply (mu4e~draft-reply-construct msg)) (reply (mu4e~draft-reply-construct msg))
(forward (mu4e~draft-forward-construct msg)) (forward (mu4e~draft-forward-construct msg))
(new (mu4e~draft-newmsg-construct))))) (new (mu4e~draft-newmsg-construct)))))

View File

@ -27,9 +27,7 @@
;; headers like 'To:' or 'Subject:') ;; headers like 'To:' or 'Subject:')
;; Code: ;; Code:
(eval-when-compile (byte-compile-disable-warning 'cl-functions)) (require 'cl-lib)
(require 'cl)
(require 'fringe) (require 'fringe)
(require 'hl-line) (require 'hl-line)
@ -435,7 +433,7 @@ into a string."
(let ((get-prefix (let ((get-prefix
(lambda (cell) (lambda (cell)
(if mu4e-use-fancy-chars (cdr cell) (car cell))))) (if mu4e-use-fancy-chars (cdr cell) (car cell)))))
(case type (cl-case type
('child (funcall get-prefix mu4e-headers-thread-child-prefix)) ('child (funcall get-prefix mu4e-headers-thread-child-prefix))
('last-child (funcall get-prefix mu4e-headers-thread-last-child-prefix)) ('last-child (funcall get-prefix mu4e-headers-thread-last-child-prefix))
('connection (funcall get-prefix mu4e-headers-thread-connection-prefix)) ('connection (funcall get-prefix mu4e-headers-thread-connection-prefix))
@ -473,7 +471,7 @@ into a string."
;; because the current level has always an connection ;; because the current level has always an connection
;; and it used a special formatting. ;; and it used a special formatting.
(setq mu4e~headers-thread-state (setq mu4e~headers-thread-state
(subseq (append mu4e~headers-thread-state padding) (cl-subseq (append mu4e~headers-thread-state padding)
0 (- level 1))) 0 (- level 1)))
;; Prepare the thread prefix. ;; Prepare the thread prefix.
(setq prefix (setq prefix
@ -517,7 +515,7 @@ while our display may be different)."
(when (member flag flags) (when (member flag flags)
(setq str (setq str
(concat str (concat str
(case flag (cl-case flag
('draft (funcall get-prefix mu4e-headers-draft-mark)) ('draft (funcall get-prefix mu4e-headers-draft-mark))
('flagged (funcall get-prefix mu4e-headers-flagged-mark)) ('flagged (funcall get-prefix mu4e-headers-flagged-mark))
('new (funcall get-prefix mu4e-headers-new-mark)) ('new (funcall get-prefix mu4e-headers-new-mark))
@ -597,7 +595,7 @@ found."
(funcall func msg))) (funcall func msg)))
(defun mu4e~headers-field-apply-basic-properties (msg field val width) (defun mu4e~headers-field-apply-basic-properties (msg field val width)
(case field (cl-case field
(:subject (:subject
(concat ;; prefix subject with a thread indicator (concat ;; prefix subject with a thread indicator
(mu4e~headers-thread-prefix (mu4e-message-field msg :thread)) (mu4e~headers-thread-prefix (mu4e-message-field msg :thread))
@ -1346,7 +1344,7 @@ matching messages with that mark."
(let* ((do-mark) (value (mu4e-msg-field msg field))) (let* ((do-mark) (value (mu4e-msg-field msg field)))
(setq do-mark (setq do-mark
(if (member field '(:to :from :cc :bcc :reply-to)) (if (member field '(:to :from :cc :bcc :reply-to))
(find-if (lambda (contact) (cl-find-if (lambda (contact)
(let ((name (car contact)) (email (cdr contact))) (let ((name (car contact)) (email (cdr contact)))
(or (and name (string-match pattern name)) (or (and name (string-match pattern name))
(and email (string-match pattern email))))) value) (and email (string-match pattern email))))) value)
@ -1367,7 +1365,7 @@ matching messages with that mark."
(mu4e-error "No thread info found"))) (mu4e-error "No thread info found")))
(path (or (plist-get thread :path) (path (or (plist-get thread :path)
(mu4e-error "No threadpath found")))) (mu4e-error "No threadpath found"))))
(case what (cl-case what
(path path) (path path)
(thread-id (thread-id
(save-match-data (save-match-data
@ -1445,7 +1443,7 @@ WHERE is a symbol telling us where to push; it's a symbol, either
'future or 'past. Functional also removes duplicats, limits the 'future or 'past. Functional also removes duplicats, limits the
stack size." stack size."
(let ((stack (let ((stack
(case where (cl-case where
(past mu4e~headers-query-past) (past mu4e~headers-query-past)
(future mu4e~headers-query-future)))) (future mu4e~headers-query-future))))
;; only add if not the same item ;; only add if not the same item
@ -1453,11 +1451,11 @@ stack size."
(push query stack) (push query stack)
;; limit the stack to `mu4e~headers-query-stack-size' elements ;; limit the stack to `mu4e~headers-query-stack-size' elements
(when (> (length stack) mu4e~headers-query-stack-size) (when (> (length stack) mu4e~headers-query-stack-size)
(setq stack (subseq stack 0 mu4e~headers-query-stack-size))) (setq stack (cl-subseq stack 0 mu4e~headers-query-stack-size)))
;; remove all duplicates of the new element ;; remove all duplicates of the new element
(remove-if (lambda (elm) (string= elm (car stack))) (cdr stack)) (cl-remove-if (lambda (elm) (string= elm (car stack))) (cdr stack))
;; update the stacks ;; update the stacks
(case where (cl-case where
(past (setq mu4e~headers-query-past stack)) (past (setq mu4e~headers-query-past stack))
(future (setq mu4e~headers-query-future stack)))))) (future (setq mu4e~headers-query-future stack))))))
@ -1465,7 +1463,7 @@ stack size."
"Pop a query from the stack. "Pop a query from the stack.
WHENCE is a symbol telling us where to get it from, either `future' WHENCE is a symbol telling us where to get it from, either `future'
or `past'." or `past'."
(case whence (cl-case whence
(past (past
(unless mu4e~headers-query-past (unless mu4e~headers-query-past
(mu4e-warn "No more previous queries")) (mu4e-warn "No more previous queries"))
@ -1570,7 +1568,7 @@ sortfield, change the sort-order) or nil (ask the user)."
(mu4e-error "Not a sortable field"))) (mu4e-error "Not a sortable field")))
(sortfield (if (booleanp sortable) field sortable)) (sortfield (if (booleanp sortable) field sortable))
(dir (dir
(case dir (cl-case dir
((ascending descending) dir) ((ascending descending) dir)
;; change the sort order if field = curfield ;; change the sort order if field = curfield
(t (t
@ -1800,7 +1798,7 @@ do nothing."
(hwin (get-buffer-window (mu4e-get-headers-buffer)))) (hwin (get-buffer-window (mu4e-get-headers-buffer))))
(when (and (buffer-live-p (mu4e-get-view-buffer)) (window-live-p hwin)) (when (and (buffer-live-p (mu4e-get-view-buffer)) (window-live-p hwin))
(let ((n (or n 1))) (let ((n (or n 1)))
(case mu4e-split-view (cl-case mu4e-split-view
;; emacs has weird ideas about what horizontal, vertical means... ;; emacs has weird ideas about what horizontal, vertical means...
(horizontal (horizontal
(window-resize hwin n nil) (window-resize hwin n nil)

View File

@ -28,6 +28,8 @@
(require 'mu4e-utils) ;; utility functions (require 'mu4e-utils) ;; utility functions
(require 'mu4e-context) ;; the context (require 'mu4e-context) ;; the context
(eval-when-compile
(require 'cl))
(defconst mu4e~main-buffer-name " *mu4e-main*" (defconst mu4e~main-buffer-name " *mu4e-main*"
"*internal* Name of the mu4e main view buffer.") "*internal* Name of the mu4e main view buffer.")

View File

@ -26,12 +26,11 @@
;; currently in the headers buffer. ;; currently in the headers buffer.
;; Code: ;; Code:
(require 'cl-lib)
(require 'mu4e-proc) (require 'mu4e-proc)
(require 'mu4e-utils) (require 'mu4e-utils)
(require 'mu4e-message) (require 'mu4e-message)
(eval-when-compile (byte-compile-disable-warning 'cl-functions))
;; keep byte-compiler happy ;; keep byte-compiler happy
(declare-function mu4e~headers-mark "mu4e-headers") (declare-function mu4e~headers-mark "mu4e-headers")
(declare-function mu4e~headers-goto-docid "mu4e-headers") (declare-function mu4e~headers-goto-docid "mu4e-headers")
@ -96,7 +95,7 @@ where
(defun mu4e~mark-find-headers-buffer () (defun mu4e~mark-find-headers-buffer ()
"Find the headers buffer, if any." "Find the headers buffer, if any."
(find-if (cl-find-if
(lambda (b) (lambda (b)
(with-current-buffer b (with-current-buffer b
(eq major-mode 'mu4e-headers-mode))) (eq major-mode 'mu4e-headers-mode)))
@ -346,7 +345,7 @@ as well."
mu4e-marks)) mu4e-marks))
(marks (marks
(if allow-something (if allow-something
marks (remove-if (lambda (m) (eq 'something (cdr m))) marks))) marks (cl-remove-if (lambda (m) (eq 'something (cdr m))) marks)))
(mark (mu4e-read-option prompt marks)) (mark (mu4e-read-option prompt marks))
(target (mu4e~mark-ask-target mark))) (target (mu4e~mark-ask-target mark)))
(cons mark target))) (cons mark target)))

View File

@ -25,12 +25,9 @@
;; Functions to get data from mu4e-message plist structure ;; Functions to get data from mu4e-message plist structure
;;; Code: ;;; Code:
(eval-when-compile (byte-compile-disable-warning 'cl-functions)) (require 'cl-lib)
(require 'mu4e-vars) (require 'mu4e-vars)
(require 'mu4e-utils) (require 'mu4e-utils)
(require 'cl)
(require 'flow-fill) (require 'flow-fill)
@ -268,11 +265,11 @@ expressions, in which case any of those are tried for a match."
(when cfield (when cfield
(if (listp rx) (if (listp rx)
;; if rx is a list, try each one of them for a match ;; if rx is a list, try each one of them for a match
(find-if (cl-find-if
(lambda (a-rx) (mu4e-message-contact-field-matches msg cfield a-rx)) (lambda (a-rx) (mu4e-message-contact-field-matches msg cfield a-rx))
rx) rx)
;; not a list, check the rx ;; not a list, check the rx
(find-if (cl-find-if
(lambda (ct) (lambda (ct)
(let ((name (car ct)) (email (cdr ct))) (let ((name (car ct)) (email (cdr ct)))
(or (or
@ -287,9 +284,9 @@ CFIELD (either :to, :from, :cc or :bcc) of msg MSG matches *me*,
that is, any of the e-mail address in that is, any of the e-mail address in
`mu4e-user-mail-address-list'. Returns the contact cell that `mu4e-user-mail-address-list'. Returns the contact cell that
matched, or nil." matched, or nil."
(find-if (cl-find-if
(lambda (cc-cell) (lambda (cc-cell)
(member-if (cl-member-if
(lambda (addr) (lambda (addr)
(string= (downcase addr) (downcase (cdr cc-cell)))) (string= (downcase addr) (downcase (cdr cc-cell))))
mu4e-user-mail-address-list)) mu4e-user-mail-address-list))

View File

@ -471,7 +471,7 @@ mean:
(:temp <path> :what <what> :param <param>)." (:temp <path> :what <what> :param <param>)."
(let ((cmd (let ((cmd
(concat "cmd:extract " (concat "cmd:extract "
(case action (cl-case action
(save (save
(format "action:save docid:%d index:%d path:%s extract-encrypted:%s use-agent:true" (format "action:save docid:%d index:%d path:%s extract-encrypted:%s use-agent:true"
docid partidx (mu4e~escape path) (if decrypt "true" "false"))) docid partidx (mu4e~escape path) (if decrypt "true" "false")))

View File

@ -26,11 +26,10 @@
;; Utility functions used in the mu4e ;; Utility functions used in the mu4e
;;; Code: ;;; Code:
(eval-when-compile (byte-compile-disable-warning 'cl-functions)) (eval-when-compile
(require 'cl) (require 'cl)
(require 'org nil 'noerror))
(eval-when-compile (require 'org nil 'noerror)) (require 'cl-lib)
(require 'mu4e-vars) (require 'mu4e-vars)
(require 'mu4e-meta) (require 'mu4e-meta)
(require 'mu4e-lists) (require 'mu4e-lists)
@ -88,7 +87,7 @@ NODEFAULT, hour and minute fields will be nil if not given."
User's addresses are set in `mu4e-user-mail-address-list'. Case User's addresses are set in `mu4e-user-mail-address-list'. Case
insensitive comparison is used." insensitive comparison is used."
(when (and addr mu4e-user-mail-address-list (when (and addr mu4e-user-mail-address-list
(find addr mu4e-user-mail-address-list (cl-find addr mu4e-user-mail-address-list
:test (lambda (s1 s2) :test (lambda (s1 s2)
(eq t (compare-strings s1 nil nil s2 nil nil t))))) (eq t (compare-strings s1 nil nil s2 nil nil t)))))
t)) t))
@ -306,9 +305,9 @@ Function will return the cdr of the list element."
" [" (propertize "C-g" 'face 'mu4e-highlight-face) " [" (propertize "C-g" 'face 'mu4e-highlight-face)
" to cancel]") " to cancel]")
;; the allowable chars ;; the allowable chars
(map 'list (lambda(elm) (string-to-char (car elm))) options))) (cl-map 'list (lambda(elm) (string-to-char (car elm))) options)))
(chosen (chosen
(find-if (cl-find-if
(lambda (option) (eq response (string-to-char (car option)))) (lambda (option) (eq response (string-to-char (car option))))
options))) options)))
(if chosen (if chosen
@ -384,7 +383,7 @@ maildirs under `mu4e-maildir'."
(funcall mu4e-completing-read-function prompt (funcall mu4e-completing-read-function prompt
(mu4e-get-maildirs) nil nil "/") (mu4e-get-maildirs) nil nil "/")
(or (car-safe (or (car-safe
(find-if (lambda (item) (= kar (cdr item))) (cl-find-if (lambda (item) (= kar (cdr item)))
mu4e-maildir-shortcuts)) mu4e-maildir-shortcuts))
(mu4e-warn "Unknown shortcut '%c'" kar))))))) (mu4e-warn "Unknown shortcut '%c'" kar)))))))
@ -401,7 +400,7 @@ and offer to create it if it does not exist yet."
mdir)) mdir))
(defstruct mu4e-bookmark (cl-defstruct mu4e-bookmark
"A mu4e bookmarl object with the following members: "A mu4e bookmarl object with the following members:
- `name': the user-visible name of the bookmark - `name': the user-visible name of the bookmark
- `key': a single key to search for this bookmark - `key': a single key to search for this bookmark
@ -415,7 +414,7 @@ and offer to create it if it does not exist yet."
(defun mu4e-bookmarks () (defun mu4e-bookmarks ()
"Get `mu4e-bookmarks' in the (new) format, converting from the old "Get `mu4e-bookmarks' in the (new) format, converting from the old
format if needed." format if needed."
(map 'list (cl-map 'list
(lambda (item) (lambda (item)
(if (mu4e-bookmark-p item) (if (mu4e-bookmark-p item)
item ;; already in the right format item ;; already in the right format
@ -448,7 +447,7 @@ format if needed."
"Get the corresponding bookmarked query for shortcut character "Get the corresponding bookmarked query for shortcut character
KAR, or raise an error if none is found." KAR, or raise an error if none is found."
(let* ((chosen-bm (let* ((chosen-bm
(or (find-if (or (cl-find-if
(lambda (bm) (lambda (bm)
(= kar (mu4e-bookmark-key bm))) (= kar (mu4e-bookmark-key bm)))
(mu4e-bookmarks)) (mu4e-bookmarks))
@ -467,15 +466,15 @@ KAR, or raise an error if none is found."
shortcut-character KEY in the list of `mu4e-bookmarks'. This shortcut-character KEY in the list of `mu4e-bookmarks'. This
replaces any existing bookmark with KEY." replaces any existing bookmark with KEY."
(setq mu4e-bookmarks (setq mu4e-bookmarks
(remove-if (cl-remove-if
(lambda (bm) (lambda (bm)
(= (mu4e-bookmark-key bm) key)) (= (mu4e-bookmark-key bm) key))
(mu4e-bookmarks))) (mu4e-bookmarks)))
(add-to-list 'mu4e-bookmarks (add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark (make-mu4e-bookmark
:name name :name name
:query query :query query
:key key) t)) :key key) t))
;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -488,7 +487,7 @@ than the ones listed here are ignored.
Also see `mu4e-flags-to-string'. Also see `mu4e-flags-to-string'.
\[1\]: http://cr.yp.to/proto/maildir.html" \[1\]: http://cr.yp.to/proto/maildir.html"
(when flags (when flags
(let ((kar (case (car flags) (let ((kar (cl-case (car flags)
('draft ?D) ('draft ?D)
('flagged ?F) ('flagged ?F)
('new ?N) ('new ?N)
@ -506,7 +505,7 @@ Also see `mu4e-flags-to-string'.
(defun mu4e-flags-to-string (flags) (defun mu4e-flags-to-string (flags)
"Remove duplicates and sort the output of `mu4e~flags-to-string-raw'." "Remove duplicates and sort the output of `mu4e~flags-to-string-raw'."
(concat (concat
(sort (remove-duplicates (sort (cl-remove-duplicates
(append (mu4e~flags-to-string-raw flags) nil)) '>))) (append (mu4e~flags-to-string-raw flags) nil)) '>)))
(defun mu4e~string-to-flags-1 (str) (defun mu4e~string-to-flags-1 (str)
@ -519,7 +518,7 @@ Also see `mu4e-flags-to-string'.
\[1\]: http://cr.yp.to/proto/maildir.html." \[1\]: http://cr.yp.to/proto/maildir.html."
(when (/= 0 (length str)) (when (/= 0 (length str))
(let ((flag (let ((flag
(case (string-to-char str) (cl-case (string-to-char str)
(?D 'draft) (?D 'draft)
(?F 'flagged) (?F 'flagged)
(?P 'passed) (?P 'passed)
@ -538,7 +537,7 @@ letters than the ones listed here are ignored. Also see
`mu4e-flags-to-string'. \[1\]: `mu4e-flags-to-string'. \[1\]:
http://cr.yp.to/proto/maildir.html " http://cr.yp.to/proto/maildir.html "
;; "Remove duplicates from the output of `mu4e~string-to-flags-1'" ;; "Remove duplicates from the output of `mu4e~string-to-flags-1'"
(remove-duplicates (mu4e~string-to-flags-1 str))) (cl-remove-duplicates (mu4e~string-to-flags-1 str)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -556,7 +555,7 @@ http://cr.yp.to/proto/maildir.html "
"Display the mu4e manual page for the current mode. "Display the mu4e manual page for the current mode.
Or go to the top level if there is none." Or go to the top level if there is none."
(interactive) (interactive)
(info (case major-mode (info (cl-case major-mode
('mu4e-main-mode "(mu4e)Main view") ('mu4e-main-mode "(mu4e)Main view")
('mu4e-headers-mode "(mu4e)Headers view") ('mu4e-headers-mode "(mu4e)Headers view")
('mu4e-view-mode "(mu4e)Message view") ('mu4e-view-mode "(mu4e)Message view")
@ -676,7 +675,7 @@ process."
(defun mu4e-error-handler (errcode errmsg) (defun mu4e-error-handler (errcode errmsg)
"Handler function for showing an error." "Handler function for showing an error."
;; don't use mu4e-error here; it's running in the process filter context ;; don't use mu4e-error here; it's running in the process filter context
(case errcode (cl-case errcode
(4 (user-error "No matches for this search query.")) (4 (user-error "No matches for this search query."))
(t (error "Error %d: %s" errcode errmsg)))) (t (error "Error %d: %s" errcode errmsg))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -741,7 +740,7 @@ or (rfc822-string . CONTACT) otherwise."
'mostly likely contact'.t See the code for the detail" 'mostly likely contact'.t See the code for the detail"
(let* ((now (+ (float-time) 3600)) ;; allow for clock diffs (let* ((now (+ (float-time) 3600)) ;; allow for clock diffs
(recent (- (float-time) (* 15 24 3600)))) (recent (- (float-time) (* 15 24 3600))))
(sort* contacts (cl-sort contacts
(lambda (c1 c2) (lambda (c1 c2)
(let* ( (c1 (cdr c1)) (c2 (cdr c2)) (let* ( (c1 (cdr c1)) (c2 (cdr c2))
(personal1 (plist-get c1 :personal)) (personal1 (plist-get c1 :personal))
@ -765,7 +764,7 @@ or (rfc822-string . CONTACT) otherwise."
(defun mu4e~sort-contacts-for-completion (contacts) (defun mu4e~sort-contacts-for-completion (contacts)
"Takes CONTACTS, which is a list of RFC-822 addresses, and sort them based "Takes CONTACTS, which is a list of RFC-822 addresses, and sort them based
on the ranking in `mu4e~contacts.'" on the ranking in `mu4e~contacts.'"
(sort* contacts (cl-sort contacts
(lambda (c1 c2) (lambda (c1 c2)
(let ((rank1 (gethash c1 mu4e~contacts)) (let ((rank1 (gethash c1 mu4e~contacts))
(rank2 (gethash c2 mu4e~contacts))) (rank2 (gethash c2 mu4e~contacts)))
@ -1099,7 +1098,7 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging."
(current-time)) (current-time))
'face 'font-lock-string-face)) 'face 'font-lock-string-face))
(msg-face (msg-face
(case type (cl-case type
(from-server 'font-lock-type-face) (from-server 'font-lock-type-face)
(to-server 'font-lock-function-name-face) (to-server 'font-lock-function-name-face)
(misc 'font-lock-variable-name-face) (misc 'font-lock-variable-name-face)
@ -1108,7 +1107,7 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging."
(msg (propertize (apply 'format frm args) 'face msg-face))) (msg (propertize (apply 'format frm args) 'face msg-face)))
(goto-char (point-max)) (goto-char (point-max))
(insert tstamp (insert tstamp
(case type (cl-case type
(from-server " <- ") (from-server " <- ")
(to-server " -> ") (to-server " -> ")
(error " !! ") (error " !! ")

View File

@ -26,6 +26,9 @@
;; viewing e-mail messages ;; viewing e-mail messages
;;; Code: ;;; Code:
(eval-when-compile
(require 'cl))
(require 'cl-lib)
(require 'mu4e-utils) ;; utility functions (require 'mu4e-utils) ;; utility functions
(require 'mu4e-vars) (require 'mu4e-vars)
(require 'mu4e-mark) (require 'mu4e-mark)
@ -43,9 +46,6 @@
(require 'thingatpt) (require 'thingatpt)
(require 'calendar) (require 'calendar)
(eval-when-compile (byte-compile-disable-warning 'cl-functions))
(require 'cl)
(declare-function mu4e-view-mode "mu4e-view") (declare-function mu4e-view-mode "mu4e-view")
;; the message view ;; the message view
@ -232,7 +232,7 @@ found."
(mapconcat (mapconcat
(lambda (field) (lambda (field)
(let ((fieldval (mu4e-message-field msg field))) (let ((fieldval (mu4e-message-field msg field)))
(case field (cl-case field
(:subject (mu4e~view-construct-header field fieldval)) (:subject (mu4e~view-construct-header field fieldval))
(:path (mu4e~view-construct-header field fieldval)) (:path (mu4e~view-construct-header field fieldval))
(:maildir (mu4e~view-construct-header field fieldval)) (:maildir (mu4e~view-construct-header field fieldval))
@ -506,12 +506,12 @@ add text-properties to VAL."
"Construct a Signature: header, if there are any signed parts." "Construct a Signature: header, if there are any signed parts."
(let* ((parts (mu4e-message-field msg :parts)) (let* ((parts (mu4e-message-field msg :parts))
(verdicts (verdicts
(remove-if 'null (cl-remove-if 'null
(mapcar (lambda (part) (mu4e-message-part-field part :signature)) (mapcar (lambda (part) (mu4e-message-part-field part :signature))
parts))) parts)))
(signers (signers
(mapconcat 'identity (mapconcat 'identity
(remove-if 'null (cl-remove-if 'null
(mapcar (lambda (part) (mu4e-message-part-field part :signers)) (mapcar (lambda (part) (mu4e-message-part-field part :signers))
parts)) ", ")) parts)) ", "))
(val (when verdicts (val (when verdicts
@ -535,12 +535,12 @@ add text-properties to VAL."
"Construct a Decryption: header, if there are any encrypted parts." "Construct a Decryption: header, if there are any encrypted parts."
(let* ((parts (mu4e-message-field msg :parts)) (let* ((parts (mu4e-message-field msg :parts))
(verdicts (verdicts
(remove-if 'null (cl-remove-if 'null
(mapcar (lambda (part) (mapcar (lambda (part)
(mu4e-message-part-field part :decryption)) (mu4e-message-part-field part :decryption))
parts))) parts)))
(succeeded (remove-if (lambda (v) (eq v 'failed)) verdicts)) (succeeded (cl-remove-if (lambda (v) (eq v 'failed)) verdicts))
(failed (remove-if (lambda (v) (eq v 'succeeded)) verdicts)) (failed (cl-remove-if (lambda (v) (eq v 'succeeded)) verdicts))
(succ (when succeeded (succ (when succeeded
(propertize (propertize
(concat (number-to-string (length succeeded)) (concat (number-to-string (length succeeded))
@ -585,7 +585,7 @@ add text-properties to VAL."
;; we only list parts that look like attachments, ie. that have a ;; we only list parts that look like attachments, ie. that have a
;; non-nil :attachment property; we record a mapping between ;; non-nil :attachment property; we record a mapping between
;; user-visible numbers and the part indices ;; user-visible numbers and the part indices
(remove-if-not (cl-remove-if-not
(lambda (part) (lambda (part)
(let* ((mtype (or (mu4e-message-part-field part :mime-type) (let* ((mtype (or (mu4e-message-part-field part :mime-type)
"application/octet-stream")) "application/octet-stream"))
@ -1198,7 +1198,7 @@ return the corresponding string."
number ATTNUM." number ATTNUM."
(let* ((partid (gethash attnum mu4e~view-attach-map)) (let* ((partid (gethash attnum mu4e~view-attach-map))
(attach (attach
(find-if (cl-find-if
(lambda (part) (lambda (part)
(eq (mu4e-message-part-field part :index) partid)) (eq (mu4e-message-part-field part :index) partid))
(mu4e-message-field msg :parts)))) (mu4e-message-field msg :parts))))

View File

@ -26,8 +26,6 @@
;;; Code: ;;; Code:
(eval-when-compile (require 'cl))
(require 'mu4e-meta) ;; autogenerated file with metadata (version etc.) (require 'mu4e-meta) ;; autogenerated file with metadata (version etc.)
(require 'mu4e-headers) ;; headers view (require 'mu4e-headers) ;; headers view
(require 'mu4e-view) ;; message view (require 'mu4e-view) ;; message view

View File

@ -30,11 +30,7 @@
;; The expect version here is org 8.x ;; The expect version here is org 8.x
;; the 'noerror is just to make sure bytecompilations does not break...
(require 'org) (require 'org)
(eval-when-compile (require 'cl))
(defgroup org-mu4e nil (defgroup org-mu4e nil
"Settings for the org-mode related functionality in mu4e." "Settings for the org-mode related functionality in mu4e."

View File

@ -34,7 +34,6 @@
(require 'org nil 'noerror) (require 'org nil 'noerror)
(require 'org-exp nil 'noerror) (require 'org-exp nil 'noerror)
(eval-when-compile (require 'cl))
(require 'mu4e) (require 'mu4e)
(defgroup org-mu4e nil (defgroup org-mu4e nil