From cf594413e2e102fdbcac6df5d47c7c99bfab716d Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 13 Jan 2020 12:47:49 +0200 Subject: [PATCH] mu4e: utils: fix indentation --- mu4e/mu4e-utils.el | 666 ++++++++++++++++++++++----------------------- 1 file changed, 333 insertions(+), 333 deletions(-) diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index d9136a8d..965fd427 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -1,6 +1,6 @@ ;;; 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 ;; Maintainer: Dirk-Jan C. Binnema @@ -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 NODEFAULT, hour and minute fields will be nil if not given." (if (string-match mu4e~ts-regexp0 s) - (list 0 + (list 0 (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)) - (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 3 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 insensitive comparison is used." (when (and addr mu4e-user-mail-address-list - (cl-find addr mu4e-user-mail-address-list - :test (lambda (s1 s2) - (eq t (compare-strings s1 nil nil s2 nil nil t))))) + (cl-find addr mu4e-user-mail-address-list + :test (lambda (s1 s2) + (eq t (compare-strings s1 nil nil s2 nil nil 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 return the result." (unless (member foldervar - '(mu4e-sent-folder mu4e-drafts-folder - mu4e-trash-folder mu4e-refile-folder)) + '(mu4e-sent-folder mu4e-drafts-folder + mu4e-trash-folder mu4e-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 (with~mu4e-context-vars (mu4e-context-determine msg nil) (let* ((folder (symbol-value foldervar)) - (val - (cond - ((stringp folder) folder) - ((functionp folder) (funcall folder msg)) - (t (mu4e-error "unsupported type for %S" folder))))) + (val + (cond + ((stringp folder) folder) + ((functionp folder) (funcall folder msg)) + (t (mu4e-error "unsupported type for %S" folder))))) (or val (mu4e-error "%S evaluates to nil" foldervar))))) (defun mu4e-get-drafts-folder (&optional msg) @@ -143,7 +143,7 @@ return the result." (defun mu4e-remove-file-later (filename) "Remove FILENAME in a few seconds." (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 ((dir (cond - ((stringp mu4e-attachment-dir) - mu4e-attachment-dir) - ((functionp mu4e-attachment-dir) - (funcall mu4e-attachment-dir fname mimetype)) - (t - (mu4e-error "unsupported type for mu4e-attachment-dir" ))))) + ((stringp mu4e-attachment-dir) + mu4e-attachment-dir) + ((functionp mu4e-attachment-dir) + (funcall mu4e-attachment-dir fname mimetype)) + (t + (mu4e-error "unsupported type for mu4e-attachment-dir" ))))) (if dir (expand-file-name dir) (mu4e-error (mu4e-error "mu4e-attachment-dir evaluates to nil"))))) @@ -184,10 +184,10 @@ see its docstring)." (let ((idx (string-match mu4e-maildir path))) (when (and idx (zerop idx)) (replace-regexp-in-string - mu4e-maildir - "" - (expand-file-name - (concat path "/../..")))))) + mu4e-maildir + "" + (expand-file-name + (concat path "/../..")))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -254,8 +254,8 @@ trying an exact match." (message nil);; this seems needed... (setq choice (read-char-exclusive prompt)) (setq chosen (or (member choice choices) - (member (downcase choice) choices) - (member (upcase choice) choices)))) + (member (downcase choice) choices) + (member (upcase choice) choices)))) (car chosen))) (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." (let* ((prompt (mu4e-format "%s" prompt)) - (chosen) - (optionsstr - (mapconcat - (lambda (option) - ;; try to detect old-style options, and warn - (when (characterp (car-safe (cdr-safe option))) - (mu4e-error - (concat "Please use the new format for options/actions; " - "see the manual"))) - (let* ((kar (substring (car option) 0 1)) - (val (cdr option))) - (concat - "[" (propertize kar 'face 'mu4e-highlight-face) "]" - (substring (car option) 1)))) - options ", ")) - (response - (mu4e~read-char-choice - (concat prompt optionsstr - " [" (propertize "C-g" 'face 'mu4e-highlight-face) - " to cancel]") - ;; the allowable chars - (cl-map 'list (lambda(elm) (string-to-char (car elm))) options))) - (chosen - (cl-find-if - (lambda (option) (eq response (string-to-char (car option)))) - options))) + (chosen) + (optionsstr + (mapconcat + (lambda (option) + ;; try to detect old-style options, and warn + (when (characterp (car-safe (cdr-safe option))) + (mu4e-error + (concat "Please use the new format for options/actions; " + "see the manual"))) + (let* ((kar (substring (car option) 0 1)) + (val (cdr option))) + (concat + "[" (propertize kar 'face 'mu4e-highlight-face) "]" + (substring (car option) 1)))) + options ", ")) + (response + (mu4e~read-char-choice + (concat prompt optionsstr + " [" (propertize "C-g" 'face 'mu4e-highlight-face) + " to cancel]") + ;; the allowable chars + (cl-map 'list (lambda(elm) (string-to-char (car elm))) options))) + (chosen + (cl-find-if + (lambda (option) (eq response (string-to-char (car option)))) + options))) (if chosen (cdr chosen) (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) "Get maildirs under path, recursively, as a list of relative paths." (let ((dirs) - (dentries - (ignore-errors - (directory-files-and-attributes - (concat path mdir) nil - "^[^.]\\|\\.[^.][^.]" t)))) + (dentries + (ignore-errors + (directory-files-and-attributes + (concat path mdir) nil + "^[^.]\\|\\.[^.][^.]" t)))) (dolist (dentry dentries) (when (and (booleanp (cadr dentry)) (cadr dentry)) - (if (file-accessible-directory-p - (concat mu4e-maildir "/" mdir "/" (car dentry) "/cur")) - (setq dirs (cons (concat mdir (car dentry)) dirs))) - (unless (member (car dentry) '("cur" "new" "tmp")) - (setq dirs (append dirs (mu4e~get-maildirs-1 path - (concat mdir (car dentry) "/"))))))) + (if (file-accessible-directory-p + (concat mu4e-maildir "/" mdir "/" (car dentry) "/cur")) + (setq dirs (cons (concat mdir (car dentry)) dirs))) + (unless (member (car dentry) '("cur" "new" "tmp")) + (setq dirs (append dirs (mu4e~get-maildirs-1 path + (concat mdir (car dentry) "/"))))))) dirs)) (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) (setq mu4e-maildir-list (sort - (append - (when (file-accessible-directory-p - (concat mu4e-maildir "/cur")) '("/")) - (mu4e~get-maildirs-1 mu4e-maildir "/")) - (lambda (s1 s2) (string< (downcase s1) (downcase s2)))))) + (append + (when (file-accessible-directory-p + (concat mu4e-maildir "/cur")) '("/")) + (mu4e~get-maildirs-1 mu4e-maildir "/")) + (lambda (s1 s2) (string< (downcase s1) (downcase s2)))))) mu4e-maildir-list) (defun mu4e-ask-maildir (prompt) @@ -365,34 +365,34 @@ maildirs under `mu4e-maildir'." (if (not mu4e-maildir-shortcuts) (funcall mu4e-completing-read-function prompt (mu4e-get-maildirs)) (let* ((mlist (append mu4e-maildir-shortcuts '(("ther" . ?o)))) - (fnames - (mapconcat - (lambda (item) - (concat - "[" - (propertize (make-string 1 (cdr item)) - 'face 'mu4e-highlight-face) - "]" - (car item))) - mlist ", ")) - (kar (read-char (concat prompt fnames)))) - (if (member kar '(?/ ?o)) ;; user chose 'other'? - (funcall mu4e-completing-read-function prompt - (mu4e-get-maildirs) nil nil "/") - (or (car-safe - (cl-find-if (lambda (item) (= kar (cdr item))) - mu4e-maildir-shortcuts)) - (mu4e-warn "Unknown shortcut '%c'" kar))))))) + (fnames + (mapconcat + (lambda (item) + (concat + "[" + (propertize (make-string 1 (cdr item)) + 'face 'mu4e-highlight-face) + "]" + (car item))) + mlist ", ")) + (kar (read-char (concat prompt fnames)))) + (if (member kar '(?/ ?o)) ;; user chose 'other'? + (funcall mu4e-completing-read-function prompt + (mu4e-get-maildirs) nil nil "/") + (or (car-safe + (cl-find-if (lambda (item) (= kar (cdr item))) + mu4e-maildir-shortcuts)) + (mu4e-warn "Unknown shortcut '%c'" kar))))))) (defun mu4e-ask-maildir-check-exists (prompt) "Like `mu4e-ask-maildir', but check for existence of the maildir, and offer to create it if it does not exist yet." (let* ((mdir (mu4e-ask-maildir prompt)) - (fullpath (concat mu4e-maildir mdir))) + (fullpath (concat mu4e-maildir mdir))) (unless (file-directory-p fullpath) (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))) mdir)) @@ -403,8 +403,8 @@ old format if needed." (lambda (item) (if (and (listp item) (= (length item) 3)) `(:name ,(nth 1 item) - :query ,(nth 0 item) - :key ,(nth 2 item)) + :query ,(nth 0 item) + :key ,(nth 2 item)) item)) mu4e-bookmarks)) @@ -413,30 +413,30 @@ old format if needed." `mu4e-bookmarks', then return the corresponding query." (unless (mu4e-bookmarks) (mu4e-error "No bookmarks defined")) (let* ((prompt (mu4e-format "%s" prompt)) - (bmarks - (mapconcat - (lambda (bm) - (concat - "[" (propertize (make-string 1 (plist-get bm :key)) - 'face 'mu4e-highlight-face) - "]" - (plist-get bm :name))) (mu4e-bookmarks) ", ")) - (kar (read-char (concat prompt bmarks)))) + (bmarks + (mapconcat + (lambda (bm) + (concat + "[" (propertize (make-string 1 (plist-get bm :key)) + 'face 'mu4e-highlight-face) + "]" + (plist-get bm :name))) (mu4e-bookmarks) ", ")) + (kar (read-char (concat prompt bmarks)))) (mu4e-get-bookmark-query kar))) (defun mu4e-get-bookmark-query (kar) "Get the corresponding bookmarked query for shortcut character KAR, or raise an error if none is found." (let* ((chosen-bm - (or (cl-find-if - (lambda (bm) - (= kar (plist-get bm :key))) - (mu4e-bookmarks)) - (mu4e-warn "Unknown shortcut '%c'" kar))) - (expr (plist-get chosen-bm :query)) - (expr (if (not (functionp expr)) expr - (funcall expr))) - (query (eval expr))) + (or (cl-find-if + (lambda (bm) + (= kar (plist-get bm :key))) + (mu4e-bookmarks)) + (mu4e-warn "Unknown shortcut '%c'" kar))) + (expr (plist-get chosen-bm :query)) + (expr (if (not (functionp expr)) expr + (funcall expr))) + (query (eval expr))) (if (stringp query) query (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 replaces any existing bookmark with KEY." (setq mu4e-bookmarks - (cl-remove-if - (lambda (bm) - (= (plist-get bm :key) key)) - (mu4e-bookmarks))) + (cl-remove-if + (lambda (bm) + (= (plist-get bm :key) key)) + (mu4e-bookmarks))) (cl-pushnew `(:name ,name - :query ,query + :query ,query :key ,key) mu4e-bookmarks :test 'equal)) @@ -468,25 +468,25 @@ Also see `mu4e-flags-to-string'. \[1\]: http://cr.yp.to/proto/maildir.html" (when flags (let ((kar (cl-case (car flags) - ('draft ?D) - ('flagged ?F) - ('new ?N) - ('passed ?P) - ('replied ?R) - ('seen ?S) - ('trashed ?T) - ('attach ?a) - ('encrypted ?x) - ('signed ?s) - ('unread ?u)))) + ('draft ?D) + ('flagged ?F) + ('new ?N) + ('passed ?P) + ('replied ?R) + ('seen ?S) + ('trashed ?T) + ('attach ?a) + ('encrypted ?x) + ('signed ?s) + ('unread ?u)))) (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) "Remove duplicates and sort the output of `mu4e~flags-to-string-raw'." (concat (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) "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." (when (/= 0 (length str)) (let ((flag - (cl-case (string-to-char str) - (?D 'draft) - (?F 'flagged) - (?P 'passed) - (?R 'replied) - (?S 'seen) - (?T 'trashed)))) + (cl-case (string-to-char str) + (?D 'draft) + (?F 'flagged) + (?P 'passed) + (?R 'replied) + (?S 'seen) + (?T 'trashed)))) (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) "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." (interactive) (info (cl-case major-mode - ('mu4e-main-mode "(mu4e)Main view") - ('mu4e-headers-mode "(mu4e)Headers view") - ('mu4e-view-mode "(mu4e)Message view") - (t "mu4e")))) + ('mu4e-main-mode "(mu4e)Main view") + ('mu4e-headers-mode "(mu4e)Headers view") + ('mu4e-view-mode "(mu4e)Message view") + (t "mu4e")))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (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." (interactive) (let* ((other-buf - (cond - ((eq major-mode 'mu4e-headers-mode) - (mu4e-get-view-buffer)) - ((eq major-mode 'mu4e-view-mode) - (mu4e-get-headers-buffer)))) - (other-win (and other-buf (get-buffer-window other-buf)))) + (cond + ((eq major-mode 'mu4e-headers-mode) + (mu4e-get-view-buffer)) + ((eq major-mode 'mu4e-view-mode) + (mu4e-get-headers-buffer)))) + (other-win (and other-buf (get-buffer-window other-buf)))) (if (window-live-p other-win) (select-window other-win) (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))) (with-current-buffer buf (let ((inhibit-read-only t)) - (erase-buffer) - (call-process-shell-command pipecmd path t t) - (view-mode))) + (erase-buffer) + (call-process-shell-command pipecmd path t t) + (view-mode))) (switch-to-buffer buf))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -601,11 +601,11 @@ on `mu4e~mailing-lists', `mu4e-user-mailing-lists', and (or (gethash list-id mu4e~lists-hash) (and (boundp 'mu4e-mailing-list-patterns) - (cl-member-if - (lambda (pattern) - (string-match pattern list-id)) - mu4e-mailing-list-patterns) - (match-string 1 list-id)) + (cl-member-if + (lambda (pattern) + (string-match pattern list-id)) + mu4e-mailing-list-patterns) + (match-string 1 list-id)) ;; if it's not in the db, take the part until the first dot if there is one; ;; otherwise just return the whole thing (if (string-match "\\([^.]*\\)\\." list-id) @@ -627,7 +627,7 @@ used as a simple way to invoke some action when a message changed.") (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 ;; @@ -638,20 +638,20 @@ process." (cond ((eq type 'add) t) ;; do nothing ((eq type 'index) - (if (eq (plist-get info :status) 'running) - (mu4e-index-message "Indexing... processed %d, updated %d" - (plist-get info :processed) (plist-get info :updated)) - (progn - (mu4e-index-message - "Indexing completed; processed %d, updated %d, cleaned-up %d" - (plist-get info :processed) (plist-get info :updated) - (plist-get info :cleaned-up)) - (unless (and (not (string= mu4e~contacts-tstamp "0")) - (zerop (plist-get info :updated))) - (mu4e~request-contacts-maybe) - (run-hooks 'mu4e-index-updated-hook))))) + (if (eq (plist-get info :status) 'running) + (mu4e-index-message "Indexing... processed %d, updated %d" + (plist-get info :processed) (plist-get info :updated)) + (progn + (mu4e-index-message + "Indexing completed; processed %d, updated %d, cleaned-up %d" + (plist-get info :processed) (plist-get info :updated) + (plist-get info :cleaned-up)) + (unless (and (not (string= mu4e~contacts-tstamp "0")) + (zerop (plist-get info :updated))) + (mu4e~request-contacts-maybe) + (run-hooks 'mu4e-index-updated-hook))))) ((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) "Handler function for showing an error." @@ -721,10 +721,10 @@ completion; for testing/debugging." (mu4e-error "Emacs >= 23.x is required for mu4e")) (when mu4e~server-props (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) - (mu4e-error "mu server has version %s, but we need %s" - version mu4e-mu-version)))) + (mu4e-error "mu server has version %s, but we need %s" + version mu4e-mu-version)))) (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 binary.")) @@ -736,16 +736,16 @@ completion; for testing/debugging." (unless (mu4e-create-maildir-maybe mu4e-maildir) (mu4e-error "%s is not a valid maildir directory" mu4e-maildir)) (dolist (var '(mu4e-sent-folder mu4e-drafts-folder - mu4e-trash-folder)) + mu4e-trash-folder)) (unless (and (boundp var) (symbol-value var)) (mu4e-error "Please set %S" var)) (unless (functionp (symbol-value var)) ;; functions are okay, too (let* ((dir (symbol-value var)) - (path (concat mu4e-maildir dir))) - (unless (string= (substring dir 0 1) "/") - (mu4e-error "%S must start with a '/'" dir)) - (unless (mu4e-create-maildir-maybe path) - (mu4e-error "%s (%S) does not exist" path var)))))) + (path (concat mu4e-maildir dir))) + (unless (string= (substring dir 0 1) "/") + (mu4e-error "%S must start with a '/'" dir)) + (unless (mu4e-create-maildir-maybe path) + (mu4e-error "%s (%S) does not exist" path var)))))) (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." ;; if we're already running, simply go to the main view (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 ;; no! try to set a context, do some checks, set up pong handler and ping ;; the server maybe switch the context @@ -799,23 +799,23 @@ When successful, call FUNC (if non-nil) afterwards." (mu4e~check-requirements) ;; set up the 'pong' handler func (setq mu4e-pong-func - (lambda (props) - (setq mu4e~server-props props) ;; save props from the server - (let ((version (plist-get props :version)) - (doccount (plist-get props :doccount))) - (mu4e~check-requirements) - (when func (funcall func)) - (when (zerop doccount) - (mu4e-message "Store is empty; (re)indexing. This can take a while.") ; - (mu4e-update-index)) - (when (and mu4e-update-interval (null mu4e~update-timer)) - (setq mu4e~update-timer - (run-at-time - 0 mu4e-update-interval - (lambda () (mu4e-update-mail-and-index - mu4e-index-update-in-background))))) - (mu4e-message "Started mu4e with %d message%s in store" - doccount (if (= doccount 1) "" "s"))))) + (lambda (props) + (setq mu4e~server-props props) ;; save props from the server + (let ((version (plist-get props :version)) + (doccount (plist-get props :doccount))) + (mu4e~check-requirements) + (when func (funcall func)) + (when (zerop doccount) + (mu4e-message "Store is empty; (re)indexing. This can take a while.") ; + (mu4e-update-index)) + (when (and mu4e-update-interval (null mu4e~update-timer)) + (setq mu4e~update-timer + (run-at-time + 0 mu4e-update-interval + (lambda () (mu4e-update-mail-and-index + mu4e-index-update-in-background))))) + (mu4e-message "Started mu4e with %d message%s in store" + doccount (if (= doccount 1) "" "s"))))) ;; wake up server (mu4e~proc-ping) ;; maybe request the list of contacts, automatically refresh after @@ -840,9 +840,9 @@ When successful, call FUNC (if non-nil) afterwards." (mapc (lambda (buf) (with-current-buffer buf - (when (member major-mode - '(mu4e-headers-mode mu4e-view-mode mu4e-main-mode)) - (kill-buffer)))) + (when (member major-mode + '(mu4e-headers-mode mu4e-view-mode mu4e-main-mode)) + (kill-buffer)))) (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) (if (process-get proc 'x-interactive) - (process-send-string proc - (concat (read-passwd mu4e~get-mail-ask-password) - "\n")) + (process-send-string proc + (concat (read-passwd mu4e~get-mail-ask-password) + "\n")) ;; TODO kill process? (mu4e-error "Unrecognized password request"))) (when (process-buffer proc) (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. (with-current-buffer (process-buffer proc) - (goto-char (point-max)) - (if (string-match ".*\r\\(.*\\)" msg) - (progn - ;; kill even with \r - (end-of-line) - (let ((end (point))) - (beginning-of-line) - (delete-region (point) end)) - (insert (match-string 1 msg))) - (insert msg))) + (goto-char (point-max)) + (if (string-match ".*\r\\(.*\\)" msg) + (progn + ;; kill even with \r + (end-of-line) + (let ((end (point))) + (beginning-of-line) + (delete-region (point) end)) + (insert (match-string 1 msg))) + (insert msg))) ;; Auto-scroll unless user is interacting with the window. (when (and (window-live-p procwin) - (not (eq (selected-window) procwin))) - (with-selected-window procwin - (goto-char (point-max))))))) + (not (eq (selected-window) procwin))) + (with-selected-window procwin + (goto-char (point-max))))))) (defun mu4e-update-index () "Update the mu4e index." @@ -903,7 +903,7 @@ Also scrolls to the final line, and update the progress throbber." updating.") (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) @@ -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 frame to display buffer BUF." (let ((win - (split-window - (frame-root-window) - (- (window-height (frame-root-window)) height)))) + (split-window + (frame-root-window) + (- (window-height (frame-root-window)) height)))) (set-window-buffer win buf) (set-window-dedicated-p win t) win)) @@ -926,13 +926,13 @@ frame to display buffer BUF." (unless mu4e-hide-index-messages (message nil)) (if (or (not (eq (process-status proc) 'exit)) - (/= (process-exit-status proc) 0)) - (progn - (when mu4e-index-update-error-warning - (mu4e-message "Update process returned with non-zero exit code") - (sit-for 5)) - (when mu4e-index-update-error-continue - (mu4e-update-index))) + (/= (process-exit-status proc) 0)) + (progn + (when mu4e-index-update-error-warning + (mu4e-message "Update process returned with non-zero exit code") + (sit-for 5)) + (when mu4e-index-update-error-continue + (mu4e-update-index))) (mu4e-update-index)) (when (buffer-live-p mu4e~update-buffer) (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 the background; otherwise, pop up a window." (let* ((process-connection-type t) - (proc (start-process-shell-command - "mu4e-update" " *mu4e-update*" - mu4e-get-mail-command)) - (buf (process-buffer proc)) - (win (or run-in-background - (mu4e~temp-window buf mu4e~update-buffer-height)))) + (proc (start-process-shell-command + "mu4e-update" " *mu4e-update*" + mu4e-get-mail-command)) + (buf (process-buffer proc)) + (win (or run-in-background + (mu4e~temp-window buf mu4e~update-buffer-height)))) (setq mu4e~update-buffer buf) (when (window-live-p win) (with-selected-window win - ;; ;;(switch-to-buffer buf) - ;; (set-window-dedicated-p win t) - (erase-buffer) - (insert "\n") ;; FIXME -- needed so output start - (mu4e~update-mail-mode))) + ;; ;;(switch-to-buffer buf) + ;; (set-window-dedicated-p win t) + (erase-buffer) + (insert "\n") ;; FIXME -- needed so output start + (mu4e~update-mail-mode))) (setq mu4e~progress-reporter (unless mu4e-hide-index-messages - (make-progress-reporter - (mu4e-format "Retrieving mail...")))) + (make-progress-reporter + (mu4e-format "Retrieving mail...")))) (set-process-sentinel proc 'mu4e~update-sentinel-func) ;; if we're running in the foreground, handle password requests (unless run-in-background @@ -980,7 +980,7 @@ in the background; otherwise, pop up a window." (unless mu4e-get-mail-command (mu4e-error "`mu4e-get-mail-command' is not defined")) (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") (progn (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." (interactive) (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) (kill-process proc t)))) @@ -1016,35 +1016,35 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging." (view-mode) (setq buffer-undo-list t) (let* ((inhibit-read-only t) - (tstamp (propertize (format-time-string "%Y-%m-%d %T" - (current-time)) - 'face 'font-lock-string-face)) - (msg-face - (cl-case type - (from-server 'font-lock-type-face) - (to-server 'font-lock-function-name-face) - (misc 'font-lock-variable-name-face) - (error 'font-lock-warning-face) - (otherwise (mu4e-error "Unsupported log type")))) - (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) + (tstamp (propertize (format-time-string "%Y-%m-%d %T" + (current-time)) + 'face 'font-lock-string-face)) + (msg-face + (cl-case type + (from-server 'font-lock-type-face) + (to-server 'font-lock-function-name-face) + (misc 'font-lock-variable-name-face) + (error 'font-lock-warning-face) + (otherwise (mu4e-error "Unsupported log type")))) + (msg (propertize (apply 'format frm args) 'face msg-face))) (goto-char (point-max)) - (forward-line (- mu4e~log-max-lines lines)) - (beginning-of-line) - (delete-region (point-min) (point))))))))) + (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)) + (forward-line (- mu4e~log-max-lines lines)) + (beginning-of-line) + (delete-region (point-min) (point))))))))) (defun mu4e-toggle-logging () "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 \"a\" ('all')) is given, that is expanded to a list with numbers [1..n]." (let ((str-split (split-string str)) - beg end list) + beg end list) (dolist (elem str-split list) ;; special number "a" converts into all attachments 1-N. (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) - ;; we have found a range A-B, which needs converting - ;; into the numbers A, A+1, A+2, ... B. - (progn - (setq beg (string-to-number (match-string 1 elem)) - end (string-to-number (match-string 2 elem))) - (while (<= beg end) + ;; we have found a range A-B, which needs converting + ;; into the numbers A, A+1, A+2, ... B. + (progn + (setq beg (string-to-number (match-string 1 elem)) + end (string-to-number (match-string 2 elem))) + (while (<= beg end) (cl-pushnew beg list :test 'equal) - (setq beg (1+ beg)))) - ;; else just a number + (setq beg (1+ beg)))) + ;; else just a number (cl-pushnew (string-to-number elem) list :test 'equal))) ;; Check that all numbers are valid. (mapc #'(lambda (x) - (cond - ((> x n) - (mu4e-warn "Attachment %d bigger than maximum (%d)" x n)) - ((< x 1) - (mu4e-warn "Attachment number must be greater than 0 (%d)" x)))) + (cond + ((> x n) + (mu4e-warn "Attachment %d bigger than maximum (%d)" x n)) + ((< x 1) + (mu4e-warn "Attachment number must be greater than 0 (%d)" x)))) list))) @@ -1110,27 +1110,27 @@ MAXHEIGHT. Function tries to use imagemagick if available (ie., emacs was compiled with inmagemagick support); otherwise MAXWIDTH and MAXHEIGHT are ignored." (let* ((have-im (and (fboundp 'imagemagick-types) - (imagemagick-types))) ;; hmm, should check for specific type - (identify (and have-im maxwidth - (executable-find mu4e-imagemagick-identify))) - (props (and identify (shell-command-to-string - (format "%s -format '%%w' %s" - identify (shell-quote-argument imgpath))))) - (width (and props (string-to-number props))) - (img (if have-im - (if (> (or width 0) (or maxwidth 0)) - (create-image imgpath 'imagemagick nil :width maxwidth) - (create-image imgpath 'imagemagick)) - (create-image imgpath)))) + (imagemagick-types))) ;; hmm, should check for specific type + (identify (and have-im maxwidth + (executable-find mu4e-imagemagick-identify))) + (props (and identify (shell-command-to-string + (format "%s -format '%%w' %s" + identify (shell-quote-argument imgpath))))) + (width (and props (string-to-number props))) + (img (if have-im + (if (> (or width 0) (or maxwidth 0)) + (create-image imgpath 'imagemagick nil :width maxwidth) + (create-image imgpath 'imagemagick)) + (create-image imgpath)))) (when img (save-excursion - (insert "\n") - (let ((size (image-size img))) ;; inspired by gnus.. - (insert-char ?\n - (max 0 (round (- (window-height) (or maxheight (cdr size)) 1) 2))) - (insert-char ?\. - (max 0 (round (- (window-width) (or maxwidth (car size))) 2))) - (insert-image img)))))) + (insert "\n") + (let ((size (image-size img))) ;; inspired by gnus.. + (insert-char ?\n + (max 0 (round (- (window-height) (or maxheight (cdr size)) 1) 2))) + (insert-char ?\. + (max 0 (round (- (window-width) (or maxwidth (car size))) 2))) + (insert-image img)))))) (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 ;; windows; therefore, the doloops here (dolist (frame (frame-list)) - (dolist (win (window-list frame nil)) - (with-current-buffer (window-buffer win) - (unless (eq curbuf (current-buffer)) - (when (member major-mode '(mu4e-headers-mode mu4e-view-mode)) - (when (eq t (window-deletable-p win)) - (delete-window win))))))) t))) + (dolist (win (window-list frame nil)) + (with-current-buffer (window-buffer win) + (unless (eq curbuf (current-buffer)) + (when (member major-mode '(mu4e-headers-mode mu4e-view-mode)) + (when (eq t (window-deletable-p win)) + (delete-window win))))))) t))) (defun mu4e-get-time-date (prompt) @@ -1173,9 +1173,9 @@ displaying it). Do _not_ bury the current buffer, though." (setq buffer-read-only t) (define-key mu4e-org-mode-map (kbd "q") `(lambda () - (interactive) - (bury-buffer) - (switch-to-buffer ,curbuf))))) + (interactive) + (bury-buffer) + (switch-to-buffer ,curbuf))))) (defun mu4e-about () "Show the mu4e 'about' page." @@ -1202,13 +1202,13 @@ used in the view and compose modes." (goto-char (point-min)) (when (search-forward-regexp "^\n" nil t) ;; search the first empty line (while (re-search-forward mu4e-cited-regexp nil t) - (let* ((level (string-width (replace-regexp-in-string - "[^>]" "" (match-string 0)))) - (face (unless (zerop level) - (intern-soft (format "mu4e-cited-%d-face" level))))) - (when face - (add-text-properties (line-beginning-position 1) - (line-end-position 1) `(face ,face)))))))) + (let* ((level (string-width (replace-regexp-in-string + "[^>]" "" (match-string 0)))) + (face (unless (zerop level) + (intern-soft (format "mu4e-cited-%d-face" level))))) + (when face + (add-text-properties (line-beginning-position 1) + (line-end-position 1) `(face ,face)))))))) (defun mu4e~fontify-signature () "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)) (while (re-search-forward "^-- *$" nil t) (let ((p (point)) - (end (or - (re-search-forward "\\(^-\\{30\\}.*$\\)" nil t) ;; 30 by RFC1153 - (point-max)))) - (add-text-properties p end '(face mu4e-footer-face))))))) + (end (or + (re-search-forward "\\(^-\\{30\\}.*$\\)" nil t) ;; 30 by RFC1153 + (point-max)))) + (add-text-properties p end '(face mu4e-footer-face))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (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 `mu4e-modeline-max-width'." (let* (;; Adjust the max-width to include the length of the " ..." string - (width (let ((w (- mu4e-modeline-max-width 4))) - (if (> w 0) w 0))) - (str (let* ((l (length str)) - ;; If the input str is longer than the max-width, then will shorten - (w (if (> l width) width l)) - ;; If the input str is longer than the max-width, then append " ..." - (a (if (> l width) " ..." ""))) - (concat (substring str 0 w) a)))) + (width (let ((w (- mu4e-modeline-max-width 4))) + (if (> w 0) w 0))) + (str (let* ((l (length str)) + ;; If the input str is longer than the max-width, then will shorten + (w (if (> l width) width l)) + ;; If the input str is longer than the max-width, then append " ..." + (a (if (> l width) " ..." ""))) + (concat (substring str 0 w) a)))) ;; Escape the % character (replace-regexp-in-string "%" "%%" str t t))) @@ -1248,9 +1248,9 @@ string will be shortened to fit if its length exceeds (let (buffers) (save-excursion (dolist (buffer (buffer-list t)) - (set-buffer buffer) - (when (eq major-mode 'mu4e-compose-mode) - (push (buffer-name buffer) buffers)))) + (set-buffer buffer) + (when (eq major-mode 'mu4e-compose-mode) + (push (buffer-name buffer) buffers)))) (nreverse buffers))) (provide 'mu4e-utils)