mu4e: support hiding bookmarks from main-screen/bookmarks

Using the :hide t property on a bookmark plist. The bookmark is still
available throught the completion mechanism.
This commit is contained in:
Dirk-Jan C. Binnema 2020-01-13 12:25:24 +02:00
parent c95cd3c1aa
commit 1631d98b9e
4 changed files with 45 additions and 30 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

@ -142,10 +142,11 @@ clicked."
;; 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 (plist-get bm :key)) "] "
(plist-get bm :name))
(concat "b" (make-string 1 (plist-get bm :key)))))
(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)

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 " " (plist-get bookmark :name))
'mu4e-highlight-face
'highlight
'mu4e~speedbar-bookmark
(plist-get bookmark :query)))
(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)

View File

@ -209,6 +209,8 @@ If the string exceeds this limit, it will be truncated to fit."
- `query': the query for this bookmark. Either a literal string or a function
that evaluates to a string."
`(:name ,name :query ,query :key ,key))
(make-obsolete 'make-mu4e-bookmark "`unneeded; `mu4e-bookmarks'
are plists" "1.3.7")
(defcustom mu4e-bookmarks
'(( :name "Unread messages"
@ -225,14 +227,15 @@ If the string exceeds this limit, it will be truncated to fit."
:key ?p))
"List of pre-defined queries that are shown on the main screen.
Each of the list elements is a plist with
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 (plist (string :tag "Query")
(string :tag "Description")
character))
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