* mm-main.el: update main view, support bookmarks

This commit is contained in:
djcb 2011-12-13 07:43:49 +02:00
parent 8ad1b738a3
commit 5f1eebcad5
1 changed files with 34 additions and 32 deletions

View File

@ -29,6 +29,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mm main view mode + keybindings ;; mm main view mode + keybindings
(defconst mm/main-buffer-name "*mm*"
"*internal* Name of the mm main view buffer.")
(defvar mm/mm-mode-map (defvar mm/mm-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -66,45 +69,44 @@
"Highlight the first occurence of [..] in STR." "Highlight the first occurence of [..] in STR."
(if (string-match "\\[\\(\\w+\\)\\]" str) (if (string-match "\\[\\(\\w+\\)\\]" str)
(let* ((key (match-string 1 str)) (let* ((key (match-string 1 str))
(keystr (propertize key 'face 'mm/highlight-face))) (keystr (propertize key 'face 'mm/highlight-face)))
(replace-match keystr nil t str 1)) (replace-match keystr nil t str 1))
str)) str))
(defun mm() (defun mm/main-view()
"Start mm; should not be called directly, instead, use `mm'" "Show the mm main view."
(interactive) (let ((buf (get-buffer-create mm/main-buffer-name))
(let ((buf (get-buffer-create mm/mm-buffer-name))
(inhibit-read-only t)) (inhibit-read-only t))
(with-current-buffer buf (with-current-buffer buf
(erase-buffer) (erase-buffer)
(insert (insert
"* " "* "
(propertize "mm - mu mail for emacs version " 'face 'mm/title-face) (propertize "mm - mu mail for emacs version " 'face 'mm/title-face)
(propertize mm/mu-version 'face 'mm/view-header-key-face) (propertize mm/mu-version 'face 'mm/view-header-key-face)
"\n\n" "\n\n"
(propertize " Basics\n\n" 'face 'mm/title-face) (propertize " Basics\n\n" 'face 'mm/title-face)
(mm/action-str "\t* [j]ump to some maildir\n") (mm/action-str "\t* [j]ump to some maildir\n")
(mm/action-str "\t* enter a [s]earch query\n") (mm/action-str "\t* enter a [s]earch query\n")
(mm/action-str "\t* [c]ompose a new message\n") (mm/action-str "\t* [c]ompose a new message\n")
"\n" "\n"
(propertize " Bookmarks\n\n" 'face 'mm/title-face) (propertize " Bookmarks\n\n" 'face 'mm/title-face)
(mapconcat (mapconcat
(lambda (bm) (lambda (bm)
(let* ((query (nth 0 bm)) (title (nth 1 bm)) (key (nth 2 bm))) (let* ((query (nth 0 bm)) (title (nth 1 bm)) (key (nth 2 bm)))
(mm/action-str (mm/action-str
(concat "\t* [b" (make-string 1 key) "] " title)))) (concat "\t* [b" (make-string 1 key) "] " title))))
mm/bookmarks "\n") mm/bookmarks "\n")
"\n" "\n"
(propertize " Misc\n\n" 'face 'mm/title-face) (propertize " Misc\n\n" 'face 'mm/title-face)
(mm/action-str "\t* [u]pdate email & database\n") (mm/action-str "\t* [u]pdate email & database\n")
(mm/action-str "\t* toggle [m]ail sending mode ") (mm/action-str "\t* toggle [m]ail sending mode ")
"(" (propertize (if smtpmail-queue-mail "queued" "direct") "(" (propertize (if smtpmail-queue-mail "queued" "direct")
'face 'mm/view-header-key-face) ")\n" 'face 'mm/view-header-key-face) ")\n"
(mm/action-str "\t* [f]lush queued mail\n") (mm/action-str "\t* [f]lush queued mail\n")
"\n" "\n"
(mm/action-str "\t* [q]uit mm\n")) (mm/action-str "\t* [q]uit mm\n"))
(mm/mm-mode) (mm/mm-mode)
(switch-to-buffer buf)))) (switch-to-buffer buf))))