1
0
mirror of https://github.com/djcb/mu.git synced 2024-06-21 06:56:48 +02:00
This commit is contained in:
Pedro Ribeiro Mendes Júnior 2020-01-16 08:28:08 -03:00
commit 5d087a130b
7 changed files with 521 additions and 531 deletions

View File

@ -63,6 +63,16 @@
- Add message-id's to messages when saving drafts, so we can find them even
with ~mu4e-headers-skip-duplicates~.
- Bookmarks (as in ~mu4e-bookmarks~) are now simple plists (instead of cl
structs). ~make-mu4e-bookmark~ has been updated to produce such plists (for
backward compatibility). A bookmark now looks like a list of e.g.
~(:name "My bookmark" :query "banana OR pear" :key ?f)~
this format is a bit easier extensible.
- For instance, we now recognize an attribute ~:hide t~, which will hide the
bookmark item from the main-screen (and speedbar), but keep it avilable
through the completion UI.
*** toys
- Updated the ~mug~ toy UI to use Webkit2/GTK+. Note that this is just a toy

View File

@ -437,7 +437,7 @@ You can append flags."
;; otherwise...
(concat
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg))))))))
(mu4e~draft-header "Cc" (mu4e~draft-recipients-construct :cc origmsg :reply-all))))))))
(defun mu4e~draft-reply-construct-recipients-list (origmsg)
"Determine the to/cc recipients for a reply message to a

View File

@ -1,6 +1,6 @@
;;; mu4e-main.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*-
;;
;; Copyright (C) 2011-2016 Dirk-Jan C. Binnema
;; Copyright (C) 2011-2020 Dirk-Jan C. Binnema
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -87,18 +87,18 @@ when STR is clicked (using RET or mouse-2); if FUNC-OR-SHORTCUT is
a string, execute the corresponding keyboard action when it is
clicked."
(let ((newstr
(replace-regexp-in-string
"\\[\\(..?\\)\\]"
(lambda(m)
(format "[%s]"
(propertize (match-string 1 m) 'face 'mu4e-highlight-face)))
str))
(map (make-sparse-keymap))
(func (if (functionp func-or-shortcut)
func-or-shortcut
(if (stringp func-or-shortcut)
(lambda()(interactive)
(execute-kbd-macro func-or-shortcut))))))
(replace-regexp-in-string
"\\[\\(..?\\)\\]"
(lambda(m)
(format "[%s]"
(propertize (match-string 1 m) 'face 'mu4e-highlight-face)))
str))
(map (make-sparse-keymap))
(func (if (functionp func-or-shortcut)
func-or-shortcut
(if (stringp func-or-shortcut)
(lambda()(interactive)
(execute-kbd-macro func-or-shortcut))))))
(define-key map [mouse-2] func)
(define-key map (kbd "RET") func)
(put-text-property 0 (length newstr) 'keymap map newstr)
@ -111,96 +111,97 @@ clicked."
;; buffer switching at the end.
(defun mu4e~main-view-real (ignore-auto noconfirm)
(let ((buf (get-buffer-create mu4e~main-buffer-name))
(inhibit-read-only t))
(inhibit-read-only t))
(with-current-buffer buf
(erase-buffer)
(insert
"* "
(propertize "mu4e - mu for emacs version " 'face 'mu4e-title-face)
(propertize mu4e-mu-version 'face 'mu4e-header-key-face)
"* "
(propertize "mu4e - mu for emacs version " 'face 'mu4e-title-face)
(propertize mu4e-mu-version 'face 'mu4e-header-key-face)
;; show some server properties; in this case; a big C when there's
;; crypto support, a big G when there's Guile support
" "
(propertize
(concat
(when (plist-get mu4e~server-props :crypto) "C")
(when (plist-get mu4e~server-props :guile) "G")
(when (plist-get mu4e~server-props :mux) "X"))
'face 'mu4e-title-face)
;; show some server properties; in this case; a big C when there's
;; crypto support, a big G when there's Guile support
" "
(propertize
(concat
(when (plist-get mu4e~server-props :crypto) "C")
(when (plist-get mu4e~server-props :guile) "G")
(when (plist-get mu4e~server-props :mux) "X"))
'face 'mu4e-title-face)
"\n\n"
(propertize " Basics\n\n" 'face 'mu4e-title-face)
(mu4e~main-action-str
"\t* [j]ump to some maildir\n" 'mu4e-jump-to-maildir)
(mu4e~main-action-str
"\t* enter a [s]earch query\n" 'mu4e-search)
(mu4e~main-action-str
"\t* [C]ompose a new message\n" 'mu4e-compose-new)
"\n"
(propertize " Bookmarks\n\n" 'face 'mu4e-title-face)
;; TODO: it's a bit uncool to hard-code the "b" shortcut...
(mapconcat
(lambda (bm)
(mu4e~main-action-str
(concat "\t* [b" (make-string 1 (mu4e-bookmark-key bm)) "] "
(mu4e-bookmark-name bm))
(concat "b" (make-string 1 (mu4e-bookmark-key bm)))))
(mu4e-bookmarks) "\n")
"\n\n"
(propertize " Misc\n\n" 'face 'mu4e-title-face)
"\n\n"
(propertize " Basics\n\n" 'face 'mu4e-title-face)
(mu4e~main-action-str
"\t* [j]ump to some maildir\n" 'mu4e-jump-to-maildir)
(mu4e~main-action-str
"\t* enter a [s]earch query\n" 'mu4e-search)
(mu4e~main-action-str
"\t* [C]ompose a new message\n" 'mu4e-compose-new)
"\n"
(propertize " Bookmarks\n\n" 'face 'mu4e-title-face)
;; TODO: it's a bit uncool to hard-code the "b" shortcut...
(mapconcat
(lambda (bm)
(unless (plist-get bm :hide)
(mu4e~main-action-str
(concat "\t* [b" (make-string 1 (plist-get bm :key)) "] "
(plist-get bm :name))
(concat "b" (make-string 1 (plist-get bm :key))))))
(mu4e-bookmarks) "\n")
"\n\n"
(propertize " Misc\n\n" 'face 'mu4e-title-face)
(mu4e~main-action-str "\t* [;]Switch context\n" 'mu4e-context-switch)
(mu4e~main-action-str "\t* [;]Switch context\n" 'mu4e-context-switch)
(mu4e~main-action-str "\t* [U]pdate email & database\n"
'mu4e-update-mail-and-index)
(mu4e~main-action-str "\t* [U]pdate email & database\n"
'mu4e-update-mail-and-index)
;; show the queue functions if `smtpmail-queue-dir' is defined
(if (file-directory-p smtpmail-queue-dir)
(mu4e~main-view-queue)
"")
"\n"
(mu4e~main-action-str "\t* [N]ews\n" 'mu4e-news)
(mu4e~main-action-str "\t* [A]bout mu4e\n" 'mu4e-about)
(mu4e~main-action-str "\t* [H]elp\n" 'mu4e-display-manual)
(mu4e~main-action-str "\t* [q]uit\n" 'mu4e-quit))
;; show the queue functions if `smtpmail-queue-dir' is defined
(if (file-directory-p smtpmail-queue-dir)
(mu4e~main-view-queue)
"")
"\n"
(mu4e~main-action-str "\t* [N]ews\n" 'mu4e-news)
(mu4e~main-action-str "\t* [A]bout mu4e\n" 'mu4e-about)
(mu4e~main-action-str "\t* [H]elp\n" 'mu4e-display-manual)
(mu4e~main-action-str "\t* [q]uit\n" 'mu4e-quit))
(mu4e-main-mode)
)))
(defun mu4e~main-view-queue ()
"Display queue-related actions in the main view."
(concat
(mu4e~main-action-str "\t* toggle [m]ail sending mode "
'mu4e~main-toggle-mail-sending-mode)
"(currently "
(propertize (if smtpmail-queue-mail "queued" "direct")
'face 'mu4e-header-key-face)
")\n"
(let ((queue-size (mu4e~main-queue-size)))
(if (zerop queue-size)
""
(mu4e~main-action-str
(format "\t* [f]lush %s queued %s\n"
(propertize (int-to-string queue-size)
'face 'mu4e-header-key-face)
(if (> queue-size 1) "mails" "mail"))
'smtpmail-send-queued-mail)))))
(mu4e~main-action-str "\t* toggle [m]ail sending mode "
'mu4e~main-toggle-mail-sending-mode)
"(currently "
(propertize (if smtpmail-queue-mail "queued" "direct")
'face 'mu4e-header-key-face)
")\n"
(let ((queue-size (mu4e~main-queue-size)))
(if (zerop queue-size)
""
(mu4e~main-action-str
(format "\t* [f]lush %s queued %s\n"
(propertize (int-to-string queue-size)
'face 'mu4e-header-key-face)
(if (> queue-size 1) "mails" "mail"))
'smtpmail-send-queued-mail)))))
(defun mu4e~main-queue-size ()
"Return, as an int, the number of emails in the queue."
(condition-case nil
(with-temp-buffer
(insert-file-contents (expand-file-name smtpmail-queue-index-file
smtpmail-queue-dir))
(count-lines (point-min) (point-max)))
(with-temp-buffer
(insert-file-contents (expand-file-name smtpmail-queue-index-file
smtpmail-queue-dir))
(count-lines (point-min) (point-max)))
(error 0)))
(defun mu4e~main-view ()
"Create the mu4e main-view, and switch to it."
(if (eq mu4e-split-view 'single-window)
(if (buffer-live-p (mu4e-get-headers-buffer))
(switch-to-buffer (mu4e-get-headers-buffer))
(mu4e~main-menu))
(if (buffer-live-p (mu4e-get-headers-buffer))
(switch-to-buffer (mu4e-get-headers-buffer))
(mu4e~main-menu))
(mu4e~main-view-real nil nil)
(switch-to-buffer mu4e~main-buffer-name)
(goto-char (point-min)))
@ -217,7 +218,7 @@ clicked."
(mu4e-error "`smtpmail-queue-dir' does not exist"))
(setq smtpmail-queue-mail (not smtpmail-queue-mail))
(message (concat "Outgoing mail will now be "
(if smtpmail-queue-mail "queued" "sent directly")))
(if smtpmail-queue-mail "queued" "sent directly")))
(unless (eq mu4e-split-view 'single-window)
(let ((curpos (point)))
(mu4e~main-view-real nil nil)
@ -227,36 +228,29 @@ clicked."
"mu4e main view in the minibuffer."
(interactive)
(let ((key
(read-key
(mu4e-format
"%s"
(concat
(mu4e~main-action-str "[j]ump " 'mu4e-jump-to-maildir)
(mu4e~main-action-str "[s]earch " 'mu4e-search)
(mu4e~main-action-str "[C]ompose " 'mu4e-compose-new)
(mu4e~main-action-str "[b]ookmarks " 'mu4e-headers-search-bookmark)
(mu4e~main-action-str "[;]Switch context " 'mu4e-context-switch)
(mu4e~main-action-str "[U]pdate " 'mu4e-update-mail-and-index)
(mu4e~main-action-str "[N]ews " 'mu4e-news)
(mu4e~main-action-str "[A]bout " 'mu4e-about)
(mu4e~main-action-str "[H]elp " 'mu4e-display-manual))))))
(read-key
(mu4e-format
"%s"
(concat
(mu4e~main-action-str "[j]ump " 'mu4e-jump-to-maildir)
(mu4e~main-action-str "[s]earch " 'mu4e-search)
(mu4e~main-action-str "[C]ompose " 'mu4e-compose-new)
(mu4e~main-action-str "[b]ookmarks " 'mu4e-headers-search-bookmark)
(mu4e~main-action-str "[;]Switch context " 'mu4e-context-switch)
(mu4e~main-action-str "[U]pdate " 'mu4e-update-mail-and-index)
(mu4e~main-action-str "[N]ews " 'mu4e-news)
(mu4e~main-action-str "[A]bout " 'mu4e-about)
(mu4e~main-action-str "[H]elp " 'mu4e-display-manual))))))
(unless (member key '(?\C-g ?\C-\[))
(let ((mu4e-command (lookup-key mu4e-main-mode-map (string key) t)))
(if mu4e-command
(condition-case err
(let ((mu4e-hide-index-messages t))
(call-interactively mu4e-command))
(error (when (cadr err) (message (cadr err)))))
(message (mu4e-format "key %s not bound to a command" (string key))))
(when (or (not mu4e-command) (eq mu4e-command 'mu4e-context-switch))
(sit-for 1)
(mu4e~main-menu))))))
;; (progn
;; (define-key mu4e-compose-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; (define-key mu4e-view-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; (define-key mu4e-compose-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; (define-key mu4e-headers-mode-map (kbd "C-c m") 'mu4e~main-toggle-mail-sending-mode)
;; )
(if mu4e-command
(condition-case err
(let ((mu4e-hide-index-messages t))
(call-interactively mu4e-command))
(error (when (cadr err) (message (cadr err)))))
(message (mu4e-format "key %s not bound to a command" (string key))))
(when (or (not mu4e-command) (eq mu4e-command 'mu4e-context-switch))
(sit-for 1)
(mu4e~main-menu))))))
(provide 'mu4e-main)

View File

@ -1,6 +1,6 @@
;;; mu4e-speedbar --- Speedbar support for mu4e -*- lexical-binding: t -*-
;; Copyright (C) 2012-2018 Antono Vasiljev, Dirk-Jan C. Binnema
;; Copyright (C) 2012-2020 Antono Vasiljev, Dirk-Jan C. Binnema
;;
;; Author: Antono Vasiljev <self@antono.info>
;; Version: 0.1
@ -56,10 +56,10 @@
"Install those variables used by speedbar to enhance mu4e."
(add-hook 'mu4e-context-changed-hook
(lambda()
(when (buffer-live-p speedbar-buffer)
(with-current-buffer speedbar-buffer
(let ((inhibit-read-only t))
(mu4e-speedbar-buttons))))))
(when (buffer-live-p speedbar-buffer)
(with-current-buffer speedbar-buffer
(let ((inhibit-read-only t))
(mu4e-speedbar-buttons))))))
(dolist (keymap
'( mu4e-main-speedbar-key-map
mu4e-headers-speedbar-key-map
@ -80,13 +80,13 @@
(when (buffer-live-p speedbar-buffer)
(with-current-buffer speedbar-buffer
(mapcar (lambda (maildir-name)
(speedbar-insert-button
(concat " " maildir-name)
'mu4e-highlight-face
'highlight
'mu4e~speedbar-maildir
maildir-name))
(mu4e-get-maildirs)))))
(speedbar-insert-button
(concat " " maildir-name)
'mu4e-highlight-face
'highlight
'mu4e~speedbar-maildir
maildir-name))
(mu4e-get-maildirs)))))
(defun mu4e~speedbar-maildir (&optional _text token _ident)
"Jump to maildir TOKEN. TEXT and INDENT are not used."
@ -98,12 +98,13 @@
"Insert the list of bookmarks in the speedbar"
(interactive)
(mapcar (lambda (bookmark)
(speedbar-insert-button
(concat " " (mu4e-bookmark-name bookmark))
'mu4e-highlight-face
'highlight
'mu4e~speedbar-bookmark
(mu4e-bookmark-query bookmark)))
(unless (plist-get bookmark :hide)
(speedbar-insert-button
(concat " " (plist-get bookmark :name))
'mu4e-highlight-face
'highlight
'mu4e~speedbar-bookmark
(plist-get bookmark :query))))
(mu4e-bookmarks)))
(defun mu4e~speedbar-bookmark (&optional _text token _ident)

File diff suppressed because it is too large Load Diff

View File

@ -201,43 +201,41 @@ If the string exceeds this limit, it will be truncated to fit."
(defvar mu4e-debug nil
"When set to non-nil, log debug information to the *mu4e-log* buffer.")
(cl-defstruct mu4e-bookmark
"A mu4e bookmarl object with the following members:
;; for backward compatibility, when a bookmark was defined with defstruct.
(cl-defun make-mu4e-bookmark (&key name query key)
"Create a mu4e proplist with the following elements:
- `name': the user-visible name of the bookmark
- `key': a single key to search for this bookmark
- `query': the query for this bookmark. Either a literal string or a function
that evaluates to a string."
name ;; name/description of the bookmark
query ;; a query (a string or a function evaluation to string)
key ;; key to activate the bookmark
)
`(:name ,name :query ,query :key ,key))
(make-obsolete 'make-mu4e-bookmark "`unneeded; `mu4e-bookmarks'
are plists" "1.3.7")
(defcustom mu4e-bookmarks
`( ,(make-mu4e-bookmark
:name "Unread messages"
:query "flag:unread AND NOT flag:trashed"
:key ?u)
,(make-mu4e-bookmark
:name "Today's messages"
:query "date:today..now"
:key ?t)
,(make-mu4e-bookmark
:name "Last 7 days"
:query "date:7d..now"
:key ?w)
,(make-mu4e-bookmark
:name "Messages with images"
:query "mime:image/*"
:key ?p))
"A list of pre-defined queries.
These will show up in the main screen. Each of the list elements
is a three-element list of the form (QUERY DESCRIPTION KEY),
where QUERY is a string with a mu query, DESCRIPTION is a short
description of the query (this will show up in the UI), and KEY
is a shortcut key for the query."
:type '(repeat (list (string :tag "Query")
(string :tag "Description")
character))
'(( :name "Unread messages"
:query "flag:unread AND NOT flag:trashed"
:key ?u)
( :name "Today's messages"
:query "date:today..now"
:key ?t)
( :name "Last 7 days"
:query "date:7d..now"
:key ?w)
( :name "Messages with images"
:query "mime:image/*"
:key ?p))
"List of pre-defined queries that are shown on the main screen.
Each of the list elements is a plist with at least:
:name - the name of the queryt
:query - the query expression
:key - the shortcut key.
Optionally, you add the following:
:hide - if t, bookmark is hdden from the main-view and speedbar.
"
:type '(repeat (plist))
:group 'mu4e)
(defcustom mu4e-split-view 'horizontal

View File

@ -1962,25 +1962,21 @@ mu4e-search-bookmark-edit}) which lets you edit the bookmark first.
@subsection Setting up bookmarks
@t{mu4e} provides a number of default bookmarks. Their definition is
instructive:
@t{mu4e} provides a number of default bookmarks. Their definition may
be instructive:
@lisp
(defvar mu4e-bookmarks
`( ,(make-mu4e-bookmark
:name "Unread messages"
'( ( :name "Unread messages"
:query "flag:unread AND NOT flag:trashed"
:key ?u)
,(make-mu4e-bookmark
:name "Today's messages"
( :name "Today's messages"
:query "date:today..now"
:key ?t)
,(make-mu4e-bookmark
:name "Last 7 days"
( :name "Last 7 days"
:query "date:7d..now"
:key ?w)
,(make-mu4e-bookmark
:name "Messages with images"
( :name "Messages with images"
:query "mime:image/*"
:key ?p))
"A list of pre-defined queries. Each query is represented by a
@ -1997,10 +1993,9 @@ You can replace these or add your own items, by putting in your
configuration (@file{~/.emacs}) something like:
@lisp
(add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark
:name "Big messages"
:query "size:5M..500M"
:key ?b))
'( :name "Big messages"
:query "size:5M..500M"
:key ?b))
@end lisp
This prepends your bookmark to the list, and assigns the key @key{b} to it. If
@ -2023,12 +2018,11 @@ inbox:
@lisp
(add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark
:name "Inbox messages in the last 7 days"
:query (lambda () (concat "maildir:/inbox AND date:"
(format-time-string "%Y%m%d"
'( :name "Inbox messages in the last 7 days"
:query (lambda () (concat "maildir:/inbox AND date:"
(format-time-string "%Y%m%d"
(subtract-time (current-time) (days-to-time 7)))))
:key ?w) t)
:key ?w) t)
@end lisp
Another example where the user is prompted how many days old messages should be
@ -2042,10 +2036,9 @@ shown:
(format-time-string "%Y%m%d" start-date))))
(add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark
:name "Inbox messages in the last 7 days"
:query (lambda () (call-interactively 'my/mu4e-bookmark-num-days-old-query))
:key ?o) t)
`(:name "Inbox messages in the last 7 days"
:query ,(lambda () (call-interactively 'my/mu4e-bookmark-num-days-old-query))
:key ?o) t)
@end lisp
It is defining a function to make the code more readable.