From 8d1175f511f7c411e2c61793fdb68293ec5072ae Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 10 Mar 2021 20:49:40 +0200 Subject: [PATCH] mu4e: avoid some compiler warnings (require) necessary things etc. warnings for using "obsolete" code are still there since things should work on emacs 25.3 --- mu4e/mu4e-compose.el | 11 ++++++----- mu4e/mu4e-headers.el | 42 ++++++++---------------------------------- mu4e/mu4e-icalendar.el | 25 ++++++++++++++----------- mu4e/mu4e-org.el | 5 +++-- mu4e/mu4e-utils.el | 24 ++++++++++++------------ mu4e/mu4e-vars.el | 21 ++++++++++++++++++++- 6 files changed, 63 insertions(+), 65 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 200eee2d..4e4a6e10 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -164,7 +164,7 @@ not a contradiction, but a redundant configuration. All `sign-*' options have a `encrypt-*' analogue." :type '(set :greedy t - (const :tag "Sign all messages" sign-all-messages) + (const :tag "Sign all messages" sign-all-messages) (const :tag "Encrypt all messages" encrypt-all-messages) (const :tag "Sign new messages" sign-new-messages) (const :tag "Encrypt new messages" encrypt-new-messages) @@ -392,9 +392,9 @@ Message-ID." "Complete address STR with predication PRED for ACTION." (cond ((eq action nil) - (try-completion str mu4e~contacts pred)) + (try-completion str mu4e~contacts-hash pred)) ((eq action t) - (all-completions str mu4e~contacts pred)) + (all-completions str mu4e~contacts-hash pred)) ((eq action 'metadata) ;; our contacts are already sorted - just need to tell the ;; completion machinery not to try to undo that... @@ -511,7 +511,8 @@ buffers; lets remap its faces so it uses the ones for mu4e." (set (make-local-variable 'message-send-mail-real-function) nil) (make-local-variable 'message-default-charset) ;; Set to nil to enable `electric-quote-local-mode' to work: - (set (make-variable-buffer-local 'comment-use-syntax) nil) + (make-local-variable 'comment-use-syntax) + (setq comment-use-syntax nil) ;; message-mode has font-locking, but uses its own faces. Let's ;; use the mu4e-specific ones instead (mu4e~compose-remap-faces) @@ -521,7 +522,7 @@ buffers; lets remap its faces so it uses the ones for mu4e." (mu4e~compose-register-message-save-hooks) ;; offer completion for e-mail addresses (when mu4e-compose-complete-addresses - (unless mu4e~contacts ;; work-around for https://github.com/djcb/mu/issues/1016 + (unless mu4e~contacts-hash ;; work-around for https://github.com/djcb/mu/issues/1016 (mu4e~request-contacts-maybe)) (mu4e~compose-setup-completion)) (if mu4e-compose-format-flowed diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index 3da526cc..b0b51d85 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -42,8 +42,6 @@ (require 'mu4e-actions) (require 'mu4e-message) -(eval-when-compile (require 'mu4e-view)) - (declare-function mu4e-view "mu4e-view") (declare-function mu4e~main-view "mu4e-main") @@ -328,9 +326,6 @@ followed by the docid, followed by `mu4e~headers-docid-post'.") "Each header starts (invisibly) with the `mu4e~headers-docid-pre', followed by the docid, followed by `mu4e~headers-docid-post'.") -(defvar mu4e~headers-view-win nil - "The view window connected to this headers view.") - (defvar mu4e~headers-sort-field-choices '( ("date" . :date) ("from" . :from) @@ -727,15 +722,15 @@ space propertized with a 'display text property which expands to (setq val (string-trim-right val)) (if (> width (length val)) (setq val (concat val " ")) - (setq val - (concat - (truncate-string-to-width val (1- width) 0 ?\s t) - " "))) + (setq val + (concat + (truncate-string-to-width val (1- width) 0 ?\s t) + " "))) (put-text-property (1- (length val)) - (length val) - 'display - `(space . (:align-to ,end-col)) - val))) + (length val) + 'display + `(space . (:align-to ,end-col)) + val))) val) (defsubst mu4e~headers-truncate-field (field val width) @@ -1249,27 +1244,6 @@ docid is not found." (mu4e-error "Cannot find message with docid %S" docid))))) ;;; Queries & searching - -(defcustom mu4e-query-rewrite-function 'identity - "Function that takes a search expression string, and returns a - possibly changed search expression string. - -This function is applied on the search expression just before -searching, and allows users to modify the query. - -For instance, we could change and of workmail into -\"maildir:/long-path-to-work-related-emails\", by setting the function - -(setq mu4e-query-rewrite-function - (lambda(expr) - (replace-regexp-in-string \"workmail\" - \"maildir:/long-path-to-work-related-emails\" expr))) - -It is good to remember that the replacement does not understand -anything about the query, it just does text replacement." - :type 'function - :group 'mu4e) - (defvar mu4e~headers-mode-line-label "") (defun mu4e~headers-update-mode-line () "Update mode-line settings." diff --git a/mu4e/mu4e-icalendar.el b/mu4e/mu4e-icalendar.el index 6c25466a..e36c1f81 100644 --- a/mu4e/mu4e-icalendar.el +++ b/mu4e/mu4e-icalendar.el @@ -1,4 +1,4 @@ -;;; mu4e-icalendar.el --- reply to iCalendar meeting requests (part of mu4e) -*- lexical-binding: t; -*- -*- lexical-binding: t -*- +;;; mu4e-icalendar.el --- reply to iCalendar meeting requests (part of mu4e) -*- lexical-binding: t; -*- ;; Copyright (C) 2019- Christophe Troestler @@ -52,8 +52,11 @@ (require 'gnus-icalendar) (require 'cl-lib) -(eval-when-compile (require 'mu4e-mark)) -(eval-when-compile (require 'mu4e-vars)) +(require 'mu4e-mark) +(require 'mu4e-utils) +(require 'mu4e-headers) +(require 'mu4e-view) +(require 'mu4e-vars) ;;;###autoload (defun mu4e-icalendar-setup () @@ -79,7 +82,7 @@ (gnus-icalendar-additional-identities (mu4e-personal-addresses 'no-regexp)) (reply (gnus-icalendar-with-decoded-handle handle - (let ((gnus-icalendar-find-if (lambda(pred seq) nil))) + (let ((gnus-icalendar-find-if (lambda(_pred _seq) nil))) (gnus-icalendar-event-reply-from-buffer (current-buffer) status (gnus-icalendar-identities))))) (msg (mu4e-message-at-point 'noerror)) @@ -104,11 +107,11 @@ ;; Back in article buffer (setq-local gnus-icalendar-reply-status status) - (when gnus-icalendar-org-enabled-p - (if (gnus-icalendar-find-org-event-file event) - (gnus-icalendar--update-org-event event status) - (gnus-icalendar:org-event-save event status))) - (when mu4e-icalendar-diary-file + (when gnus-icalendar-org-enabled-p + (if (gnus-icalendar-find-org-event-file event) + (gnus-icalendar--update-org-event event status) + (gnus-icalendar:org-event-save event status))) + (when mu4e-icalendar-diary-file (mu4e~icalendar-insert-diary event status mu4e-icalendar-diary-file)))))) @@ -141,8 +144,8 @@ See `gnus-icalendar-event-reply-from-buffer' for the possible STATUS values. BUFFER-NAME is the name of the buffer holding the response in icalendar format." (let ((message-signature nil)) - (let ((mu4e-compose-cite-function #'mu4e~icalendar-delete-citation) - (mu4e-sent-messages-behavior 'delete) + (let ((_mu4e-compose-cite-function #'mu4e~icalendar-delete-citation) + (_mu4e-sent-messages-behavior 'delete) (mu4e-compose-reply-recipients 'sender)) (mu4e~compose-handler 'reply original-msg)) ;; Make sure the recipient is the organizer diff --git a/mu4e/mu4e-org.el b/mu4e/mu4e-org.el index 0242f581..c4040aaf 100644 --- a/mu4e/mu4e-org.el +++ b/mu4e/mu4e-org.el @@ -1,11 +1,10 @@ ;;; mu4e-org -- Org-links to mu4e messages/queries -*- lexical-binding: t -*- -;; Copyright (C) 2012-2020 Dirk-Jan C. Binnema +;; Copyright (C) 2012-2021 Dirk-Jan C. Binnema ;; Author: Dirk-Jan C. Binnema ;; Maintainer: Dirk-Jan C. Binnema ;; Keywords: outlines, hypermedia, calendar, mail -;; Version: 0.0 ;; This file is not part of GNU Emacs. @@ -29,6 +28,8 @@ ;;; Code: (require 'org) +(require 'mu4e-view) +(require 'mu4e-utils) (defgroup mu4e-org nil "Settings for the org-mode related functionality in mu4e." diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index b2aca025..3295b06f 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -667,9 +667,8 @@ process." (defun mu4e~update-contacts (contacts &optional tstamp) "Receive a sorted list of CONTACTS. Each of the contacts has the form - (FULL_EMAIL_ADDRESS . RANK) and fill the hash -`mu4e~contacts' with it, with each contact mapped to an integer -for their ranking. + (FULL_EMAIL_ADDRESS . RANK) and fill `mu4e~contacts-hash' with +it, with each contact mapped to an integer for their ranking. This is used by the completion function in mu4e-compose." ;; We have our nicely sorted list, map them to a list @@ -677,8 +676,8 @@ This is used by the completion function in mu4e-compose." ;; to sort them there. It would have been so much easier if emacs ;; allowed us to use the sorted-list as-is, but no such luck. (let ((n 0)) - (unless mu4e~contacts - (setq mu4e~contacts (make-hash-table :test 'equal :weakness nil + (unless mu4e~contacts-hash + (setq mu4e~contacts-hash (make-hash-table :test 'equal :weakness nil :size (length contacts)))) (dolist (contact contacts) (cl-incf n) @@ -690,13 +689,13 @@ This is used by the completion function in mu4e-compose." (when address ;; note the explicit deccode; the strings we get are utf-8, ;; but emacs doesn't know yet. (puthash (decode-coding-string address 'utf-8) - (plist-get contact :rank) mu4e~contacts)))) + (plist-get contact :rank) mu4e~contacts-hash)))) (setq mu4e~contacts-tstamp (or tstamp "0")) (unless (zerop n) (mu4e-index-message "Contacts updated: %d; total %d" - n (hash-table-count mu4e~contacts))))) + n (hash-table-count mu4e~contacts-hash))))) (defun mu4e-contacts-info () "Display information about the cache used for contacts @@ -711,12 +710,13 @@ completion; for testing/debugging." (insert (format "only addresses seen after: %s\n" (or mu4e-compose-complete-only-after "no restrictions"))) - (when mu4e~contacts + (when mu4e~contacts-hash (insert (format "number of contacts cached: %d\n\n" - (hash-table-count mu4e~contacts))) + (hash-table-count mu4e~contacts-hash))) (let ((contacts)) (maphash (lambda (addr rank) - (setq contacts (cons (cons rank addr) contacts))) mu4e~contacts) + (setq contacts (cons (cons rank addr) contacts))) + mu4e~contacts-hash) (setq contacts (sort contacts (lambda(cell1 cell2) (< (car cell1) (car cell2))))) (dolist (contact contacts) @@ -837,13 +837,13 @@ When successful, call FUNC (if non-nil) afterwards." (mu4e~maildirs-with-query))))) ;; maybe request the list of contacts, automatically refreshed after ;; reindexing - (unless mu4e~contacts (mu4e~request-contacts-maybe))) + (unless mu4e~contacts-hash (mu4e~request-contacts-maybe))) (defun mu4e-clear-caches () "Clear any cached resources." (setq mu4e-maildir-list nil - mu4e~contacts nil + mu4e~contacts-hash nil mu4e~contacts-tstamp "0")) (defun mu4e~stop () diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 5526af07..e63e90ec 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -279,6 +279,25 @@ differ from the number you get from a 'real' query." :version "1.3.9" :group 'mu4e) +(defcustom mu4e-query-rewrite-function 'identity + "Function that takes a search expression string, and returns a + possibly changed search expression string. + +This function is applied on the search expression just before +searching, and allows users to modify the query. + +For instance, we could change and of workmail into +\"maildir:/long-path-to-work-related-emails\", by setting the function + +(setq mu4e-query-rewrite-function + (lambda(expr) + (replace-regexp-in-string \"workmail\" + \"maildir:/long-path-to-work-related-emails\" expr))) + +It is good to remember that the replacement does not understand +anything about the query, it just does text replacement." + :type 'function + :group 'mu4e) (defun mu4e-bookmarks () "Get `mu4e-bookmarks' in the (new) format, converting from the @@ -1031,7 +1050,7 @@ with SPC and therefore is not visible in buffer list.") ;;;; Other -(defvar mu4e~contacts nil +(defvar mu4e~contacts-hash nil "Hash that maps contacts (ie. 'name ') to an integer for sorting. We need to keep this information around to quickly re-sort subsets of the contacts in the completions function in