fixup: mu4e: some cleanups / bytecomp warning fixes

This commit is contained in:
Dirk-Jan C. Binnema 2020-05-28 10:21:16 +03:00
parent 0a49cead33
commit 73be015cd0
6 changed files with 52 additions and 77 deletions

View File

@ -743,7 +743,7 @@ displaying in the header view."
mu4e-headers-fields " "))) mu4e-headers-fields " ")))
(mu4e~headers-line-handler msg line)))) (mu4e~headers-line-handler msg line))))
(defconst mu4e~searching "Searching...") (defconst mu4e~search-message "Searching...")
(defconst mu4e~no-matches "No matching messages found") (defconst mu4e~no-matches "No matching messages found")
(defconst mu4e~end-of-results "End of search results") (defconst mu4e~end-of-results "End of search results")
@ -1232,7 +1232,7 @@ the query history stack."
(unless (get-buffer-window buf 0) (unless (get-buffer-window buf 0)
(switch-to-buffer buf)) (switch-to-buffer buf))
(run-hook-with-args 'mu4e-headers-search-hook expr) (run-hook-with-args 'mu4e-headers-search-hook expr)
(mu4e~headers-clear mu4e~searching) (mu4e~headers-clear mu4e~search-message)
(mu4e~proc-find (mu4e~proc-find
rewritten-expr rewritten-expr
mu4e-headers-show-threads mu4e-headers-show-threads

View File

@ -27,7 +27,7 @@
(require 'smtpmail) ;; the queueing stuff (silence elint) (require 'smtpmail) ;; the queueing stuff (silence elint)
(require 'mu4e-utils) ;; utility functions (require 'mu4e-utils) ;; utility functions
(require 'mu4e-context) ;; the context (require 'mu4e-context) ;; the context
(require 'mu4e-vars) ;; the context (require 'mu4e-vars) ;; mu-wide variables
(require 'cl-lib) (require 'cl-lib)
;;; Mode ;;; Mode
@ -43,10 +43,6 @@ part of the personal addresses.")
"When set to t, do not hide bookmarks or maildirs that have "When set to t, do not hide bookmarks or maildirs that have
no unread messages.") no unread messages.")
(defvar mu4e-main-buffer-name " *mu4e-main*"
"Name of the mu4e main view buffer. The default name starts
with SPC and therefore is not visible in buffer list.")
(defvar mu4e-main-mode-map (defvar mu4e-main-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -220,8 +216,7 @@ clicked."
(defun mu4e~main-view-real-1 (&optional refresh) (defun mu4e~main-view-real-1 (&optional refresh)
"Create `mu4e-main-buffer-name' and set it up. "Create `mu4e-main-buffer-name' and set it up.
When REFRESH is non nil refresh infos from server." When REFRESH is non nil refresh infos from server."
(let ((inhibit-read-only t) (let ((inhibit-read-only t))
(pos (point)))
;; Maybe refresh infos from server. ;; Maybe refresh infos from server.
(if refresh (if refresh
(mu4e~start 'mu4e~main-redraw-buffer) (mu4e~start 'mu4e~main-redraw-buffer)

View File

@ -28,16 +28,13 @@
(require 'cl-lib) (require 'cl-lib)
(require 'mu4e-vars) (require 'mu4e-vars)
(require 'mu4e-utils)
(require 'flow-fill) (require 'flow-fill)
(require 'shr)
(defvar mu4e~view-message) (defvar mu4e~view-message)
(defvar shr-inhibit-images) (defvar shr-inhibit-images)
(defcustom mu4e-html2text-command (defcustom mu4e-html2text-command 'mu4e-shr2text
(if (fboundp 'shr-insert-document)
'mu4e-shr2text
(progn (require 'html2text) 'html2text))
"Either a shell command or a function that converts from html to plain text. "Either a shell command or a function that converts from html to plain text.
If it is a shell command, the command reads html from standard If it is a shell command, the command reads html from standard
@ -55,9 +52,7 @@ and expected to transform this (like the `html2text' function).
In all cases, the output is expected to be in UTF-8 encoding. In all cases, the output is expected to be in UTF-8 encoding.
Newer emacs has the shr renderer, and when it's available The default is to use the shr renderer."
conversion defaults to `mu4e-shr2text'; otherwise, the default is
emacs' built-in `html2text' function."
:type '(choice string function) :type '(choice string function)
:group 'mu4e-view) :group 'mu4e-view)

View File

@ -26,11 +26,11 @@
;;; Code: ;;; Code:
(eval-when-compile (require 'org)
(require 'org nil 'noerror))
(require 'cl-lib) (require 'cl-lib)
(require 'cl-seq nil 'noerror) (require 'cl-seq nil 'noerror)
(require 'mu4e-vars) (require 'mu4e-vars)
(require 'mu4e-message)
(require 'mu4e-meta) (require 'mu4e-meta)
(require 'mu4e-lists) (require 'mu4e-lists)
(require 'doc-view) (require 'doc-view)
@ -45,40 +45,15 @@
(declare-function mu4e~proc-mkdir "mu4e-proc") (declare-function mu4e~proc-mkdir "mu4e-proc")
(declare-function mu4e~proc-running-p "mu4e-proc") (declare-function mu4e~proc-running-p "mu4e-proc")
(declare-function mu4e-message-field-at-point "mu4e-proc")
(declare-function mu4e~proc-running-p "mu4e-proc")
(declare-function mu4e~context-autoswitch "mu4e-context") (declare-function mu4e~context-autoswitch "mu4e-context")
(declare-function mu4e-context-determine "mu4e-context") (declare-function mu4e-context-determine "mu4e-context")
(declare-function mu4e-context-vars "mu4e-context") (declare-function mu4e-context-vars "mu4e-context")
(declare-function show-all "org") (declare-function show-all "org")
;; the following is taken from org.el; we copy it here since we don't want to
;; depend on org-mode directly (it causes byte-compilation errors) TODO: a
;; cleaner solution....
(defconst mu4e~ts-regexp0
(concat
"\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)"
"\\( +[^]+0-9>\r\n -]+\\)?\\( +\\([0-9]\\{1,2\\}\\):"
"\\([0-9]\\{2\\}\\)\\)?\\)")
"Regular expression matching time strings for analysis.
This one does not require the space after the date, so it can be
used on a string that terminates immediately after the date.")
(defun mu4e-parse-time-string (s &optional nodefault)
"Parse the standard Org-mode time string.
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
(if (or (match-beginning 8) (not nodefault))
(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 (match-string 4 s))
(string-to-number (match-string 3 s))
(string-to-number (match-string 2 s))
nil nil nil)
(mu4e-error "Not a standard mu4e time string: %s" s)))
;;; Various ;;; Various
(defun mu4e-copy-message-path () (defun mu4e-copy-message-path ()
@ -1167,7 +1142,7 @@ displaying it). Do _not_ bury the current buffer, though."
after PROMPT. Formats are all that are accepted by after PROMPT. Formats are all that are accepted by
`parse-time-string'." `parse-time-string'."
(let ((timestr (read-string (mu4e-format "%s" prompt)))) (let ((timestr (read-string (mu4e-format "%s" prompt))))
(apply 'encode-time (mu4e-parse-time-string timestr)))) (apply 'encode-time (org-parse-time-string timestr))))
;;; Mu4e-org-mode ;;; Mu4e-org-mode
@ -1259,6 +1234,33 @@ string will be shortened to fit if its length exceeds
(push (buffer-name buffer) buffers)))) (push (buffer-name buffer) buffers))))
(nreverse buffers))) (nreverse buffers)))
;;
;; Loading messages
;;
(defvar mu4e-loading-mode-map nil "Keymap for *mu4e-loading* buffers.")
(unless mu4e-loading-mode-map
(setq mu4e-loading-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "n" 'ignore)
(define-key map "p" 'ignore)
(define-key map "q"
(lambda()(interactive)
(if (eq mu4e-split-view 'single-window)
'kill-buffer
'kill-buffer-and-window)))
map)))
(fset 'mu4e-loading-mode-map mu4e-loading-mode-map)
(define-derived-mode mu4e-loading-mode special-mode
"mu4e:loading"
(use-local-map mu4e-loading-mode-map)
(let ((inhibit-read-only t))
(erase-buffer)
(insert (propertize "Loading message..."
'face 'mu4e-system-face 'intangible t))))
;;; _ ;;; _
(provide 'mu4e-utils) (provide 'mu4e-utils)
;;; mu4e-utils.el ends here ;;; mu4e-utils.el ends here

View File

@ -966,7 +966,15 @@ Note that when using the gnus-based view (see
message fields: only the ones used in the header-view, not message fields: only the ones used in the header-view, not
including, for instance, the message body.") including, for instance, the message body.")
;;; Run-time variables ;;; Run-time variables / constants
;;;; Main
(defvar mu4e-main-buffer-name " *mu4e-main*"
"Name of the mu4e main view buffer. The default name starts
with SPC and therefore is not visible in buffer list.")
;;;; Headers ;;;; Headers
(defconst mu4e~headers-buffer-name "*mu4e-headers*" (defconst mu4e~headers-buffer-name "*mu4e-headers*"
@ -1021,6 +1029,7 @@ mu4e-compose.")
(mu4e-error "version unknown; did you start mu4e?")) (mu4e-error "version unknown; did you start mu4e?"))
version)) version))
;;; Handler functions ;;; Handler functions
;; ;;

View File

@ -37,6 +37,7 @@
(require 'mu4e-message) (require 'mu4e-message)
(eval-when-compile (require 'gnus-art)) (eval-when-compile (require 'gnus-art))
(require 'comint) (require 'comint)
(require 'browse-url) (require 'browse-url)
(require 'button) (require 'button)
@ -1816,33 +1817,6 @@ other windows."
(setq mu4e~headers-view-win nil) (setq mu4e~headers-view-win nil)
(when (buffer-live-p (mu4e-get-headers-buffer)) (when (buffer-live-p (mu4e-get-headers-buffer))
(switch-to-buffer (mu4e-get-headers-buffer)))))))) (switch-to-buffer (mu4e-get-headers-buffer))))))))
;;
;; Loading messages
;;
(defvar mu4e-loading-mode-map nil "Keymap for *mu4e-loading* buffers.")
(unless mu4e-loading-mode-map
(setq mu4e-loading-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "n" 'ignore)
(define-key map "p" 'ignore)
(define-key map "q"
(lambda()(interactive)
(if (eq mu4e-split-view 'single-window)
'kill-buffer
'kill-buffer-and-window)))
map)))
(fset 'mu4e-loading-mode-map mu4e-loading-mode-map)
(define-derived-mode mu4e-loading-mode special-mode
"mu4e:loading"
(use-local-map mu4e-loading-mode-map)
(let ((inhibit-read-only t))
(erase-buffer)
(insert (propertize "Loading message..."
'face 'mu4e-system-face 'intangible t))))
;;; ;;;
(provide 'mu4e-view) (provide 'mu4e-view)
;;; mu4e-view.el ends here ;;; mu4e-view.el ends here