* (WIP) add speedbar support (thanks to Antono V)

This commit is contained in:
djcb 2012-03-19 21:45:26 +02:00
parent f43f704429
commit bd0573f3db
4 changed files with 114 additions and 8 deletions

View File

@ -36,6 +36,7 @@ elisp_DATA= \
mu4e-proc.el \
mu4e-main.el \
mu4e-send.el \
mu4e-speedbar.el \
mu4e-version.el \
org-mu4e.el

View File

@ -208,7 +208,7 @@ if provided, or at the end of the buffer otherwise."
(propertize line 'face 'mu4e-header-face)))))
;; store the thread info, so we can use it when updating the message
(when thread-info
(when (and thread-info mu4e-thread-info-map)
(puthash docid thread-info mu4e-thread-info-map))
(mu4e-hdrs-add-header line (plist-get msg :docid)
(if point point (point-max)))))
@ -360,7 +360,7 @@ after the end of the search results."
(setq
mu4e-marks-map (make-hash-table :size 16 :rehash-size 2)
mu4e-msg-map (make-hash-table :size 1024 :rehash-size 2 :weakness nil)
mu4e-thread-info-map (make-hash-table :size 512 :rehash-size 2)
mu4e-thread-info-map (make-hash-table :size 512 :rehash-size 2)
major-mode 'mu4e-hdrs-mode
mode-name "mu4e: message headers"
truncate-lines t
@ -638,7 +638,7 @@ action', return nil means 'don't do anything'"
(what mu4e-headers-leave-behavior))
(unless (or (= marknum 0) (eq what 'ignore) (eq what 'apply))
;; if `mu4e-headers-leave-behavior' is not apply or ignore, ask the user
(setq what
(setq what
(let ((kar
(read-char
(concat
@ -652,11 +652,11 @@ action', return nil means 'don't do anything'"
(t nil))))) ;; cancel
;; we determined what to do... now do it
(cond
((= 0 marknum) t) ;; no marks, just go ahead
((= 0 marknum) t) ;; no marks, just go ahead
((eq what 'ignore) t) ;; ignore the marks, go ahead
((eq what 'apply)
(progn (mu4e-execute-marks t) t) t) ;; execute marks, go ahead
(t nil)))) ;; otherwise, don't do anything
(t nil)))) ;; otherwise, don't do anything
;;; interactive functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -725,9 +725,9 @@ return the new docid. Otherwise, return nil."
(defun mu4e-jump-to-maildir ()
"Show the messages in maildir TARGET. If TARGET is not provided,
ask user for it. With C-u prefix, show /all/ results, otherwise,
limit to up to `mu4e-search-results-limit'."
"Show the messages in maildir (user is prompted to ask what
maildir). With C-u prefix, show /all/ results, otherwise, limit to
up to `mu4e-search-results-limit'."
(interactive)
(let ((fld (mu4e-ask-maildir "Jump to maildir: ")))
(when fld

86
emacs/mu4e-speedbar.el Normal file
View File

@ -0,0 +1,86 @@
;;; mu4e-speedbar --- Speedbar support for mu4e
;; Copyright (C) 2012 Antono Vasiljev
;;
;; Author: Antono Vasiljev <self@antono.info>
;; Version: 0.1
;; Keywords: file, tags, tools
;;
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, you can either send email to this
;; program's author (see below) or write to:
;;
;; The Free Software Foundation, Inc.
;; 675 Mass Ave.
;; Cambridge, MA 02139, USA.
;;
;; Please send bug reports, etc. to self@antono.info
;;
;;; Commentary:
;;
;; Speedbar provides a frame in which files, and locations in files
;; are displayed. These functions provide mu4e specific support,
;; showing maildir list in the side-bar.
;;
;; This file requires speedbar.
;;; Code:
(defvar mu4e-main-speedbar-key-map nil
"Keymap used when in mu4e display mode.")
(defvar mu4e-main-speedbar-menu-items nil
"Additional menu-items to add to speedbar frame.")
(defun mu4e-install-speedbar-variables ()
"Install those variables used by speedbar to enhance mu4e."
(if mu4e-main-speedbar-key-map
nil
(setq mu4e-main-speedbar-key-map (speedbar-make-specialized-keymap))
(define-key mu4e-main-speedbar-key-map "RET" 'speedbar-edit-line)
(define-key mu4e-main-speedbar-key-map "e" 'speedbar-edit-line)
(define-key mu4e-main-speedbar-key-map "e" 'speedbar-edit-line)))
;; Make sure our special speedbar major mode is loaded
(if (featurep 'speedbar)
(mu4e-install-speedbar-variables)
(add-hook 'speedbar-load-hook 'mu4e-install-speedbar-variables))
(defun mu4e-render-maildir-list ()
(interactive)
(mapcar (lambda (maildir-name)
(speedbar-insert-button maildir-name
'speedbar-directory-face
'highlight
'mu4e-main-speedbar-find-file
maildir-name))
(mu4e-get-maildirs mu4e-maildir)))
(defun mu4e-main-speedbar-find-file (&optional text token ident)
"Load in the mu4e file TEXT. TOKEN and INDENT are not used."
(speedbar-with-attached-buffer
(speedbar-message "Loading in MU4E maildir %s..." text)
(mu4e-search (concat "\"maildir:" token "\""))))
;;;###autoload
(defun mu4e-main-speedbar-buttons (buffer)
"Create buttons for any mu4e BUFFER."
(interactive)
(erase-buffer)
(mu4e-render-maildir-list))
(provide 'mu4e-speedbar)
;;; mu4e-speedbar.el ends here

View File

@ -840,6 +840,7 @@ with other tools.
* Creating org-mode links::
* Maintaining an address-book with org-contacts::
* Getting new mail notifications with Sauron::
* Speedbar support::
@end menu
@node Creating org-mode links
@ -926,6 +927,24 @@ Note, you should put something like:
@end lisp
in your setup, which allows the script to find the D-Bus session bus.
@node Speedbar support
@section Speedbar support (experimental)
@code{speedbar} is an emacs-extension that shows navigational information for
an emacs buffer in a separate frame. Using @code{mu4e-speedbar}, @t{mu4e}
lists your maildir folders and allows for one-click access to them.
You can set it up like this in your emacs configuration:
@lisp
(require 'speedbar)
(require 'mu4e-speedbar)
@end lisp
You can then activate it with @code{M-x speedbar}.
@code{mu4e-speedbar} was contributed by Antono Vasiljev.
@node Example configuration