Permalink
Browse files

* mu4e: restructure code a bit and enable byte-compilation

  • Loading branch information...
1 parent b943f56 commit edda59bff78f6e454567053fe53077e3d53ab0d9 @djcb committed Apr 9, 2012
Showing with 708 additions and 615 deletions.
  1. +7 −1 Makefile.am
  2. +4 −1 configure.ac
  3. +10 −14 emacs/Makefile.am
  4. +34 −24 emacs/mu4e-hdrs.el
  5. +5 −7 emacs/mu4e-proc.el
  6. +110 −0 emacs/mu4e-raw-view.el
  7. +5 −4 emacs/mu4e-send.el
  8. +2 −0 emacs/mu4e-speedbar.el
  9. +44 −4 emacs/mu4e-utils.el
  10. +472 −0 emacs/mu4e-vars.el
  11. +7 −0 emacs/mu4e-version.el.in
  12. +8 −89 emacs/mu4e-view.el
  13. +0 −471 emacs/mu4e.el
View
@@ -29,7 +29,13 @@ else
guile=
endif
-SUBDIRS=m4 man src $(widgets) $(guile) emacs contrib toys
+if HAVE_EMACS
+emacs=emacs
+else
+emacs=
+endif
+
+SUBDIRS=m4 man src $(widgets) $(guile) $(emacs) contrib toys
ACLOCAL_AMFLAGS=-I m4
View
@@ -49,7 +49,9 @@ AC_SYS_LARGEFILE
AC_CHECK_PROG(have_makeinfo,makeinfo,yes,no)
AM_CONDITIONAL(HAVE_MAKEINFO,test "x$have_makeinfo" = "xyes")
-
+# we need emacs for byte-compiling mu4e
+AM_PATH_LISPDIR
+AM_CONDITIONAL(HAVE_EMACS,test "x$lispdir" != "xno")
# we need some special tricks for filesystems that don't have d_type;
# e.g. Solaris. See mu-maildir.c. Explicitly disabling it is for
@@ -281,6 +283,7 @@ src/Makefile
src/tests/Makefile
widgets/Makefile
emacs/Makefile
+emacs/mu4e-version.el
guile/Makefile
guile/mu/Makefile
guile/examples/Makefile
View
@@ -17,28 +17,24 @@
include $(top_srcdir)/gtest.mk
SUBDIRS=
-
-BUILT_SOURCES=mu4e-version.el
-
-mu4e-version.el: $(top_srcdir)/configure.ac
- @echo -e ";; auto-generated\n\
-(defconst mu4e-mu-version \"$(VERSION)\" \"Required mu binary version.\")\n\
-(provide 'mu4e-version)\n" >$@
-
+
info_TEXINFOS=mu4e.texi
mu4e_TEXINFOS=fdl.texi
-elispdir= ${prefix}/share/emacs/site-lisp/mu4e/
-elisp_DATA= \
- mu4e.el \
+lispdir=${prefix}/share/emacs/site-lisp/mu4e/
+
+dist_lisp_LISP= \
+ mu4e-utils.el \
mu4e-hdrs.el \
- mu4e-view.el \
- mu4e-proc.el \
mu4e-main.el \
+ mu4e-proc.el \
+ mu4e-raw-view.el \
mu4e-send.el \
mu4e-speedbar.el \
- mu4e-utils.el \
+ mu4e-vars.el \
mu4e-version.el \
+ mu4e-view.el \
+ mu4e.el \
org-mu4e.el
EXTRA_DIST=$(elisp_DATA)
View
@@ -27,19 +27,13 @@
;; headers like 'To:' or 'Subject:')
;; Code:
-
-(eval-when-compile (require 'cl))
-
(require 'hl-line)
+
(require 'mu4e-proc)
(require 'mu4e-utils) ;; utility functions
-
+(require 'mu4e-vars)
;;;; internal variables/constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar mu4e-last-expr nil "*internal* The most recent search expression.")
-(defconst mu4e-hdrs-buffer-name "*mu4e-headers*"
- "*internal* Name of the buffer for message headers.")
-(defvar mu4e-hdrs-buffer nil "*internal* Buffer for message headers")
(defconst mu4e-hdrs-fringe " " "*internal* The space on the left of
message headers to put marks.")
@@ -120,7 +114,9 @@ headers."
(when (and viewbuf (buffer-live-p viewbuf))
(with-current-buffer viewbuf
(when (eq docid (plist-get mu4e-current-msg :docid))
- (setq mu4e-current-msg msg)))))
+ (setq mu4e-current-msg msg)
+ ;; and re-highlight this message
+ (mu4e-hdrs-highlight docid)))))
;; now, if this update was about *moving* a message, we don't show it
;; anymore (of course, we cannot be sure if the message really no
@@ -234,7 +230,9 @@ after the end of the search results."
(insert (propertize str 'face 'mu4e-system-face 'intangible t))
(unless (= 0 count)
(message "Found %d matching message%s"
- count (if (= 1 count) "" "s"))))))))
+ count (if (= 1 count) "" "s"))
+ ;; highlight the first message
+ (mu4e-hdrs-highlight (mu4e--docid-at-point (point-min)))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -336,7 +334,6 @@ after the end of the search results."
(define-key menumap [next] '("Next" . mu4e-next-header))
(define-key menumap [previous] '("Previous" . mu4e-prev-header))
(define-key menumap [sepa4] '("--")))
-
map)))
(fset 'mu4e-hdrs-mode-map mu4e-hdrs-mode-map)
@@ -376,7 +373,7 @@ after the end of the search results."
hl-line-face 'mu4e-header-highlight-face)
(hl-line-mode 1)
-
+
(setq header-line-format
(cons
(make-string
@@ -394,7 +391,27 @@ after the end of the search results."
mu4e-headers-fields))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun mu4e-select-headers-window-if-visible ()
+;;; higlighting
+(defvar mu4e--highlighted-docid nil
+ "*internal* The highlighted docid")
+
+(defun mu4e-hdrs-highlight (docid)
+ "Highlight the header with DOCID, or do nothing if it's not
+found. Also, unhighlight any previously highlighted headers."
+ (with-current-buffer mu4e-hdrs-buffer
+ (save-excursion
+ ;; first, unhighlight the previously highlighted docid, if any
+ (when (and mu4e--highlighted-docid
+ (mu4e--goto-docid mu4e--highlighted-docid))
+ (hl-line-unhighlight))
+ ;; now, highlight the new one
+ (when (mu4e--goto-docid docid)
+ (hl-line-highlight)))
+ (setq mu4e--highlighted-docid docid)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defun mu4e-select-headers-window-if-visible ()
"When there is a visible window for the headers buffer, make sure
to select it. This is needed when adding new headers, otherwise
adding a lot of new headers looks really choppy."
@@ -436,8 +453,6 @@ of the beginning of the line."
(setq newpoint (point)))))
newpoint)) ;; return the point, or nil if not found
-
-
(defun mu4e--docid-pos (docid)
"Return the pos of the beginning of the line with the header with
docid DOCID, or nil if it cannot be found."
@@ -482,11 +497,7 @@ at (point-max) otherwise. If MSG is not nil, add it as the text-property `msg'."
(concat
(mu4e--docid-cookie docid)
mu4e-hdrs-fringe str "\n")
- 'docid docid 'msg msg))
- ;; if it's the first header, highlight it
- (when is-first-header
- (goto-char (point-min))
- (hl-line-highlight)))))))
+ 'docid docid 'msg msg)))))))
(defun mu4e-hdrs-remove-header (docid)
"Remove header with DOCID at POINT."
@@ -746,7 +757,7 @@ do a new search."
(when (mu4e-handle-marks)
(if mu4e-last-expr
(mu4e-hdrs-search mu4e-last-expr)
- (mu4e-search))))
+ (call-interactively 'mu4e-search))))
(defun mu4e--hdrs-move (lines)
"Move point LINES lines forward (if LINES is positive) or
@@ -756,12 +767,11 @@ docid. Otherwise, return nil."
(unless (buffer-live-p mu4e-hdrs-buffer)
(error "Headers buffer is not alive %S" (current-buffer)))
(set-window-point (get-buffer-window mu4e-hdrs-buffer) (point))
- (hl-line-unhighlight)
(let ((succeeded (= 0 (forward-line lines)))
(docid (mu4e--docid-at-point)))
;; trick to move point, even if this function is called when this window
;; is not visible
- (hl-line-highlight)
+ (mu4e-hdrs-highlight docid)
;; return the docid only if the move succeeded
(when succeeded docid))))
@@ -803,7 +813,7 @@ not provided, function asks for it."
(concat "/" target)))
(fulltarget (concat mu4e-maildir target)))
(when (or (file-directory-p fulltarget)
- (and (yes-or-no-(point)
+ (and (yes-or-no-p
(format "%s does not exist. Create now?" fulltarget))
(mu4e-proc-mkdir fulltarget)))
(mu4e-hdrs-mark 'move target)
View
@@ -23,9 +23,11 @@
;;; Commentary:
;;; Code:
-(eval-when-compile (require 'cl))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(require 'mu4e-vars)
+(require 'mu4e-utils)
+(require 'mu4e-version)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; internal vars
(defvar mu4e-mu-proc nil
@@ -106,10 +108,6 @@ process."
;; add draft messages to the db, so when we're sending them, we can move
;; to the sent folder using the `mu4e-proc-move'.
(puthash (plist-get info :path) (plist-get info :docid) mu4e-path-docid-map))
- ((eq type 'version)
- (setq
- mu4e-version (plist-get info :version)
- mu4e-doccount (plist-get-info :doccount)))
((eq type 'index)
(if (eq (plist-get info :status) 'running)
(message (format "Indexing... processed %d, updated %d"
View
@@ -0,0 +1,110 @@
+;;; mu4e-raw-view.el -- part of mu4e, the mu mail user agent
+;;
+;; Copyright (C) 2011-2012 Dirk-Jan C. Binnema
+
+;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+
+;; This file is not part of GNU Emacs.
+;;
+;; GNU Emacs 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 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; In this file we define mu4e-view-mode (+ helper functions), which is used for
+;; viewing e-mail messages
+
+;;; Code:
+(eval-when-compile (require 'cl))
+
+(require 'mu4e-utils) ;; utility functions
+
+;; raw mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;; some buffer-local variables
+(defconst mu4e-raw-view-buffer-name "*mu4e-raw-view*"
+ "*internal* Name for the raw message view buffer")
+
+(defvar mu4e-raw-view-buffer nil "*internal* The raw view buffer.")
+
+(defvar mu4e-raw-view-mode-map nil
+ "Keymap for \"*mu4e-raw-view*\" buffers.")
+
+(unless mu4e-raw-view-mode-map
+ (setq mu4e-raw-view-mode-map
+ (let ((map (make-sparse-keymap)))
+
+ (define-key map "q" 'mu4e-raw-view-quit-buffer)
+ (define-key map "." 'mu4e-raw-view-quit-buffer)
+
+ ;; intra-message navigation
+ (define-key map (kbd "SPC") 'scroll-up)
+ (define-key map (kbd "<home>")
+ '(lambda () (interactive) (goto-char (point-min))))
+ (define-key map (kbd "<end>")
+ '(lambda () (interactive) (goto-char (point-max))))
+ (define-key map (kbd "RET")
+ '(lambda () (interactive) (scroll-up 1)))
+ (define-key map (kbd "<backspace>")
+ '(lambda () (interactive) (scroll-up -1)))
+ map)))
+
+(fset 'mu4e-raw-view-mode-map mu4e-raw-view-mode-map)
+
+(define-derived-mode mu4e-raw-view-mode special-mode
+ "mu4e:raw"
+ "Major mode for viewing of raw e-mail message in mu4e.
+\\{mu4e-raw-view-mode-map}.")
+
+
+(defun mu4e-raw-view-message (msg view-buffer)
+ "Display the raw contents of message MSG in a new buffer."
+ (let ((buf (get-buffer-create mu4e-raw-view-buffer-name))
+ (inhibit-read-only t)
+ (file (plist-get msg :path)))
+ (unless (and file (file-readable-p file))
+ (error "Not a readable file: %S" file))
+ (with-current-buffer buf
+ (erase-buffer)
+ (insert-file-contents file)
+ ;; initialize view-mode
+ (mu4e-raw-view-mode)
+ (setq mu4e-raw-view-buffer view-buffer)
+ (switch-to-buffer buf)
+ (goto-char (point-min)))))
+
+
+(defun mu4e-view-shell-command-on-raw-message (msg view-buffer cmd)
+ "Process the raw message with shell command CMD."
+ (let ((buf (get-buffer-create mu4e-raw-view-buffer-name))
+ (inhibit-read-only t)
+ (file (plist-get msg :path)))
+ (unless (and file (file-readable-p file))
+ (error "Not a readable file: %S" file))
+ (with-current-buffer buf
+ (erase-buffer)
+ (process-file-shell-command cmd file buf)
+ (mu4e-raw-view-mode)
+ (setq mu4e-raw-view-buffer view-buffer)
+ (switch-to-buffer buf)
+ (goto-char (point-min)))))
+
+
+(defun mu4e-raw-view-quit-buffer ()
+ "Quit the raw view and return to the message."
+ (interactive)
+ (kill-buffer))
+
+(provide 'mu4e-raw-view)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
View
@@ -26,10 +26,11 @@
;; gnus' message mode
;;; Code:
+ ;; we use some stuff from gnus..
+(require 'cl)
-(eval-when-compile (require 'cl))
-
-;; we use some stuff from gnus...
+(require 'mu4e-utils)
+(require 'mu4e-vars)
(require 'message)
(require 'mail-parse)
(require 'smtpmail)
@@ -159,7 +160,7 @@ separator is never written to file. Also see
(replace-match
(propertize mail-header-separator 'read-only t 'intangible t))
;; no empty line? then append one
- ((progn )
+ (progn
(goto-char (point-max))
(insert (concat "\n" mail-header-separator "\n"))))))
View
@@ -39,6 +39,8 @@
;;; Code:
+(require 'speedbar)
+
(defvar mu4e-main-speedbar-key-map nil
"Keymap used when in mu4e display mode.")
Oops, something went wrong.

0 comments on commit edda59b

Please sign in to comment.