mu4e: utils: fix indentation

This commit is contained in:
Dirk-Jan C. Binnema 2020-01-13 12:47:49 +02:00
parent 1631d98b9e
commit cf594413e2
1 changed files with 333 additions and 333 deletions

View File

@ -1,6 +1,6 @@
;;; mu4e-utils.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*- ;;; mu4e-utils.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*-
;; ;;
;; Copyright (C) 2011-2019 Dirk-Jan C. Binnema ;; Copyright (C) 2011-2020 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>
@ -68,11 +68,11 @@ This should be a lot faster than the normal `parse-time-string'.
If time is not given, defaults to 0:00. However, with optional If time is not given, defaults to 0:00. However, with optional
NODEFAULT, hour and minute fields will be nil if not given." NODEFAULT, hour and minute fields will be nil if not given."
(if (string-match mu4e~ts-regexp0 s) (if (string-match mu4e~ts-regexp0 s)
(list 0 (list 0
(if (or (match-beginning 8) (not nodefault)) (if (or (match-beginning 8) (not nodefault))
(string-to-number (or (match-string 8 s) "0"))) (string-to-number (or (match-string 8 s) "0")))
(if (or (match-beginning 7) (not nodefault)) (if (or (match-beginning 7) (not nodefault))
(string-to-number (or (match-string 7 s) "0"))) (string-to-number (or (match-string 7 s) "0")))
(string-to-number (match-string 4 s)) (string-to-number (match-string 4 s))
(string-to-number (match-string 3 s)) (string-to-number (match-string 3 s))
(string-to-number (match-string 2 s)) (string-to-number (match-string 2 s))
@ -85,9 +85,9 @@ 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
(cl-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))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -109,17 +109,17 @@ If FOLDER is a string, return it, if it is a function, evaluate
this function with MSG as parameter (which may be `nil'), and this function with MSG as parameter (which may be `nil'), and
return the result." return the result."
(unless (member foldervar (unless (member foldervar
'(mu4e-sent-folder mu4e-drafts-folder '(mu4e-sent-folder mu4e-drafts-folder
mu4e-trash-folder mu4e-refile-folder)) mu4e-trash-folder mu4e-refile-folder))
(mu4e-error "Folder must be one of mu4e-(sent|drafts|trash|refile)-folder")) (mu4e-error "Folder must be one of mu4e-(sent|drafts|trash|refile)-folder"))
;; get the value with the vars for the relevants context let-bound ;; get the value with the vars for the relevants context let-bound
(with~mu4e-context-vars (mu4e-context-determine msg nil) (with~mu4e-context-vars (mu4e-context-determine msg nil)
(let* ((folder (symbol-value foldervar)) (let* ((folder (symbol-value foldervar))
(val (val
(cond (cond
((stringp folder) folder) ((stringp folder) folder)
((functionp folder) (funcall folder msg)) ((functionp folder) (funcall folder msg))
(t (mu4e-error "unsupported type for %S" folder))))) (t (mu4e-error "unsupported type for %S" folder)))))
(or val (mu4e-error "%S evaluates to nil" foldervar))))) (or val (mu4e-error "%S evaluates to nil" foldervar)))))
(defun mu4e-get-drafts-folder (&optional msg) (defun mu4e-get-drafts-folder (&optional msg)
@ -143,7 +143,7 @@ return the result."
(defun mu4e-remove-file-later (filename) (defun mu4e-remove-file-later (filename)
"Remove FILENAME in a few seconds." "Remove FILENAME in a few seconds."
(run-at-time "30 sec" nil (run-at-time "30 sec" nil
(lambda () (ignore-errors (delete-file filename))))) (lambda () (ignore-errors (delete-file filename)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -167,12 +167,12 @@ see its docstring)."
(let (let
((dir ((dir
(cond (cond
((stringp mu4e-attachment-dir) ((stringp mu4e-attachment-dir)
mu4e-attachment-dir) mu4e-attachment-dir)
((functionp mu4e-attachment-dir) ((functionp mu4e-attachment-dir)
(funcall mu4e-attachment-dir fname mimetype)) (funcall mu4e-attachment-dir fname mimetype))
(t (t
(mu4e-error "unsupported type for mu4e-attachment-dir" ))))) (mu4e-error "unsupported type for mu4e-attachment-dir" )))))
(if dir (if dir
(expand-file-name dir) (expand-file-name dir)
(mu4e-error (mu4e-error "mu4e-attachment-dir evaluates to nil"))))) (mu4e-error (mu4e-error "mu4e-attachment-dir evaluates to nil")))))
@ -184,10 +184,10 @@ see its docstring)."
(let ((idx (string-match mu4e-maildir path))) (let ((idx (string-match mu4e-maildir path)))
(when (and idx (zerop idx)) (when (and idx (zerop idx))
(replace-regexp-in-string (replace-regexp-in-string
mu4e-maildir mu4e-maildir
"" ""
(expand-file-name (expand-file-name
(concat path "/../..")))))) (concat path "/../.."))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -254,8 +254,8 @@ trying an exact match."
(message nil);; this seems needed... (message nil);; this seems needed...
(setq choice (read-char-exclusive prompt)) (setq choice (read-char-exclusive prompt))
(setq chosen (or (member choice choices) (setq chosen (or (member choice choices)
(member (downcase choice) choices) (member (downcase choice) choices)
(member (upcase choice) choices)))) (member (upcase choice) choices))))
(car chosen))) (car chosen)))
(defun mu4e-read-option (prompt options) (defun mu4e-read-option (prompt options)
@ -281,32 +281,32 @@ User now will be presented with a list: \"Choose an animal:
Function will return the cdr of the list element." Function will return the cdr of the list element."
(let* ((prompt (mu4e-format "%s" prompt)) (let* ((prompt (mu4e-format "%s" prompt))
(chosen) (chosen)
(optionsstr (optionsstr
(mapconcat (mapconcat
(lambda (option) (lambda (option)
;; try to detect old-style options, and warn ;; try to detect old-style options, and warn
(when (characterp (car-safe (cdr-safe option))) (when (characterp (car-safe (cdr-safe option)))
(mu4e-error (mu4e-error
(concat "Please use the new format for options/actions; " (concat "Please use the new format for options/actions; "
"see the manual"))) "see the manual")))
(let* ((kar (substring (car option) 0 1)) (let* ((kar (substring (car option) 0 1))
(val (cdr option))) (val (cdr option)))
(concat (concat
"[" (propertize kar 'face 'mu4e-highlight-face) "]" "[" (propertize kar 'face 'mu4e-highlight-face) "]"
(substring (car option) 1)))) (substring (car option) 1))))
options ", ")) options ", "))
(response (response
(mu4e~read-char-choice (mu4e~read-char-choice
(concat prompt optionsstr (concat prompt optionsstr
" [" (propertize "C-g" 'face 'mu4e-highlight-face) " [" (propertize "C-g" 'face 'mu4e-highlight-face)
" to cancel]") " to cancel]")
;; the allowable chars ;; the allowable chars
(cl-map 'list (lambda(elm) (string-to-char (car elm))) options))) (cl-map 'list (lambda(elm) (string-to-char (car elm))) options)))
(chosen (chosen
(cl-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
(cdr chosen) (cdr chosen)
(mu4e-warn "Unknown shortcut '%c'" response)))) (mu4e-warn "Unknown shortcut '%c'" response))))
@ -314,19 +314,19 @@ Function will return the cdr of the list element."
(defun mu4e~get-maildirs-1 (path mdir) (defun mu4e~get-maildirs-1 (path mdir)
"Get maildirs under path, recursively, as a list of relative paths." "Get maildirs under path, recursively, as a list of relative paths."
(let ((dirs) (let ((dirs)
(dentries (dentries
(ignore-errors (ignore-errors
(directory-files-and-attributes (directory-files-and-attributes
(concat path mdir) nil (concat path mdir) nil
"^[^.]\\|\\.[^.][^.]" t)))) "^[^.]\\|\\.[^.][^.]" t))))
(dolist (dentry dentries) (dolist (dentry dentries)
(when (and (booleanp (cadr dentry)) (cadr dentry)) (when (and (booleanp (cadr dentry)) (cadr dentry))
(if (file-accessible-directory-p (if (file-accessible-directory-p
(concat mu4e-maildir "/" mdir "/" (car dentry) "/cur")) (concat mu4e-maildir "/" mdir "/" (car dentry) "/cur"))
(setq dirs (cons (concat mdir (car dentry)) dirs))) (setq dirs (cons (concat mdir (car dentry)) dirs)))
(unless (member (car dentry) '("cur" "new" "tmp")) (unless (member (car dentry) '("cur" "new" "tmp"))
(setq dirs (append dirs (mu4e~get-maildirs-1 path (setq dirs (append dirs (mu4e~get-maildirs-1 path
(concat mdir (car dentry) "/"))))))) (concat mdir (car dentry) "/")))))))
dirs)) dirs))
(defvar mu4e-cache-maildir-list nil (defvar mu4e-cache-maildir-list nil
@ -348,11 +348,11 @@ the list of maildirs will not change until you restart mu4e."
(unless (and mu4e-maildir-list mu4e-cache-maildir-list) (unless (and mu4e-maildir-list mu4e-cache-maildir-list)
(setq mu4e-maildir-list (setq mu4e-maildir-list
(sort (sort
(append (append
(when (file-accessible-directory-p (when (file-accessible-directory-p
(concat mu4e-maildir "/cur")) '("/")) (concat mu4e-maildir "/cur")) '("/"))
(mu4e~get-maildirs-1 mu4e-maildir "/")) (mu4e~get-maildirs-1 mu4e-maildir "/"))
(lambda (s1 s2) (string< (downcase s1) (downcase s2)))))) (lambda (s1 s2) (string< (downcase s1) (downcase s2))))))
mu4e-maildir-list) mu4e-maildir-list)
(defun mu4e-ask-maildir (prompt) (defun mu4e-ask-maildir (prompt)
@ -365,34 +365,34 @@ maildirs under `mu4e-maildir'."
(if (not mu4e-maildir-shortcuts) (if (not mu4e-maildir-shortcuts)
(funcall mu4e-completing-read-function prompt (mu4e-get-maildirs)) (funcall mu4e-completing-read-function prompt (mu4e-get-maildirs))
(let* ((mlist (append mu4e-maildir-shortcuts '(("ther" . ?o)))) (let* ((mlist (append mu4e-maildir-shortcuts '(("ther" . ?o))))
(fnames (fnames
(mapconcat (mapconcat
(lambda (item) (lambda (item)
(concat (concat
"[" "["
(propertize (make-string 1 (cdr item)) (propertize (make-string 1 (cdr item))
'face 'mu4e-highlight-face) 'face 'mu4e-highlight-face)
"]" "]"
(car item))) (car item)))
mlist ", ")) mlist ", "))
(kar (read-char (concat prompt fnames)))) (kar (read-char (concat prompt fnames))))
(if (member kar '(?/ ?o)) ;; user chose 'other'? (if (member kar '(?/ ?o)) ;; user chose 'other'?
(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
(cl-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)))))))
(defun mu4e-ask-maildir-check-exists (prompt) (defun mu4e-ask-maildir-check-exists (prompt)
"Like `mu4e-ask-maildir', but check for existence of the maildir, "Like `mu4e-ask-maildir', but check for existence of the maildir,
and offer to create it if it does not exist yet." and offer to create it if it does not exist yet."
(let* ((mdir (mu4e-ask-maildir prompt)) (let* ((mdir (mu4e-ask-maildir prompt))
(fullpath (concat mu4e-maildir mdir))) (fullpath (concat mu4e-maildir mdir)))
(unless (file-directory-p fullpath) (unless (file-directory-p fullpath)
(and (yes-or-no-p (and (yes-or-no-p
(mu4e-format "%s does not exist. Create now?" fullpath)) (mu4e-format "%s does not exist. Create now?" fullpath))
(mu4e~proc-mkdir fullpath))) (mu4e~proc-mkdir fullpath)))
mdir)) mdir))
@ -403,8 +403,8 @@ old format if needed."
(lambda (item) (lambda (item)
(if (and (listp item) (= (length item) 3)) (if (and (listp item) (= (length item) 3))
`(:name ,(nth 1 item) `(:name ,(nth 1 item)
:query ,(nth 0 item) :query ,(nth 0 item)
:key ,(nth 2 item)) :key ,(nth 2 item))
item)) item))
mu4e-bookmarks)) mu4e-bookmarks))
@ -413,30 +413,30 @@ old format if needed."
`mu4e-bookmarks', then return the corresponding query." `mu4e-bookmarks', then return the corresponding query."
(unless (mu4e-bookmarks) (mu4e-error "No bookmarks defined")) (unless (mu4e-bookmarks) (mu4e-error "No bookmarks defined"))
(let* ((prompt (mu4e-format "%s" prompt)) (let* ((prompt (mu4e-format "%s" prompt))
(bmarks (bmarks
(mapconcat (mapconcat
(lambda (bm) (lambda (bm)
(concat (concat
"[" (propertize (make-string 1 (plist-get bm :key)) "[" (propertize (make-string 1 (plist-get bm :key))
'face 'mu4e-highlight-face) 'face 'mu4e-highlight-face)
"]" "]"
(plist-get bm :name))) (mu4e-bookmarks) ", ")) (plist-get bm :name))) (mu4e-bookmarks) ", "))
(kar (read-char (concat prompt bmarks)))) (kar (read-char (concat prompt bmarks))))
(mu4e-get-bookmark-query kar))) (mu4e-get-bookmark-query kar)))
(defun mu4e-get-bookmark-query (kar) (defun mu4e-get-bookmark-query (kar)
"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 (cl-find-if (or (cl-find-if
(lambda (bm) (lambda (bm)
(= kar (plist-get bm :key))) (= kar (plist-get bm :key)))
(mu4e-bookmarks)) (mu4e-bookmarks))
(mu4e-warn "Unknown shortcut '%c'" kar))) (mu4e-warn "Unknown shortcut '%c'" kar)))
(expr (plist-get chosen-bm :query)) (expr (plist-get chosen-bm :query))
(expr (if (not (functionp expr)) expr (expr (if (not (functionp expr)) expr
(funcall expr))) (funcall expr)))
(query (eval expr))) (query (eval expr)))
(if (stringp query) (if (stringp query)
query query
(mu4e-warn "Expression must evaluate to query string ('%S')" expr)))) (mu4e-warn "Expression must evaluate to query string ('%S')" expr))))
@ -447,12 +447,12 @@ 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
(cl-remove-if (cl-remove-if
(lambda (bm) (lambda (bm)
(= (plist-get bm :key) key)) (= (plist-get bm :key) key))
(mu4e-bookmarks))) (mu4e-bookmarks)))
(cl-pushnew `(:name ,name (cl-pushnew `(:name ,name
:query ,query :query ,query
:key ,key) :key ,key)
mu4e-bookmarks :test 'equal)) mu4e-bookmarks :test 'equal))
@ -468,25 +468,25 @@ 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 (cl-case (car flags) (let ((kar (cl-case (car flags)
('draft ?D) ('draft ?D)
('flagged ?F) ('flagged ?F)
('new ?N) ('new ?N)
('passed ?P) ('passed ?P)
('replied ?R) ('replied ?R)
('seen ?S) ('seen ?S)
('trashed ?T) ('trashed ?T)
('attach ?a) ('attach ?a)
('encrypted ?x) ('encrypted ?x)
('signed ?s) ('signed ?s)
('unread ?u)))) ('unread ?u))))
(concat (and kar (string kar)) (concat (and kar (string kar))
(mu4e~flags-to-string-raw (cdr flags)))))) (mu4e~flags-to-string-raw (cdr flags))))))
(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 (cl-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)
"Convert a string with message flags as seen in Maildir "Convert a string with message flags as seen in Maildir
@ -498,15 +498,15 @@ 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
(cl-case (string-to-char str) (cl-case (string-to-char str)
(?D 'draft) (?D 'draft)
(?F 'flagged) (?F 'flagged)
(?P 'passed) (?P 'passed)
(?R 'replied) (?R 'replied)
(?S 'seen) (?S 'seen)
(?T 'trashed)))) (?T 'trashed))))
(append (when flag (list flag)) (append (when flag (list flag))
(mu4e~string-to-flags-1 (substring str 1)))))) (mu4e~string-to-flags-1 (substring str 1))))))
(defun mu4e-string-to-flags (str) (defun mu4e-string-to-flags (str)
"Convert a string with message flags as seen in Maildir messages "Convert a string with message flags as seen in Maildir messages
@ -536,10 +536,10 @@ http://cr.yp.to/proto/maildir.html "
Or go to the top level if there is none." Or go to the top level if there is none."
(interactive) (interactive)
(info (cl-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")
(t "mu4e")))) (t "mu4e"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-last-query () (defun mu4e-last-query ()
@ -559,12 +559,12 @@ Or go to the top level if there is none."
that has a live window), and vice versa." that has a live window), and vice versa."
(interactive) (interactive)
(let* ((other-buf (let* ((other-buf
(cond (cond
((eq major-mode 'mu4e-headers-mode) ((eq major-mode 'mu4e-headers-mode)
(mu4e-get-view-buffer)) (mu4e-get-view-buffer))
((eq major-mode 'mu4e-view-mode) ((eq major-mode 'mu4e-view-mode)
(mu4e-get-headers-buffer)))) (mu4e-get-headers-buffer))))
(other-win (and other-buf (get-buffer-window other-buf)))) (other-win (and other-buf (get-buffer-window other-buf))))
(if (window-live-p other-win) (if (window-live-p other-win)
(select-window other-win) (select-window other-win)
(mu4e-message "No window to switch to")))) (mu4e-message "No window to switch to"))))
@ -578,9 +578,9 @@ that has a live window), and vice versa."
(let ((buf (get-buffer-create mu4e-output-buffer-name))) (let ((buf (get-buffer-create mu4e-output-buffer-name)))
(with-current-buffer buf (with-current-buffer buf
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(erase-buffer) (erase-buffer)
(call-process-shell-command pipecmd path t t) (call-process-shell-command pipecmd path t t)
(view-mode))) (view-mode)))
(switch-to-buffer buf))) (switch-to-buffer buf)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -601,11 +601,11 @@ on `mu4e~mailing-lists', `mu4e-user-mailing-lists', and
(or (or
(gethash list-id mu4e~lists-hash) (gethash list-id mu4e~lists-hash)
(and (boundp 'mu4e-mailing-list-patterns) (and (boundp 'mu4e-mailing-list-patterns)
(cl-member-if (cl-member-if
(lambda (pattern) (lambda (pattern)
(string-match pattern list-id)) (string-match pattern list-id))
mu4e-mailing-list-patterns) mu4e-mailing-list-patterns)
(match-string 1 list-id)) (match-string 1 list-id))
;; if it's not in the db, take the part until the first dot if there is one; ;; if it's not in the db, take the part until the first dot if there is one;
;; otherwise just return the whole thing ;; otherwise just return the whole thing
(if (string-match "\\([^.]*\\)\\." list-id) (if (string-match "\\([^.]*\\)\\." list-id)
@ -627,7 +627,7 @@ used as a simple way to invoke some action when a message
changed.") changed.")
(make-obsolete-variable 'mu4e-msg-changed-hook (make-obsolete-variable 'mu4e-msg-changed-hook
'mu4e-message-changed-hook "0.9.19") 'mu4e-message-changed-hook "0.9.19")
;; some handler functions for server messages ;; some handler functions for server messages
;; ;;
@ -638,20 +638,20 @@ process."
(cond (cond
((eq type 'add) t) ;; do nothing ((eq type 'add) t) ;; do nothing
((eq type 'index) ((eq type 'index)
(if (eq (plist-get info :status) 'running) (if (eq (plist-get info :status) 'running)
(mu4e-index-message "Indexing... processed %d, updated %d" (mu4e-index-message "Indexing... processed %d, updated %d"
(plist-get info :processed) (plist-get info :updated)) (plist-get info :processed) (plist-get info :updated))
(progn (progn
(mu4e-index-message (mu4e-index-message
"Indexing completed; processed %d, updated %d, cleaned-up %d" "Indexing completed; processed %d, updated %d, cleaned-up %d"
(plist-get info :processed) (plist-get info :updated) (plist-get info :processed) (plist-get info :updated)
(plist-get info :cleaned-up)) (plist-get info :cleaned-up))
(unless (and (not (string= mu4e~contacts-tstamp "0")) (unless (and (not (string= mu4e~contacts-tstamp "0"))
(zerop (plist-get info :updated))) (zerop (plist-get info :updated)))
(mu4e~request-contacts-maybe) (mu4e~request-contacts-maybe)
(run-hooks 'mu4e-index-updated-hook))))) (run-hooks 'mu4e-index-updated-hook)))))
((plist-get info :message) ((plist-get info :message)
(mu4e-index-message "%s" (plist-get info :message)))))) (mu4e-index-message "%s" (plist-get info :message))))))
(defun mu4e-error-handler (errcode errmsg) (defun mu4e-error-handler (errcode errmsg)
"Handler function for showing an error." "Handler function for showing an error."
@ -721,10 +721,10 @@ completion; for testing/debugging."
(mu4e-error "Emacs >= 23.x is required for mu4e")) (mu4e-error "Emacs >= 23.x is required for mu4e"))
(when mu4e~server-props (when mu4e~server-props
(let ((version (plist-get mu4e~server-props :version)) (let ((version (plist-get mu4e~server-props :version))
(mux (plist-get mu4e~server-props :mux))) (mux (plist-get mu4e~server-props :mux)))
(unless (or (string= version mu4e-mu-version) mux) (unless (or (string= version mu4e-mu-version) mux)
(mu4e-error "mu server has version %s, but we need %s" (mu4e-error "mu server has version %s, but we need %s"
version mu4e-mu-version)))) version mu4e-mu-version))))
(unless (and mu4e-mu-binary (file-executable-p mu4e-mu-binary)) (unless (and mu4e-mu-binary (file-executable-p mu4e-mu-binary))
(mu4e-error "Please set `mu4e-mu-binary' to the full path to the mu (mu4e-error "Please set `mu4e-mu-binary' to the full path to the mu
binary.")) binary."))
@ -736,16 +736,16 @@ completion; for testing/debugging."
(unless (mu4e-create-maildir-maybe mu4e-maildir) (unless (mu4e-create-maildir-maybe mu4e-maildir)
(mu4e-error "%s is not a valid maildir directory" mu4e-maildir)) (mu4e-error "%s is not a valid maildir directory" mu4e-maildir))
(dolist (var '(mu4e-sent-folder mu4e-drafts-folder (dolist (var '(mu4e-sent-folder mu4e-drafts-folder
mu4e-trash-folder)) mu4e-trash-folder))
(unless (and (boundp var) (symbol-value var)) (unless (and (boundp var) (symbol-value var))
(mu4e-error "Please set %S" var)) (mu4e-error "Please set %S" var))
(unless (functionp (symbol-value var)) ;; functions are okay, too (unless (functionp (symbol-value var)) ;; functions are okay, too
(let* ((dir (symbol-value var)) (let* ((dir (symbol-value var))
(path (concat mu4e-maildir dir))) (path (concat mu4e-maildir dir)))
(unless (string= (substring dir 0 1) "/") (unless (string= (substring dir 0 1) "/")
(mu4e-error "%S must start with a '/'" dir)) (mu4e-error "%S must start with a '/'" dir))
(unless (mu4e-create-maildir-maybe path) (unless (mu4e-create-maildir-maybe path)
(mu4e-error "%s (%S) does not exist" path var)))))) (mu4e-error "%s (%S) does not exist" path var))))))
(defun mu4e-running-p () (defun mu4e-running-p ()
@ -791,7 +791,7 @@ non-nil). Otherwise, check various requireme`'nts, then start mu4e.
When successful, call FUNC (if non-nil) afterwards." When successful, call FUNC (if non-nil) afterwards."
;; if we're already running, simply go to the main view ;; if we're already running, simply go to the main view
(if (mu4e-running-p) ;; already running? (if (mu4e-running-p) ;; already running?
(when func (funcall func)) ;; yes! run func if defined (when func (funcall func)) ;; yes! run func if defined
(progn (progn
;; no! try to set a context, do some checks, set up pong handler and ping ;; no! try to set a context, do some checks, set up pong handler and ping
;; the server maybe switch the context ;; the server maybe switch the context
@ -799,23 +799,23 @@ When successful, call FUNC (if non-nil) afterwards."
(mu4e~check-requirements) (mu4e~check-requirements)
;; set up the 'pong' handler func ;; set up the 'pong' handler func
(setq mu4e-pong-func (setq mu4e-pong-func
(lambda (props) (lambda (props)
(setq mu4e~server-props props) ;; save props from the server (setq mu4e~server-props props) ;; save props from the server
(let ((version (plist-get props :version)) (let ((version (plist-get props :version))
(doccount (plist-get props :doccount))) (doccount (plist-get props :doccount)))
(mu4e~check-requirements) (mu4e~check-requirements)
(when func (funcall func)) (when func (funcall func))
(when (zerop doccount) (when (zerop doccount)
(mu4e-message "Store is empty; (re)indexing. This can take a while.") ; (mu4e-message "Store is empty; (re)indexing. This can take a while.") ;
(mu4e-update-index)) (mu4e-update-index))
(when (and mu4e-update-interval (null mu4e~update-timer)) (when (and mu4e-update-interval (null mu4e~update-timer))
(setq mu4e~update-timer (setq mu4e~update-timer
(run-at-time (run-at-time
0 mu4e-update-interval 0 mu4e-update-interval
(lambda () (mu4e-update-mail-and-index (lambda () (mu4e-update-mail-and-index
mu4e-index-update-in-background))))) mu4e-index-update-in-background)))))
(mu4e-message "Started mu4e with %d message%s in store" (mu4e-message "Started mu4e with %d message%s in store"
doccount (if (= doccount 1) "" "s"))))) doccount (if (= doccount 1) "" "s")))))
;; wake up server ;; wake up server
(mu4e~proc-ping) (mu4e~proc-ping)
;; maybe request the list of contacts, automatically refresh after ;; maybe request the list of contacts, automatically refresh after
@ -840,9 +840,9 @@ When successful, call FUNC (if non-nil) afterwards."
(mapc (mapc
(lambda (buf) (lambda (buf)
(with-current-buffer buf (with-current-buffer buf
(when (member major-mode (when (member major-mode
'(mu4e-headers-mode mu4e-view-mode mu4e-main-mode)) '(mu4e-headers-mode mu4e-view-mode mu4e-main-mode))
(kill-buffer)))) (kill-buffer))))
(buffer-list))) (buffer-list)))
@ -862,31 +862,31 @@ Also scrolls to the final line, and update the progress throbber."
(when (string-match mu4e~get-mail-password-regexp msg) (when (string-match mu4e~get-mail-password-regexp msg)
(if (process-get proc 'x-interactive) (if (process-get proc 'x-interactive)
(process-send-string proc (process-send-string proc
(concat (read-passwd mu4e~get-mail-ask-password) (concat (read-passwd mu4e~get-mail-ask-password)
"\n")) "\n"))
;; TODO kill process? ;; TODO kill process?
(mu4e-error "Unrecognized password request"))) (mu4e-error "Unrecognized password request")))
(when (process-buffer proc) (when (process-buffer proc)
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(procwin (get-buffer-window (process-buffer proc)))) (procwin (get-buffer-window (process-buffer proc))))
;; Insert at end of buffer. Leave point alone. ;; Insert at end of buffer. Leave point alone.
(with-current-buffer (process-buffer proc) (with-current-buffer (process-buffer proc)
(goto-char (point-max)) (goto-char (point-max))
(if (string-match ".*\r\\(.*\\)" msg) (if (string-match ".*\r\\(.*\\)" msg)
(progn (progn
;; kill even with \r ;; kill even with \r
(end-of-line) (end-of-line)
(let ((end (point))) (let ((end (point)))
(beginning-of-line) (beginning-of-line)
(delete-region (point) end)) (delete-region (point) end))
(insert (match-string 1 msg))) (insert (match-string 1 msg)))
(insert msg))) (insert msg)))
;; Auto-scroll unless user is interacting with the window. ;; Auto-scroll unless user is interacting with the window.
(when (and (window-live-p procwin) (when (and (window-live-p procwin)
(not (eq (selected-window) procwin))) (not (eq (selected-window) procwin)))
(with-selected-window procwin (with-selected-window procwin
(goto-char (point-max))))))) (goto-char (point-max)))))))
(defun mu4e-update-index () (defun mu4e-update-index ()
"Update the mu4e index." "Update the mu4e index."
@ -903,7 +903,7 @@ Also scrolls to the final line, and update the progress throbber."
updating.") updating.")
(define-derived-mode mu4e~update-mail-mode special-mode "mu4e:update" (define-derived-mode mu4e~update-mail-mode special-mode "mu4e:update"
"Major mode used for retrieving new e-mail messages in `mu4e'.") "Major mode used for retrieving new e-mail messages in `mu4e'.")
(define-key mu4e~update-mail-mode-map (kbd "q") 'mu4e-kill-update-mail) (define-key mu4e~update-mail-mode-map (kbd "q") 'mu4e-kill-update-mail)
@ -911,9 +911,9 @@ Also scrolls to the final line, and update the progress throbber."
"Create a temporary window with HEIGHT at the bottom of the "Create a temporary window with HEIGHT at the bottom of the
frame to display buffer BUF." frame to display buffer BUF."
(let ((win (let ((win
(split-window (split-window
(frame-root-window) (frame-root-window)
(- (window-height (frame-root-window)) height)))) (- (window-height (frame-root-window)) height))))
(set-window-buffer win buf) (set-window-buffer win buf)
(set-window-dedicated-p win t) (set-window-dedicated-p win t)
win)) win))
@ -926,13 +926,13 @@ frame to display buffer BUF."
(unless mu4e-hide-index-messages (unless mu4e-hide-index-messages
(message nil)) (message nil))
(if (or (not (eq (process-status proc) 'exit)) (if (or (not (eq (process-status proc) 'exit))
(/= (process-exit-status proc) 0)) (/= (process-exit-status proc) 0))
(progn (progn
(when mu4e-index-update-error-warning (when mu4e-index-update-error-warning
(mu4e-message "Update process returned with non-zero exit code") (mu4e-message "Update process returned with non-zero exit code")
(sit-for 5)) (sit-for 5))
(when mu4e-index-update-error-continue (when mu4e-index-update-error-continue
(mu4e-update-index))) (mu4e-update-index)))
(mu4e-update-index)) (mu4e-update-index))
(when (buffer-live-p mu4e~update-buffer) (when (buffer-live-p mu4e~update-buffer)
(unless (eq mu4e-split-view 'single-window) (unless (eq mu4e-split-view 'single-window)
@ -948,24 +948,24 @@ frame to display buffer BUF."
RUN-IN-BACKGROUND is non-nil (or called with prefix-argument), RUN-IN-BACKGROUND is non-nil (or called with prefix-argument),
run in the background; otherwise, pop up a window." run in the background; otherwise, pop up a window."
(let* ((process-connection-type t) (let* ((process-connection-type t)
(proc (start-process-shell-command (proc (start-process-shell-command
"mu4e-update" " *mu4e-update*" "mu4e-update" " *mu4e-update*"
mu4e-get-mail-command)) mu4e-get-mail-command))
(buf (process-buffer proc)) (buf (process-buffer proc))
(win (or run-in-background (win (or run-in-background
(mu4e~temp-window buf mu4e~update-buffer-height)))) (mu4e~temp-window buf mu4e~update-buffer-height))))
(setq mu4e~update-buffer buf) (setq mu4e~update-buffer buf)
(when (window-live-p win) (when (window-live-p win)
(with-selected-window win (with-selected-window win
;; ;;(switch-to-buffer buf) ;; ;;(switch-to-buffer buf)
;; (set-window-dedicated-p win t) ;; (set-window-dedicated-p win t)
(erase-buffer) (erase-buffer)
(insert "\n") ;; FIXME -- needed so output start (insert "\n") ;; FIXME -- needed so output start
(mu4e~update-mail-mode))) (mu4e~update-mail-mode)))
(setq mu4e~progress-reporter (setq mu4e~progress-reporter
(unless mu4e-hide-index-messages (unless mu4e-hide-index-messages
(make-progress-reporter (make-progress-reporter
(mu4e-format "Retrieving mail...")))) (mu4e-format "Retrieving mail..."))))
(set-process-sentinel proc 'mu4e~update-sentinel-func) (set-process-sentinel proc 'mu4e~update-sentinel-func)
;; if we're running in the foreground, handle password requests ;; if we're running in the foreground, handle password requests
(unless run-in-background (unless run-in-background
@ -980,7 +980,7 @@ in the background; otherwise, pop up a window."
(unless mu4e-get-mail-command (unless mu4e-get-mail-command
(mu4e-error "`mu4e-get-mail-command' is not defined")) (mu4e-error "`mu4e-get-mail-command' is not defined"))
(if (and (buffer-live-p mu4e~update-buffer) (if (and (buffer-live-p mu4e~update-buffer)
(process-live-p (get-buffer-process mu4e~update-buffer))) (process-live-p (get-buffer-process mu4e~update-buffer)))
(mu4e-message "Update process is already running") (mu4e-message "Update process is already running")
(progn (progn
(run-hooks 'mu4e-update-pre-hook) (run-hooks 'mu4e-update-pre-hook)
@ -990,7 +990,7 @@ in the background; otherwise, pop up a window."
"Stop the update process by killing it." "Stop the update process by killing it."
(interactive) (interactive)
(let* ((proc (and (buffer-live-p mu4e~update-buffer) (let* ((proc (and (buffer-live-p mu4e~update-buffer)
(get-buffer-process mu4e~update-buffer)))) (get-buffer-process mu4e~update-buffer))))
(when (process-live-p proc) (when (process-live-p proc)
(kill-process proc t)))) (kill-process proc t))))
@ -1016,35 +1016,35 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging."
(view-mode) (view-mode)
(setq buffer-undo-list t) (setq buffer-undo-list t)
(let* ((inhibit-read-only t) (let* ((inhibit-read-only t)
(tstamp (propertize (format-time-string "%Y-%m-%d %T" (tstamp (propertize (format-time-string "%Y-%m-%d %T"
(current-time)) (current-time))
'face 'font-lock-string-face)) 'face 'font-lock-string-face))
(msg-face (msg-face
(cl-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)
(error 'font-lock-warning-face) (error 'font-lock-warning-face)
(otherwise (mu4e-error "Unsupported log type")))) (otherwise (mu4e-error "Unsupported log type"))))
(msg (propertize (apply 'format frm args) 'face msg-face))) (msg (propertize (apply 'format frm args) 'face msg-face)))
(goto-char (point-max))
(insert tstamp
(cl-case type
(from-server " <- ")
(to-server " -> ")
(error " !! ")
(otherwise " "))
msg "\n")
;; if `mu4e-log-max-lines is specified and exceeded, clearest the oldest
;; lines
(when (numberp mu4e~log-max-lines)
(let ((lines (count-lines (point-min) (point-max))))
(when (> lines mu4e~log-max-lines)
(goto-char (point-max)) (goto-char (point-max))
(forward-line (- mu4e~log-max-lines lines)) (insert tstamp
(beginning-of-line) (cl-case type
(delete-region (point-min) (point))))))))) (from-server " <- ")
(to-server " -> ")
(error " !! ")
(otherwise " "))
msg "\n")
;; if `mu4e-log-max-lines is specified and exceeded, clearest the oldest
;; lines
(when (numberp mu4e~log-max-lines)
(let ((lines (count-lines (point-min) (point-max))))
(when (> lines mu4e~log-max-lines)
(goto-char (point-max))
(forward-line (- mu4e~log-max-lines lines))
(beginning-of-line)
(delete-region (point-min) (point)))))))))
(defun mu4e-toggle-logging () (defun mu4e-toggle-logging ()
"Toggle between enabling/disabling debug-mode (in debug-mode, "Toggle between enabling/disabling debug-mode (in debug-mode,
@ -1072,30 +1072,30 @@ STR is a string; N is the highest possible number in the list.
This includes expanding e.g. 3-5 into 3,4,5. If the letter This includes expanding e.g. 3-5 into 3,4,5. If the letter
\"a\" ('all')) is given, that is expanded to a list with numbers [1..n]." \"a\" ('all')) is given, that is expanded to a list with numbers [1..n]."
(let ((str-split (split-string str)) (let ((str-split (split-string str))
beg end list) beg end list)
(dolist (elem str-split list) (dolist (elem str-split list)
;; special number "a" converts into all attachments 1-N. ;; special number "a" converts into all attachments 1-N.
(when (equal elem "a") (when (equal elem "a")
(setq elem (concat "1-" (int-to-string n)))) (setq elem (concat "1-" (int-to-string n))))
(if (string-match "\\([0-9]+\\)-\\([0-9]+\\)" elem) (if (string-match "\\([0-9]+\\)-\\([0-9]+\\)" elem)
;; we have found a range A-B, which needs converting ;; we have found a range A-B, which needs converting
;; into the numbers A, A+1, A+2, ... B. ;; into the numbers A, A+1, A+2, ... B.
(progn (progn
(setq beg (string-to-number (match-string 1 elem)) (setq beg (string-to-number (match-string 1 elem))
end (string-to-number (match-string 2 elem))) end (string-to-number (match-string 2 elem)))
(while (<= beg end) (while (<= beg end)
(cl-pushnew beg list :test 'equal) (cl-pushnew beg list :test 'equal)
(setq beg (1+ beg)))) (setq beg (1+ beg))))
;; else just a number ;; else just a number
(cl-pushnew (string-to-number elem) list :test 'equal))) (cl-pushnew (string-to-number elem) list :test 'equal)))
;; Check that all numbers are valid. ;; Check that all numbers are valid.
(mapc (mapc
#'(lambda (x) #'(lambda (x)
(cond (cond
((> x n) ((> x n)
(mu4e-warn "Attachment %d bigger than maximum (%d)" x n)) (mu4e-warn "Attachment %d bigger than maximum (%d)" x n))
((< x 1) ((< x 1)
(mu4e-warn "Attachment number must be greater than 0 (%d)" x)))) (mu4e-warn "Attachment number must be greater than 0 (%d)" x))))
list))) list)))
@ -1110,27 +1110,27 @@ MAXHEIGHT. Function tries to use imagemagick if available (ie.,
emacs was compiled with inmagemagick support); otherwise MAXWIDTH emacs was compiled with inmagemagick support); otherwise MAXWIDTH
and MAXHEIGHT are ignored." and MAXHEIGHT are ignored."
(let* ((have-im (and (fboundp 'imagemagick-types) (let* ((have-im (and (fboundp 'imagemagick-types)
(imagemagick-types))) ;; hmm, should check for specific type (imagemagick-types))) ;; hmm, should check for specific type
(identify (and have-im maxwidth (identify (and have-im maxwidth
(executable-find mu4e-imagemagick-identify))) (executable-find mu4e-imagemagick-identify)))
(props (and identify (shell-command-to-string (props (and identify (shell-command-to-string
(format "%s -format '%%w' %s" (format "%s -format '%%w' %s"
identify (shell-quote-argument imgpath))))) identify (shell-quote-argument imgpath)))))
(width (and props (string-to-number props))) (width (and props (string-to-number props)))
(img (if have-im (img (if have-im
(if (> (or width 0) (or maxwidth 0)) (if (> (or width 0) (or maxwidth 0))
(create-image imgpath 'imagemagick nil :width maxwidth) (create-image imgpath 'imagemagick nil :width maxwidth)
(create-image imgpath 'imagemagick)) (create-image imgpath 'imagemagick))
(create-image imgpath)))) (create-image imgpath))))
(when img (when img
(save-excursion (save-excursion
(insert "\n") (insert "\n")
(let ((size (image-size img))) ;; inspired by gnus.. (let ((size (image-size img))) ;; inspired by gnus..
(insert-char ?\n (insert-char ?\n
(max 0 (round (- (window-height) (or maxheight (cdr size)) 1) 2))) (max 0 (round (- (window-height) (or maxheight (cdr size)) 1) 2)))
(insert-char ?\. (insert-char ?\.
(max 0 (round (- (window-width) (or maxwidth (car size))) 2))) (max 0 (round (- (window-width) (or maxwidth (car size))) 2)))
(insert-image img)))))) (insert-image img))))))
(defun mu4e-hide-other-mu4e-buffers () (defun mu4e-hide-other-mu4e-buffers ()
@ -1142,12 +1142,12 @@ displaying it). Do _not_ bury the current buffer, though."
;; note: 'walk-windows' does not seem to work correctly when modifying ;; note: 'walk-windows' does not seem to work correctly when modifying
;; windows; therefore, the doloops here ;; windows; therefore, the doloops here
(dolist (frame (frame-list)) (dolist (frame (frame-list))
(dolist (win (window-list frame nil)) (dolist (win (window-list frame nil))
(with-current-buffer (window-buffer win) (with-current-buffer (window-buffer win)
(unless (eq curbuf (current-buffer)) (unless (eq curbuf (current-buffer))
(when (member major-mode '(mu4e-headers-mode mu4e-view-mode)) (when (member major-mode '(mu4e-headers-mode mu4e-view-mode))
(when (eq t (window-deletable-p win)) (when (eq t (window-deletable-p win))
(delete-window win))))))) t))) (delete-window win))))))) t)))
(defun mu4e-get-time-date (prompt) (defun mu4e-get-time-date (prompt)
@ -1173,9 +1173,9 @@ displaying it). Do _not_ bury the current buffer, though."
(setq buffer-read-only t) (setq buffer-read-only t)
(define-key mu4e-org-mode-map (kbd "q") (define-key mu4e-org-mode-map (kbd "q")
`(lambda () `(lambda ()
(interactive) (interactive)
(bury-buffer) (bury-buffer)
(switch-to-buffer ,curbuf))))) (switch-to-buffer ,curbuf)))))
(defun mu4e-about () (defun mu4e-about ()
"Show the mu4e 'about' page." "Show the mu4e 'about' page."
@ -1202,13 +1202,13 @@ used in the view and compose modes."
(goto-char (point-min)) (goto-char (point-min))
(when (search-forward-regexp "^\n" nil t) ;; search the first empty line (when (search-forward-regexp "^\n" nil t) ;; search the first empty line
(while (re-search-forward mu4e-cited-regexp nil t) (while (re-search-forward mu4e-cited-regexp nil t)
(let* ((level (string-width (replace-regexp-in-string (let* ((level (string-width (replace-regexp-in-string
"[^>]" "" (match-string 0)))) "[^>]" "" (match-string 0))))
(face (unless (zerop level) (face (unless (zerop level)
(intern-soft (format "mu4e-cited-%d-face" level))))) (intern-soft (format "mu4e-cited-%d-face" level)))))
(when face (when face
(add-text-properties (line-beginning-position 1) (add-text-properties (line-beginning-position 1)
(line-end-position 1) `(face ,face)))))))) (line-end-position 1) `(face ,face))))))))
(defun mu4e~fontify-signature () (defun mu4e~fontify-signature ()
"Give the message signatures a distinctive color. This is used in "Give the message signatures a distinctive color. This is used in
@ -1219,10 +1219,10 @@ the view and compose modes and will color each signature in digest messages adhe
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "^-- *$" nil t) (while (re-search-forward "^-- *$" nil t)
(let ((p (point)) (let ((p (point))
(end (or (end (or
(re-search-forward "\\(^-\\{30\\}.*$\\)" nil t) ;; 30 by RFC1153 (re-search-forward "\\(^-\\{30\\}.*$\\)" nil t) ;; 30 by RFC1153
(point-max)))) (point-max))))
(add-text-properties p end '(face mu4e-footer-face))))))) (add-text-properties p end '(face mu4e-footer-face)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e~quote-for-modeline (str) (defun mu4e~quote-for-modeline (str)
@ -1230,14 +1230,14 @@ the view and compose modes and will color each signature in digest messages adhe
string will be shortened to fit if its length exceeds string will be shortened to fit if its length exceeds
`mu4e-modeline-max-width'." `mu4e-modeline-max-width'."
(let* (;; Adjust the max-width to include the length of the " ..." string (let* (;; Adjust the max-width to include the length of the " ..." string
(width (let ((w (- mu4e-modeline-max-width 4))) (width (let ((w (- mu4e-modeline-max-width 4)))
(if (> w 0) w 0))) (if (> w 0) w 0)))
(str (let* ((l (length str)) (str (let* ((l (length str))
;; If the input str is longer than the max-width, then will shorten ;; If the input str is longer than the max-width, then will shorten
(w (if (> l width) width l)) (w (if (> l width) width l))
;; If the input str is longer than the max-width, then append " ..." ;; If the input str is longer than the max-width, then append " ..."
(a (if (> l width) " ..." ""))) (a (if (> l width) " ..." "")))
(concat (substring str 0 w) a)))) (concat (substring str 0 w) a))))
;; Escape the % character ;; Escape the % character
(replace-regexp-in-string "%" "%%" str t t))) (replace-regexp-in-string "%" "%%" str t t)))
@ -1248,9 +1248,9 @@ string will be shortened to fit if its length exceeds
(let (buffers) (let (buffers)
(save-excursion (save-excursion
(dolist (buffer (buffer-list t)) (dolist (buffer (buffer-list t))
(set-buffer buffer) (set-buffer buffer)
(when (eq major-mode 'mu4e-compose-mode) (when (eq major-mode 'mu4e-compose-mode)
(push (buffer-name buffer) buffers)))) (push (buffer-name buffer) buffers))))
(nreverse buffers))) (nreverse buffers)))
(provide 'mu4e-utils) (provide 'mu4e-utils)