* big renaming / refactoring

This commit is contained in:
djcb 2012-05-01 22:45:54 +03:00
parent c489482e86
commit 3a4814f38b
12 changed files with 341 additions and 345 deletions

View File

@ -92,7 +92,7 @@ AS_IF([test "x$PKG_CONFIG" = "xno"],[
# glib2?
# we need 2.14 at least, because we use GRegex
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.14 gobject-2.0)
PKG_CHECK_MODULES(GLIB,glib-2.0 >= 2.14 gobject-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
glib_version="`$PKG_CONFIG --modversion glib-2.0`"

View File

@ -26,7 +26,7 @@ lispdir=${prefix}/share/emacs/site-lisp/mu4e/
dist_lisp_LISP= \
mu4e-actions.el \
mu4e-compose.el \
mu4e-hdrs.el \
mu4e-headers.el \
mu4e-main.el \
mu4e-mark.el \
mu4e-meta.el \

View File

@ -35,7 +35,7 @@
(require 'mu4e-utils)
(require 'mu4e-vars)
(require 'mu4e-proc)
(require 'mu4e-view)
(require 'mu4e-actions)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Composing / Sending messages
@ -88,8 +88,6 @@ of mu4e and emacs."
(format "mu4e %s; emacs %s" mu4e-mu-version emacs-version))
(defun mu4e~compose-cite-original (msg)
"Return a cited version of the original message MSG (ie., the
plist). This function use gnus' `message-cite-function', and as
@ -588,13 +586,66 @@ buffer."
(mu4e~proc-move (match-string 1 forwarded-from) nil "+P")))))))
(defun mu4e-compose (compose-type)
"Start composing a message of COMPOSE-TYPE, where COMPOSE-TYPE is
a symbol, one of `reply', `forward', `edit', `new'. All but `new'
take the message at point as input. Symbol `edit' is only allowed
for draft messages."
(unless (member compose-type '(reply forward edit new))
(error "Invalid compose type '%S'" compose-type))
;; 'new is special, since it takes no existing message as arg therefore,
;; we don't need to call thec backend, and call the handler *directly*
(if (eq compose-type 'new)
(mu4e~compose-handler 'new)
;; otherwise, we need the doc-id
(let ((docid (mu4e-field-at-point :docid)))
;; note, the first two chars of the line (the mark margin) does *not*
;; have the 'draft property; thus, we check one char before the end of
;; the current line instead
(unless (or (not (eq compose-type 'edit))
(member 'draft (mu4e-field-at-point :flags)))
(error "Editing is only allowed for draft messages"))
;; if there's a visible view window, select that before starting
;; composing a new message, so that one will be replaced by the
;; compose window. The 10-or-so line headers buffer is not a good way
;; to write it...
(let ((viewwin (get-buffer-window mu4e~view-buffer)))
(when (window-live-p viewwin)
(select-window viewwin)))
;; talk to the backend
(mu4e~proc-compose compose-type docid))))
(defun mu4e-compose-reply ()
"Compose a reply for the message at point in the headers buffer."
(interactive)
(mu4e-compose 'reply))
(defun mu4e-compose-forward ()
"Forward the message at point in the headers buffer."
(interactive)
(mu4e-compose 'forward))
(defun mu4e-compose-edit ()
"Edit the draft message at point in the headers buffer. This is
only possible if the message at point is, in fact, a draft
message."
(interactive)
(mu4e-compose 'edit))
(defun mu4e-compose-new ()
"Start writing a new message."
(interactive)
(mu4e-compose 'new))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mu4e-compose-func and mu4e-send-func are wrappers so we can set ourselves
;; as default emacs mailer (define-mail-user-agent etc.)
(defun mu4e~compose (&optional to subject other-headers continue
switch-function yank-action send-actions return-action)
(defun mu4e~compose-mail (&optional to subject other-headers continue
switch-function yank-action send-actions return-action)
"mu4e's implementation of `compose-mail'."
;; create a new draft message 'resetting' (as below) is not actually needed in
;; this case, but let's prepare for the re-edit case as well
@ -626,7 +677,7 @@ buffer."
;; happily, we can re-use most things from message mode
(define-mail-user-agent 'mu4e-user-agent
'mu4e~compose
'mu4e~compose-mail
'message-send-and-exit
'message-kill-buffer
'message-send-hook)

View File

@ -1,4 +1,4 @@
;;; mu4e-hdrs.el -- part of mu4e, the mu mail user agent
;;; mu4e-headers.el -- part of mu4e, the mu mail user agent
;;
;; Copyright (C) 2011-2012 Dirk-Jan C. Binnema
@ -22,7 +22,7 @@
;;; Commentary:
;; In this file are function related mu4e-hdrs-mode, to creating the list of
;; In this file are function related mu4e-headers-mode, to creating the list of
;; one-line descriptions of emails, aka 'headers' (not to be confused with
;; headers like 'To:' or 'Subject:')
@ -34,6 +34,7 @@
(require 'mu4e-utils) ;; utility functions
(require 'mu4e-vars)
(require 'mu4e-mark)
(require 'mu4e-compose)
(require 'mu4e-actions)
;; the headers view
@ -87,40 +88,40 @@ are of the form:
;;;; internal variables/constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar mu4e~hdrs-query nil "The most recent search expression.")
(defvar mu4e~headers-query nil "The most recent search expression.")
;; docid cookies
(defconst mu4e~docid-pre "\376"
(defconst mu4e~headers-docid-pre "\376"
"Each header starts (invisibly) with the `mu4e-docid-pre',
followed by the docid, followed by `mu4e-docid-post'.")
(defconst mu4e~docid-post "\377"
(defconst mu4e~headers-docid-post "\377"
"Each header starts (invisibly) with the `mu4e-docid-pre',
followed by the docid, followed by `mu4e-docid-post'.")
(defun mu4e~hdrs-clear ()
(defun mu4e~headers-clear ()
"Clear the header buffer and related data structures."
(when (buffer-live-p mu4e~hdrs-buffer)
(when (buffer-live-p mu4e~headers-buffer)
(let ((inhibit-read-only t))
(with-current-buffer mu4e~hdrs-buffer
(with-current-buffer mu4e~headers-buffer
(erase-buffer)
(mu4e~mark-clear)))))
(defun mu4e-hdrs-search (expr &optional full-search)
(defun mu4e-headers-search (expr full-search)
"Search in the mu database for EXPR, and switch to the output
buffer for the results. If FULL-SEARCH is non-nil return all
results, otherwise, limit number of results to
`mu4e-search-results-limit'."
(let ((buf (get-buffer-create mu4e~hdrs-buffer-name))
`mu4e-search-results-limit'. This is an interactive function which
ask user for EXPR, and FULL-SEARCH as prefix-argument."
(interactive "s\nPSearch: ")
(let ((buf (get-buffer-create mu4e~headers-buffer-name))
(inhibit-read-only t))
(mu4e-mark-handle-when-leaving)
(with-current-buffer buf
(mu4e-hdrs-mode)
(mu4e-headers-mode)
(setq
global-mode-string (propertize expr 'face 'mu4e-title-face)
mu4e~hdrs-query expr
mu4e~hdrs-buffer buf
mu4e~headers-query expr
mu4e~headers-buffer buf
mode-name "mu4e-headers"))
(switch-to-buffer buf)
(mu4e~proc-find
@ -137,18 +138,18 @@ results, otherwise, limit number of results to
;; response to output from the server process
(defun mu4e~hdrs-view-handler (msg)
(defun mu4e~headers-view-handler (msg)
"Handler function for displaying a message."
(mu4e-view msg mu4e~hdrs-buffer))
(mu4e-view msg mu4e~headers-buffer))
(defun mu4e~hdrs-update-handler (msg is-move)
(defun mu4e~headers-update-handler (msg is-move)
"Update handler, will be called when a message has been updated
in the database. This function will update the current list of
headers."
(when (buffer-live-p mu4e~hdrs-buffer)
(with-current-buffer mu4e~hdrs-buffer
(when (buffer-live-p mu4e~headers-buffer)
(with-current-buffer mu4e~headers-buffer
(let* ((docid (plist-get msg :docid))
(point (mu4e~docid-pos docid)))
(point (mu4e~headers-docid-pos docid)))
(when point ;; is the message present in this list?
;; if it's marked, unmark it now
@ -160,11 +161,11 @@ headers."
;; search results)
;; but since we still have the search results, re-use those
(plist-put msg :thread
(mu4e~field-for-docid docid :thread))
(mu4e~headers-field-for-docid docid :thread))
;; first, remove the old one (otherwise, we'd have two headers with
;; the same docid...
(mu4e~hdrs-remove-handler docid)
(mu4e~headers-remove-handler docid)
;; if we we're actually viewing this message (in mu4e-view mode), we
;; update it; that way, the flags can be updated, as well as the path
@ -173,31 +174,31 @@ headers."
(when (and viewbuf (buffer-live-p viewbuf))
(with-current-buffer viewbuf
(when (eq docid (plist-get mu4e~view-msg :docid))
(mu4e-view msg mu4e~hdrs-buffer)))))
(mu4e-view msg mu4e~headers-buffer)))))
;; 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
;; longer matches the query, but this seem a good heuristic.
;; if it was only a flag-change, show the message with its updated flags.
(unless is-move
(mu4e~hdrs-header-handler msg point))
(mu4e~headers-header-handler msg point))
;; attempt to highlight the corresponding line and make it visible
(mu4e~hdrs-highlight docid))))))
(mu4e~headers-highlight docid))))))
(defun mu4e~hdrs-remove-handler (docid)
(defun mu4e~headers-remove-handler (docid)
"Remove handler, will be called when a message with DOCID has
been removed from the database. This function will hide the removed
message from the current list of headers. If the message is not
present, don't do anything."
(when (buffer-live-p mu4e~hdrs-buffer)
(with-current-buffer mu4e~hdrs-buffer
(mu4e~hdrs-remove-header docid t))))
(when (buffer-live-p mu4e~headers-buffer)
(with-current-buffer mu4e~headers-buffer
(mu4e~headers-remove-header docid t))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e~hdrs-contact-str (contacts)
(defun mu4e~headers-contact-str (contacts)
"Turn the list of contacts CONTACTS (with elements (NAME . EMAIL)
into a string."
(mapconcat
@ -205,7 +206,7 @@ into a string."
(let ((name (car ct)) (email (cdr ct)))
(or name email "?"))) contacts ", "))
(defun mu4e-thread-prefix (thread)
(defun mu4e~headers-thread-prefix (thread)
"Calculate the thread prefix based on thread info THREAD."
(if thread
(let ( (level (plist-get thread :level))
@ -222,10 +223,10 @@ into a string."
(duplicate "= ")
(t "| "))))))
(defun mu4e~hdrs-header-handler (msg &optional point)
(defun mu4e~headers-header-handler (msg &optional point)
"Create a one line description of MSG in this buffer, at POINT,
if provided, or at the end of the buffer otherwise."
(when (buffer-live-p mu4e~hdrs-buffer)
(when (buffer-live-p mu4e~headers-buffer)
(let* ((docid (plist-get msg :docid))
(line
(mapconcat
@ -236,11 +237,11 @@ if provided, or at the end of the buffer otherwise."
(case field
(:subject
(concat ;; prefix subject with a thread indicator
(mu4e-thread-prefix (plist-get msg :thread))
(mu4e~headers-thread-prefix (plist-get msg :thread))
;; "["(plist-get (plist-get msg :thread) :path) "] "
val))
((:maildir :path) val)
((:to :from :cc :bcc) (mu4e~hdrs-contact-str val))
((:to :from :cc :bcc) (mu4e~headers-contact-str val))
;; if we (ie. `user-mail-address' is the 'From', show
;; 'To', otherwise show From
(:from-or-to
@ -249,8 +250,8 @@ if provided, or at the end of the buffer otherwise."
(if (and from (string-match
mu4e-user-mail-address-regexp from))
(concat "To "
(mu4e~hdrs-contact-str (plist-get msg :to)))
(mu4e~hdrs-contact-str from-lst))))
(mu4e~headers-contact-str (plist-get msg :to)))
(mu4e~headers-contact-str from-lst))))
(:date (format-time-string mu4e-headers-date-format val))
(:flags (mu4e-flags-to-string val))
(:size (mu4e-display-size val))
@ -272,13 +273,13 @@ if provided, or at the end of the buffer otherwise."
(propertize line 'face 'mu4e-header-face)))))
;; now, append the header line
(mu4e~hdrs-add-header line docid point msg))))
(mu4e~headers-add-header line docid point msg))))
(defun mu4e~hdrs-found-handler (count)
(defun mu4e~headers-found-handler (count)
"Create a one line description of the number of headers found
after the end of the search results."
(when (buffer-live-p mu4e~hdrs-buffer)
(with-current-buffer mu4e~hdrs-buffer
(when (buffer-live-p mu4e~headers-buffer)
(with-current-buffer mu4e~headers-buffer
(save-excursion
(goto-char (point-max))
(let ((inhibit-read-only t)
@ -290,74 +291,75 @@ after the end of the search results."
(message "Found %d matching message%s"
count (if (= 1 count) "" "s"))
;; highlight the first message
(mu4e~hdrs-highlight (mu4e~docid-at-point (point-min)))))))))
(mu4e~headers-highlight (mu4e~headers-docid-at-point (point-min)))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; hdrs-mode and mode-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar mu4e-hdrs-mode-map nil
;;; headers-mode and mode-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar mu4e-headers-mode-map nil
"Keymap for *mu4e-headers* buffers.")
(unless mu4e-hdrs-mode-map
(unless mu4e-headers-mode-map
;; add some quick funcs so our key descriptions below are shorter
(defun mu4e~hdrs-mark-trash()(interactive)(mu4e-hdrs-mark-and-next 'trash))
(defun mu4e~hdrs-mark-delete()(interactive)(mu4e-hdrs-mark-and-next 'delete))
(defun mu4e~hdrs-mark-unmark()(interactive)(mu4e-hdrs-mark-and-next 'unmark))
(defun mu4e~hdrs-mark-read()(interactive)(mu4e-hdrs-mark-and-next 'read))
(defun mu4e~hdrs-mark-unread()(interactive)(mu4e-hdrs-mark-and-next 'unread))
(setq mu4e-hdrs-mode-map
(defun mu4e~headers-mark-trash()(interactive)(mu4e-headers-mark-and-next 'trash))
(defun mu4e~headers-mark-delete()(interactive)(mu4e-headers-mark-and-next 'delete))
(defun mu4e~headers-mark-unmark()(interactive)(mu4e-headers-mark-and-next 'unmark))
(defun mu4e~headers-mark-read()(interactive)(mu4e-headers-mark-and-next 'read))
(defun mu4e~headers-mark-unread()(interactive)(mu4e-headers-mark-and-next 'unread))
(setq mu4e-headers-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "s" 'mu4e-search)
(define-key map "b" 'mu4e-search-bookmark)
(define-key map "B" 'mu4e-search-bookmark-edit-first)
(define-key map "b" 'mu4e-headers-search-bookmark)
(define-key map "B" 'mu4e-headers-search-bookmark-edit-first)
(define-key map "q" 'mu4e~hdrs-kill-buffer-and-window)
(define-key map "z" 'mu4e~hdrs-kill-buffer-and-window)
(define-key map "q" 'mu4e~headers-kill-buffer-and-window)
(define-key map "z" 'mu4e~headers-kill-buffer-and-window)
(define-key map "r" 'mu4e-rerun-search)
(define-key map "g" 'mu4e-rerun-search) ;; for compatibility
(define-key map "r" 'mu4e-headers-rerun-search)
(define-key map "g" 'mu4e-headers-rerun-search) ;; for compatibility
(define-key map "%" 'mu4e-hdrs-mark-matches)
(define-key map "t" 'mu4e-hdrs-mark-subthread)
(define-key map "T" 'mu4e-hdrs-mark-thread)
(define-key map "%" 'mu4e-headers-mark-matches)
(define-key map "t" 'mu4e-headers-mark-subthread)
(define-key map "T" 'mu4e-headers-mark-thread)
;; navigation
(define-key map "n" 'mu4e-next-header)
(define-key map "p" 'mu4e-prev-header)
(define-key map "n" 'mu4e-headers-next)
(define-key map "p" 'mu4e-headers-prev)
;; the same
(define-key map (kbd "<M-down>") 'mu4e-next-header)
(define-key map (kbd "<M-up>") 'mu4e-prev-header)
(define-key map (kbd "<M-down>") 'mu4e-headers-next)
(define-key map (kbd "<M-up>") 'mu4e-headers-prev)
;; switching to view mode (if it's visible)
(define-key map "y" 'mu4e-select-other-view)
;; marking/unmarking ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-key map (kbd "<backspace>") 'mu4e~hdrs-mark-trash)
(define-key map (kbd "d") 'mu4e~hdrs-mark-trash)
(define-key map (kbd "<backspace>") 'mu4e~headers-mark-trash)
(define-key map (kbd "d") 'mu4e~headers-mark-trash)
(define-key map (kbd "<delete>") 'mu4e~hdrs-mark-delete)
(define-key map (kbd "<deletechar>") 'mu4e~hdrs-mark-delete)
(define-key map (kbd "D") 'mu4e~hdrs-mark-delete)
(define-key map (kbd "<delete>") 'mu4e~headers-mark-delete)
(define-key map (kbd "<deletechar>") 'mu4e~headers-mark-delete)
(define-key map (kbd "D") 'mu4e~headers-mark-delete)
(define-key map (kbd "o") 'mu4e~hdrs-mark-unread)
(define-key map (kbd "r") 'mu4e~hdrs-mark-read)
(define-key map (kbd "u") 'mu4e~hdrs-mark-unmark)
(define-key map (kbd "o") 'mu4e~headers-mark-unread)
(define-key map (kbd "r") 'mu4e~headers-mark-read)
(define-key map (kbd "u") 'mu4e~headers-mark-unmark)
(define-key map "m" 'mu4e-hdrs-mark-for-move-and-next)
(define-key map "m" 'mu4e-headers-mark-for-move-and-next)
(define-key map "U" 'mu4e-mark-unmark-all)
(define-key map "x" 'mu4e-mark-execute-all)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-key map "j" 'mu4e-jump-to-maildir)
(define-key map "a" 'mu4e-hdrs-action)
(define-key map "j" 'mu4e~headers-jump-to-maildir)
(define-key map "a" 'mu4e-headers-action)
;; message composition
(define-key map "R" 'mu4e-compose-reply)
@ -365,8 +367,8 @@ after the end of the search results."
(define-key map "C" 'mu4e-compose-new)
(define-key map "E" 'mu4e-compose-edit)
(define-key map (kbd "RET") 'mu4e-view-message)
(define-key map [mouse-2] 'mu4e-view-message)
(define-key map (kbd "RET") 'mu4e-headers-view-message)
(define-key map [mouse-2] 'mu4e-headers-view-message)
(define-key map "$" 'mu4e-show-log)
(define-key map "H" 'mu4e-display-manual)
@ -376,8 +378,8 @@ after the end of the search results."
(let ((menumap (make-sparse-keymap "Headers")))
(define-key map [menu-bar headers] (cons "Headers" menumap))
(define-key menumap [mu4e~hdrs-kill-buffer-and-window]
'("Quit view" . mu4e~hdrs-kill-buffer-and-window))
(define-key menumap [mu4e~headers-kill-buffer-and-window]
'("Quit view" . mu4e~headers-kill-buffer-and-window))
(define-key menumap [display-help] '("Help" . mu4e-display-manual))
(define-key menumap [sepa0] '("--"))
@ -385,18 +387,18 @@ after the end of the search results."
(define-key menumap [execute-marks] '("Execute marks"
. mu4e-mark-execute-all))
(define-key menumap [unmark-all] '("Unmark all" . mu4e-mark-unmark-all))
(define-key menumap [unmark] '("Unmark" . mu4e~hdrs-mark-unmark))
(define-key menumap [unmark] '("Unmark" . mu4e~headers-mark-unmark))
(define-key menumap [mark-as-read] '("Mark as read" . mu4e~hdrs-mark-read))
(define-key menumap [mark-as-read] '("Mark as read" . mu4e~headers-mark-read))
(define-key menumap [mark-as-unread]
'("Mark as unread" . mu4e~hdrs-mark-unread))
'("Mark as unread" . mu4e~headers-mark-unread))
(define-key menumap [mark-delete]
'("Mark for deletion" . mu4e~hdrs-mark-delete))
'("Mark for deletion" . mu4e~headers-mark-delete))
(define-key menumap [mark-trash]
'("Mark for trash" . mu4e~hdrs-mark-trash))
'("Mark for trash" . mu4e~headers-mark-trash))
(define-key menumap [mark-move]
'("Mark for move" . mu4e-hdrs-mark-for-move-and-next))
'("Mark for move" . mu4e-headers-mark-for-move-and-next))
(define-key menumap [sepa1] '("--"))
(define-key menumap [compose-new] '("Compose new" . mu4e-compose-new))
@ -404,29 +406,29 @@ after the end of the search results."
(define-key menumap [reply] '("Reply" . mu4e-compose-reply))
(define-key menumap [sepa2] '("--"))
(define-key menumap [refresh] '("Refresh" . mu4e-rerun-search))
(define-key menumap [refresh] '("Refresh" . mu4e-headers-rerun-search))
(define-key menumap [search] '("Search" . mu4e-search))
(define-key menumap [jump] '("Jump to maildir" . mu4e-jump-to-maildir))
(define-key menumap [jump] '("Jump to maildir" . mu4e~headers-jump-to-maildir))
(define-key menumap [sepa3] '("--"))
(define-key menumap [view] '("View" . mu4e-view-message))
(define-key menumap [next] '("Next" . mu4e-next-header))
(define-key menumap [previous] '("Previous" . mu4e-prev-header))
(define-key menumap [view] '("View" . mu4e-headers-view-message))
(define-key menumap [next] '("Next" . mu4e-headers-next))
(define-key menumap [previous] '("Previous" . mu4e-headers-prev))
(define-key menumap [sepa4] '("--")))
map)))
(fset 'mu4e-hdrs-mode-map mu4e-hdrs-mode-map)
(fset 'mu4e-headers-mode-map mu4e-headers-mode-map)
(define-derived-mode mu4e-hdrs-mode special-mode
(define-derived-mode mu4e-headers-mode special-mode
"mu4e:headers"
"Major mode for displaying mu4e search results.
\\{mu4e-hdrs-mode-map}."
(use-local-map mu4e-hdrs-mode-map)
\\{mu4e-headers-mode-map}."
(use-local-map mu4e-headers-mode-map)
(make-local-variable 'mu4e~hdrs-query)
(make-local-variable 'mu4e~hdrs-proc)
(make-local-variable 'mu4e~headers-query)
(make-local-variable 'mu4e~headers-proc)
(make-local-variable 'mu4e~highlighted-docid)
(make-local-variable 'global-mode-string)
@ -461,27 +463,27 @@ after the end of the search results."
(defvar mu4e~highlighted-docid nil
"*internal* The highlighted docid")
(defun mu4e~hdrs-highlight (docid)
(defun mu4e~headers-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
(with-current-buffer mu4e~headers-buffer
(save-excursion
;; first, unhighlight the previously highlighted docid, if any
(when (and mu4e~highlighted-docid
(mu4e~goto-docid mu4e~highlighted-docid))
(mu4e~headers-goto-docid mu4e~highlighted-docid))
(hl-line-unhighlight))
;; now, highlight the new one
(when (mu4e~goto-docid docid)
(when (mu4e~headers-goto-docid docid)
(hl-line-highlight)))
(setq mu4e~highlighted-docid docid)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-select-headers-window-if-visible ()
(defun mu4e~headers-select-window ()
"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."
(let ((win (get-buffer-window mu4e~hdrs-buffer)))
(let ((win (get-buffer-window mu4e~headers-buffer)))
(when win (select-window win))))
;;;; headers in the buffer are prefixed by an invisible string with the docid
@ -490,15 +492,15 @@ adding a lot of new headers looks really choppy."
;;;; is used for quickly finding a certain header, the latter for retrieving the
;;;; docid at point without string matching etc.
(defun mu4e~docid-cookie (docid)
(defun mu4e~headers-docid-cookie (docid)
"Create an invisible string containing DOCID; this is to be used
at the beginning of lines to identify headers."
(propertize (format "%s%d%s"
mu4e~docid-pre docid mu4e~docid-post)
mu4e~headers-docid-pre docid mu4e~headers-docid-post)
'docid docid 'invisible t))
(defun mu4e~docid-at-point (&optional point)
(defun mu4e~headers-docid-at-point (&optional point)
"Get the docid for the header at POINT, or at current (point) if
nil. Returns the docid, or nil if there is none."
(save-excursion
@ -506,7 +508,7 @@ nil. Returns the docid, or nil if there is none."
(goto-char point))
(get-text-property (line-beginning-position) 'docid)))
(defun mu4e~goto-docid (docid &optional to-mark)
(defun mu4e~headers-goto-docid (docid &optional to-mark)
"Go to the beginning of the line with the header with docid
DOCID, or nil if it cannot be found. If the optional TO-MARK is
non-nil, go to the point directly *after* the docid-cookie instead
@ -514,7 +516,7 @@ of the beginning of the line."
(let ((oldpoint (point)) (newpoint))
(goto-char (point-min))
(setq newpoint
(search-forward (mu4e~docid-cookie docid) nil t))
(search-forward (mu4e~headers-docid-cookie docid) nil t))
(unless to-mark
(if (null newpoint)
(goto-char oldpoint) ;; not found; restore old pos
@ -523,33 +525,33 @@ of the beginning of the line."
(setq newpoint (point)))))
newpoint)) ;; return the point, or nil if not found
(defun mu4e~docid-pos (docid)
(defun mu4e~headers-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."
(let ((pos))
(save-excursion
(setq pos (mu4e~goto-docid docid)))
(setq pos (mu4e~headers-goto-docid docid)))
pos))
(defun mu4e~field-for-docid (docid field)
(defun mu4e~headers-field-for-docid (docid field)
"Get FIELD (a symbol, see `mu4e-headers-names') for the message
with DOCID which must be present in the headers buffer."
(save-excursion
(when (mu4e~goto-docid docid)
(when (mu4e~headers-goto-docid docid)
(mu4e-field-at-point field))))
;;;; markers mark headers for
(defun mu4e~mark-header (docid mark)
(defun mu4e~headers-mark (docid mark)
"(Visually) mark the header for DOCID with character MARK."
(with-current-buffer mu4e~hdrs-buffer
(with-current-buffer mu4e~headers-buffer
(let ((inhibit-read-only t) (oldpoint (point)))
(unless (mu4e~goto-docid docid)
(unless (mu4e~headers-goto-docid docid)
(error "Cannot find message with docid %S" docid))
;; now, we're at the beginning of the header, looking at
;; <docid>\004
;; (which is invisible). jump past that…
(unless (re-search-forward mu4e~docid-post nil t)
(error "Cannot find the `mu4e~docid-post' separator"))
(unless (re-search-forward mu4e~headers-docid-post nil t)
(error "Cannot find the `mu4e~headers-docid-post' separator"))
;; clear old marks, and add the new ones.
(let ((msg (get-text-property (point) 'msg)))
@ -562,12 +564,12 @@ with DOCID which must be present in the headers buffer."
(goto-char oldpoint))))
(defun mu4e~hdrs-add-header (str docid point &optional msg)
(defun mu4e~headers-add-header (str docid point &optional msg)
"Add header STR with DOCID to the buffer at POINT if non-nil, or
at (point-max) otherwise. If MSG is not nil, add it as the text-property `msg'."
(unless docid (error "Invalid message"))
(when (buffer-live-p mu4e~hdrs-buffer)
(with-current-buffer mu4e~hdrs-buffer
(when (buffer-live-p mu4e~headers-buffer)
(with-current-buffer mu4e~headers-buffer
(let ((inhibit-read-only t)
(is-first-header (= (point-min) (point-max))))
(save-excursion
@ -575,16 +577,16 @@ at (point-max) otherwise. If MSG is not nil, add it as the text-property `msg'."
(insert
(propertize
(concat
(mu4e~docid-cookie docid)
(mu4e~headers-docid-cookie docid)
mu4e~mark-fringe
str "\n")
'docid docid 'msg msg)))))))
(defun mu4e~hdrs-remove-header (docid &optional ignore-missing)
(defun mu4e~headers-remove-header (docid &optional ignore-missing)
"Remove header with DOCID at POINT; when IGNORE-MISSING is
non-nill, don't raise an error when the docid is not found."
(with-current-buffer mu4e~hdrs-buffer
(if (mu4e~goto-docid docid)
(with-current-buffer mu4e~headers-buffer
(if (mu4e~headers-goto-docid docid)
(let ((inhibit-read-only t))
(delete-region (line-beginning-position) (line-beginning-position 2)))
(unless ignore-missing
@ -595,13 +597,13 @@ non-nill, don't raise an error when the docid is not found."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; search-based marking
(defun mu4e-hdrs-for-each (func)
(defun mu4e-headers-for-each (func)
"Call FUNC for each header, moving point to the header. FUNC
takes one argument msg, the msg s-expression for the corresponding
header."
(save-excursion
(goto-char (point-min))
(while (search-forward mu4e~docid-pre nil t)
(while (search-forward mu4e~headers-docid-pre nil t)
;; not really sure why we need to jump to bol; we we need
;; to, otherwise we miss lines sometimes...
(let ((msg (get-text-property (line-beginning-position) 'msg)))
@ -609,7 +611,7 @@ header."
(funcall func msg))))))
(defun mu4e~hdrs-get-markpair ()
(defun mu4e~headers-get-markpair ()
"Ask user for a mark; return (MARK . TARGET)."
(let* ((mark
(mu4e-read-option "Mark to set: "
@ -624,18 +626,18 @@ header."
(mu4e-ask-maildir-check-exists "Move message to: "))))
(cons mark target)))
(defun mu4e-hdrs-mark-matches ()
(defun mu4e-headers-mark-matches ()
"Ask user for a kind of mark (move, delete etc.), a field to
match and a regular expression to match with. Then, mark all
matching messages with that mark."
(interactive)
(let ((markpair (mu4e~hdrs-get-markpair))
(let ((markpair (mu4e~headers-get-markpair))
(field (mu4e-read-option "Field to match: "
'(("subject" nil :subject)
("from" nil :from)
("to" nil :to))))
(pattern (read-string "Regexp: ")))
(mu4e-hdrs-for-each
(mu4e-headers-for-each
(lambda (msg)
(let* ((do-mark) (value (mu4e-msg-field msg field)))
(setq do-mark
@ -649,7 +651,7 @@ matching messages with that mark."
(mu4e-mark-at-point (car markpair) (cdr markpair))))))))
(defun mu4e~hdrs-get-thread-info (msg what)
(defun mu4e~headers-get-thread-info (msg what)
"Get WHAT (a symbol, either path or thread-id) for MSG."
(let* ((thread (or (plist-get msg :thread) (error "No thread info found")))
(path (or (plist-get thread :path) (error "No threadpath found"))))
@ -663,40 +665,40 @@ matching messages with that mark."
(otherwise (error "Not supported")))))
(defun mu4e-hdrs-mark-thread (&optional subthread)
(defun mu4e-headers-mark-thread (&optional subthread)
"Mark the thread at point, if SUBTHREAD is non-nil, marking is
limited to the message at point and its descendants."
;; the tread id is shared by all messages in a thread
(interactive "P")
(let* ((thread-id (mu4e~hdrs-get-thread-info
(let* ((thread-id (mu4e~headers-get-thread-info
(mu4e-message-at-point t) 'thread-id))
(path (mu4e~hdrs-get-thread-info
(path (mu4e~headers-get-thread-info
(mu4e-message-at-point t) 'path))
(markpair (mu4e~hdrs-get-markpair))
(markpair (mu4e~headers-get-markpair))
(last-marked-point))
(mu4e-hdrs-for-each
(mu4e-headers-for-each
(lambda (msg)
(let ((my-thread-id (mu4e~hdrs-get-thread-info msg 'thread-id)))
(let ((my-thread-id (mu4e~headers-get-thread-info msg 'thread-id)))
(if subthread
;; subthread matching; msg's thread path should have path as its
;; prefix
(when (string-match (concat "^" path)
(mu4e~hdrs-get-thread-info msg 'path))
(mu4e~headers-get-thread-info msg 'path))
(mu4e-mark-at-point (car markpair) (cdr markpair))
(setq last-marked-point (point)))
;; nope; not looking for the subthread; looking for the whole thread
(when (string= thread-id
(mu4e~hdrs-get-thread-info msg 'thread-id))
(mu4e~headers-get-thread-info msg 'thread-id))
(mu4e-mark-at-point (car markpair) (cdr markpair))
(setq last-marked-point (point)))))))
(when last-marked-point
(goto-char last-marked-point)
(mu4e-next-header))))
(mu4e-headers-next))))
(defun mu4e-hdrs-mark-subthread ()
(defun mu4e-headers-mark-subthread ()
"Like `mu4e-mark-thread', but only for a sub-thread."
(interactive)
(mu4e-hdrs-mark-thread t))
(mu4e-headers-mark-thread t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -704,44 +706,39 @@ limited to the message at point and its descendants."
;;; interactive functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-headers-search-bookmark (query search-all)
"Search using some bookmarked query. when search-all (prefix
argument) is non-nil, show /all/ results, otherwise, limit to up to
`mu4e-search-results-limit'."
(interactive
(let ((query (mu4e-ask-bookmark "Bookmark: ")))
(list query current-prefix-arg)))
(when query
(mu4e-headers-search query search-all)))
(defun mu4e-search (expr)
"Start a new mu search. If prefix ARG is nil, limit the number of
results to `mu4e-search-results-limit', otherwise show all. In
other words, use the C-u prefix to get /all/ results, otherwise get
up to `mu4e-search-results-limit' much quicker."
(interactive "s[mu] search for: ")
(mu4e-hdrs-search expr current-prefix-arg))
(defun mu4e-search-bookmark ()
"Search using some bookmarked query. With C-u prefix, show /all/ results,
otherwise, limit to up to `mu4e-search-results-limit'."
(interactive)
(let ((query (mu4e-ask-bookmark "Bookmark: ")))
(when query
(mu4e-hdrs-search query current-prefix-arg))))
(defun mu4e-search-bookmark-edit-first (expr)
(defun mu4e-headers-search-bookmark-edit-first (expr search-all)
"Search using some bookmarked query, but allow for editing the
bookmark before submitting it. With C-u prefix, show /all/ results,
otherwise, limit to up to `mu4e-search-results-limit'."
(interactive
(list (read-string "[mu] search for: "
(concat (or (mu4e-ask-bookmark "Edit bookmark: ") "") " "))))
(list (read-string
(concat "Search for:")
(concat (or (mu4e-ask-bookmark "Edit bookmark: ") "") " "))
current-prefix-arg))
(when expr
(mu4e-hdrs-search expr current-prefix-arg)))
(mu4e-headers-search expr search-all)))
(defun mu4e-view-message ()
(defun mu4e-headers-view-message ()
"View message at point. If there's an existing window for the
view, re-use that one. If not, create a new one, depending on the
value of `mu4e-split-view': if it's a symbol `horizontal' or
`vertical', split the window accordingly; if it is nil, replace the
current window. "
(interactive)
(unless (eq major-mode 'mu4e-hdrs-mode)
(error "Must be in mu4e-hdrs-mode (%S)" major-mode))
(let* ((docid (mu4e~docid-at-point))
(unless (eq major-mode 'mu4e-headers-mode)
(error "Must be in mu4e-headers-mode (%S)" major-mode))
(let* ((docid (mu4e~headers-docid-at-point))
(viewwin (and mu4e~view-buffer
(get-buffer-window mu4e~view-buffer))))
(unless docid (error "No message at point."))
@ -769,11 +766,11 @@ current window. "
'face 'mu4e-system-face 'intangible t))
(mu4e~proc-view docid))))
(defun mu4e~hdrs-kill-buffer-and-window ()
(defun mu4e~headers-kill-buffer-and-window ()
"Quit the message view and return to the main view."
(interactive)
(mu4e-mark-handle-when-leaving)
(let ((buf mu4e~hdrs-buffer))
(let ((buf mu4e~headers-buffer))
(when (buffer-live-p buf)
(bury-buffer)
(delete-windows-on buf) ;; destroy all windows for this buffer
@ -781,113 +778,59 @@ current window. "
(mu4e~main-view))
(defun mu4e-rerun-search ()
(defun mu4e-headers-rerun-search (full-search)
"Rerun the search for the last search expression; if none exists,
do a new search."
(interactive)
(if mu4e~hdrs-query
(mu4e-hdrs-search mu4e~hdrs-query)
(call-interactively 'mu4e-search)))
do a new search. If full-search is non-nil, return /all/ search
results, otherwise show up to `mu4e-search-results-limit'."
(interactive "P")
(mu4e-headers-search mu4e~headers-query full-search))
(defun mu4e~hdrs-move (lines)
(defun mu4e~headers-move (lines)
"Move point LINES lines forward (if LINES is positive) or
backward (if LINES is negative). If this succeeds, return the new
docid. Otherwise, return nil."
(unless (eq major-mode 'mu4e-hdrs-mode)
(error "Must be in mu4e-hdrs-mode (%S)" major-mode))
(unless (eq major-mode 'mu4e-headers-mode)
(error "Must be in mu4e-headers-mode (%S)" major-mode))
(let ((succeeded (= 0 (forward-line lines)))
(docid (mu4e~docid-at-point)))
(docid (mu4e~headers-docid-at-point)))
;; trick to move point, even if this function is called when this window
;; is not visible
(when docid
(set-window-point (get-buffer-window mu4e~hdrs-buffer) (point))
(set-window-point (get-buffer-window mu4e~headers-buffer) (point))
;; attempt to highlight the new line, display the message
(mu4e~hdrs-highlight docid)
(mu4e~headers-highlight docid)
;; if there already is a visible message view, show the message
(when (and (buffer-live-p mu4e~view-buffer)
(window-live-p (get-buffer-window mu4e~view-buffer)))
(mu4e-view-message)))
(mu4e-headers-view-message)))
;; return the docid only if the move succeeded
(when succeeded docid)))
(defun mu4e-next-header ()
(defun mu4e-headers-next ()
"Move point to the next message header. If this succeeds, return
the new docid. Otherwise, return nil."
(interactive)
(mu4e~hdrs-move 1))
(mu4e~headers-move 1))
(defun mu4e-prev-header ()
(defun mu4e-headers-prev ()
"Move point to the previous message header. If this succeeds,
return the new docid. Otherwise, return nil."
(interactive)
(mu4e~hdrs-move -1))
(mu4e~headers-move -1))
(defun mu4e-jump-to-maildir ()
(defun mu4e~headers-jump-to-maildir (maildir search-all)
"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
(mu4e-mark-handle-when-leaving)
(mu4e-hdrs-search (concat "\"maildir:" fld "\"")
current-prefix-arg))))
(interactive
(let ((maildir (mu4e-ask-maildir "Jump to maildir: ")))
(list maildir current-prefix-arg)))
(when maildir
(mu4e-mark-handle-when-leaving)
(mu4e-headers-search (concat "\"maildir:" maildir "\"") search-all)))
(defun mu4e-compose (compose-type)
"Start composing a message of COMPOSE-TYPE, where COMPOSE-TYPE is
a symbol, one of `reply', `forward', `edit', `new'. All but `new'
take the message at point as input. Symbol `edit' is only allowed
for draft messages."
(interactive)
(let ((mu4e~hdrs-buffer (get-buffer-create mu4e~hdrs-buffer-name))
(compose-type
(or compose-type
(intern (ido-completing-read "Compose type: "
'("reply" "forward" "edit" "new"))))))
(with-current-buffer mu4e~hdrs-buffer
;; 'new is special, since it takes no existing message as arg therefore,
;; we don't need to call thec backend, and call the handler *directly*
(if (eq compose-type 'new)
(mu4e~compose-handler 'new)
;; otherwise, we need the doc-id
(let ((docid (mu4e~docid-at-point)))
(unless docid (error "No message at point."))
;; note, the first two chars of the line (the mark margin) does *not*
;; have the 'draft property; thus, we check one char before the end of
;; the current line instead
(unless (or (not (eq compose-type 'edit))
(get-text-property (- (line-end-position) 1) 'draft))
(error "Editing is only allowed for draft messages"))
;; if there's a visible view window, select that before starting
;; composing a new message, so that one will be replaced by the
;; compose window. The 10-or-so line headers buffer is not a good way
;; to write it...
(let ((viewwin (get-buffer-window mu4e~view-buffer)))
(when (window-live-p viewwin)
(select-window viewwin)))
;; talk to the backend
(mu4e~proc-compose compose-type docid))))))
(defun mu4e-compose-reply ()
"Reply to the current message."
(interactive) (mu4e-compose 'reply))
(defun mu4e-compose-forward ()
"Forward the current message."
(interactive) (mu4e-compose 'forward))
(defun mu4e-compose-edit ()
"Edit the draft message."
(interactive) (mu4e-compose 'edit))
(defun mu4e-compose-new ()
"Compose a new message."
(interactive) (mu4e-compose 'new))
(defun mu4e-hdrs-action ()
(defun mu4e-headers-action ()
"Ask user what to do with message-at-point, then do it. The
actions are specified in `mu4e-headers-actions'."
(interactive)
@ -895,20 +838,19 @@ actions are specified in `mu4e-headers-actions'."
(actionfunc (mu4e-read-option "Action: " mu4e-headers-actions)))
(funcall actionfunc msg)))
(defun mu4e-hdrs-mark-and-next (mark)
(defun mu4e-headers-mark-and-next (mark)
"Set mark MARK on the message at point or on all messages in the
region if there is a region, then move to the next message."
(interactive)
(mu4e-mark-set mark)
(mu4e-next-header))
(mu4e-headers-next))
(defun mu4e-hdrs-mark-for-move-and-next ()
(defun mu4e-headers-mark-for-move-and-next ()
"Set mark MARK on the message at point or on all messages in the
region if there is a region, then move to the next message."
(interactive)
(mu4e-mark-for-move-set)
(mu4e-next-header))
(mu4e-headers-next))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'mu4e-hdrs)
(provide 'mu4e-headers)

View File

@ -32,12 +32,12 @@
(defvar mu4e-main-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "b" 'mu4e-search-bookmark)
(define-key map "B" 'mu4e-search-bookmark-edit-first)
(define-key map "b" 'mu4e-headers-search-bookmark)
(define-key map "B" 'mu4e-headers-search-bookmark-edit-first)
(define-key map "s" 'mu4e-search)
(define-key map "s" 'mu4e-headers-search)
(define-key map "q" 'mu4e-quit)
(define-key map "j" 'mu4e-jump-to-maildir)
(define-key map "j" 'mu4e~headers-jump-to-maildir)
(define-key map "C" 'mu4e-compose-new)
(define-key map "m" 'mu4e~main-toggle-mail-sending-mode)

View File

@ -96,7 +96,7 @@ The following marks are available, and the corresponding props:
`unread' n mark the message as unread
`unmark' n unmark this message"
(interactive)
(let* ((docid (mu4e~docid-at-point))
(let* ((docid (mu4e~headers-docid-at-point))
(markkar
(case mark ;; the visual mark
('move "m")
@ -108,7 +108,7 @@ The following marks are available, and the corresponding props:
(t (error "Invalid mark %S" mark)))))
(unless docid (error "No message on this line"))
(save-excursion
(when (mu4e~mark-header docid markkar)
(when (mu4e~headers-mark docid markkar)
;; update the hash -- remove everything current, and if add the new stuff,
;; unless we're unmarking
(remhash docid mu4e~mark-map)
@ -123,10 +123,10 @@ The following marks are available, and the corresponding props:
(when target
(let* ((targetstr (propertize (concat "-> " target " ")
'face 'mu4e-system-face))
;; mu4e-goto-docid docid t \will take us just after the
;; mu4e~headers-goto-docid docid t \will take us just after the
;; docid cookie and then we skip the mu4e~mark-fringe
(start (+ (length mu4e~mark-fringe)
(mu4e~goto-docid docid t)))
(mu4e~headers-goto-docid docid t)))
(overlay (make-overlay start (+ start (length targetstr)))))
(overlay-put overlay 'display targetstr)
docid)))))))
@ -153,7 +153,7 @@ headers in the region."
the region, for moving to maildir TARGET. If target is not
provided, function asks for it."
(interactive)
(unless (mu4e~docid-at-point)
(unless (mu4e~headers-docid-at-point)
(error "No message at point."))
(let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
(target (if (string= (substring target 0 1) "/")
@ -211,7 +211,7 @@ If NO-CONFIRMATION is non-nil, don't ask user for confirmation."
(maphash
(lambda (docid val)
(save-excursion
(when (mu4e~goto-docid docid)
(when (mu4e~headers-goto-docid docid)
(mu4e-mark-set 'unmark))))
mu4e~mark-map)
;; in any case, clear the marks map

View File

@ -41,18 +41,18 @@
(require 'speedbar)
(require 'mu4e-vars)
(require 'mu4e-hdrs)
(require 'mu4e-headers)
(defvar mu4e-main-speedbar-key-map nil
"Keymap used when in mu4e display mode.")
(defvar mu4e-hdrs-speedbar-key-map nil
(defvar mu4e-headers-speedbar-key-map nil
"Keymap used when in mu4e display mode.")
(defvar mu4e-view-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.")
(defvar mu4e-hdrs-speedbar-menu-items nil
(defvar mu4e-headers-speedbar-menu-items nil
"Additional menu-items to add to speedbar frame.")
(defvar mu4e-view-speedbar-menu-items nil
"Additional menu-items to add to speedbar frame.")
@ -62,7 +62,7 @@
"Install those variables used by speedbar to enhance mu4e."
(dolist (keymap
'( mu4e-main-speedbar-key-map
mu4e-hdrs-speedbar-key-map
mu4e-headers-speedbar-key-map
mu4e-view-speedbar-key-map))
(unless keymap
(setq keymap (speedbar-make-specialized-keymap))
@ -88,9 +88,10 @@
(mu4e-get-maildirs mu4e-maildir)))
(defun mu4e~speedbar-maildir (&optional text token ident)
"Load in the mu4e file TEXT. TOKEN and INDENT are not used."
"Jump to maildir TOKEN. TEXT and INDENT are not used."
(speedbar-with-attached-buffer
(mu4e-search (concat "\"maildir:" token "\""))))
(mu4e-headers-search (concat "\"maildir:" token "\"")
current-prefix-arg)))
(defun mu4e~speedbar-render-bookmark-list ()
"Insert the list of bookmarks in the speedbar"
@ -105,9 +106,9 @@
mu4e-bookmarks))
(defun mu4e~speedbar-bookmark (&optional text token ident)
"Load in the mu4e file TEXT. TOKEN and INDENT are not used."
"Run bookmarked query TOKEN. TEXT and INDENT are not used."
(speedbar-with-attached-buffer
(mu4e-search token)))
(mu4e-headers-search token current-prefix-arg)))
;;;###autoload
(defun mu4e-speedbar-buttons (buffer)
@ -123,7 +124,7 @@
(mu4e~speedbar-render-maildir-list))
(defun mu4e-main-speedbar-buttons (buffer) (mu4e-speedbar-buttons buffer))
(defun mu4e-hdrs-speedbar-buttons (buffer) (mu4e-speedbar-buttons buffer))
(defun mu4e-headers-speedbar-buttons (buffer) (mu4e-speedbar-buttons buffer))
(defun mu4e-view-speedbar-buttons (buffer) (mu4e-speedbar-buttons buffer))

View File

@ -197,7 +197,7 @@ and offer to create it if it does not exist yet."
the region, for moving to maildir TARGET. If target is not
provided, function asks for it."
(interactive)
(unless (mu4e~docid-at-point)
(unless (mu4e~headers-docid-at-point)
(error "No message at point."))
(let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
(target (if (string= (substring target 0 1) "/")
@ -211,9 +211,6 @@ provided, function asks for it."
(mu4e-mark-set 'move target))))
(defun mu4e-ask-bookmark (prompt &optional kar)
"Ask the user for a bookmark (using PROMPT) as defined in
`mu4e-bookmarks', then return the corresponding query."
@ -363,10 +360,11 @@ top level if there is none."
(interactive)
(info (case major-mode
('mu4e-main-mode "(mu4e)Main view")
('mu4e-hdrs-mode "(mu4e)Headers view")
('mu4e-headers-mode "(mu4e)Headers view")
('mu4e-view-mode "(mu4e)Message view")
(t "mu4e"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-msg-field (msg field)
@ -415,7 +413,7 @@ message. If optional RAISE-ERR is non-nil, raise an error when
there is no message at point."
(let ((msg
(cond
((eq major-mode 'mu4e-hdrs-mode)
((eq major-mode 'mu4e-headers-mode)
(get-text-property (point) 'msg))
((eq major-mode 'mu4e-view-mode)
mu4e~view-msg))))
@ -430,9 +428,9 @@ point in eiter the headers buffer or the view buffer."
(defun mu4e-last-query ()
"Get the most recent query or nil if there is none."
(when (buffer-live-p mu4e~hdrs-buffer)
(with-current-buffer mu4e~hdrs-buffer
mu4e~hdrs-query)))
(when (buffer-live-p mu4e~headers-buffer)
(with-current-buffer mu4e~headers-buffer
mu4e~headers-query)))
(defun mu4e-select-other-view ()
"When the headers view is selected, select the message view (if
@ -440,10 +438,10 @@ that has a live window), and vice versa."
(interactive)
(let* ((other-buf
(cond
((eq major-mode 'mu4e-hdrs-mode)
((eq major-mode 'mu4e-headers-mode)
mu4e~view-buffer)
((eq major-mode 'mu4e-view-mode)
mu4e~hdrs-buffer)))
mu4e~headers-buffer)))
(other-win (and other-buf (get-buffer-window other-buf))))
(if (window-live-p other-win)
(select-window other-win)
@ -517,8 +515,6 @@ split-window."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; start and stopping

View File

@ -203,8 +203,6 @@ flag set)."
"Face for the mark in the headers list."
:group 'mu4e-faces)
(defface mu4e-view-header-key-face
'((t :inherit font-lock-builtin-face :bold t))
"Face for a header key (such as \"Foo\" in \"Subject:\ Foo\") in
@ -273,6 +271,14 @@ flag set)."
headers)."
:group 'mu4e-faces)
(defconst mu4e-logo
(concat
(propertize "mu" 'face 'font-lock-builtin-face)
(propertize "4" 'face 'font-lock-constant-face)
(propertize "e" 'face 'font-lock-string-face))
"A propertized string for the mu4e 'logo'.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; internal variables / constants
@ -299,9 +305,9 @@ view). Most fields should be self-explanatory. A special one is
;; run-time vars used in multiple places
;; headers
(defconst mu4e~hdrs-buffer-name "*mu4e-headers*"
(defconst mu4e~headers-buffer-name "*mu4e-headers*"
"Name of the buffer for message headers.")
(defvar mu4e~hdrs-buffer nil "Buffer for message headers")
(defvar mu4e~headers-buffer nil "Buffer for message headers")
; view
(defconst mu4e~view-buffer-name "*mu4e-view*"
"Name for the message view buffer")

View File

@ -30,6 +30,7 @@
(require 'mu4e-vars)
(require 'mu4e-mark)
(require 'mu4e-proc)
(require 'mu4e-compose)
(require 'mu4e-actions)
;; we prefer the improved fill-region
@ -127,7 +128,7 @@ where:
;; some buffer-local variables
(defvar mu4e~view-hdrs-buffer nil
(defvar mu4e~view-headers-buffer nil
"*internal* Headers buffer connected to this view.")
(defvar mu4e~view-lines-wrapped nil "*internal* Whether lines are wrapped.")
@ -151,15 +152,15 @@ plist."
(fieldval (plist-get msg field)))
(case field
(:subject (mu4e~view-construct-header fieldname fieldval))
(:path (mu4e~view-construct-header fieldname fieldval))
(:path (mu4e~view-construct-header fieldname fieldval))
(:maildir (mu4e~view-construct-header fieldname fieldval))
(:flags (mu4e~view-construct-header fieldname
(if fieldval (format "%S" fieldval) "")))
(:flags (mu4e~view-construct-header fieldname
(if fieldval (format "%S" fieldval) "")))
;; contact fields
(:to (mu4e~view-construct-contacts msg field))
(:from (mu4e~view-construct-contacts msg field))
(:cc (mu4e~view-construct-contacts msg field))
(:bcc (mu4e~view-construct-contacts msg field))
(:to (mu4e~view-construct-contacts msg field))
(:from (mu4e~view-construct-contacts msg field))
(:cc (mu4e~view-construct-contacts msg field))
(:bcc (mu4e~view-construct-contacts msg field))
;; if we (`user-mail-address' are the From, show To, otherwise,
;; show From
@ -188,7 +189,7 @@ plist."
(mu4e-body-text msg)))
(defun mu4e-view (msg hdrsbuf &optional refresh)
(defun mu4e-view (msg headersbuf &optional refresh)
"Display the message MSG in a new buffer, and keep in sync with HDRSBUF.
'In sync' here means that moving to the next/previous message in
the the message view affects HDRSBUF, as does marking etc.
@ -203,7 +204,7 @@ marking if it still had that."
(let ((inhibit-read-only t))
(setq ;; buffer local
mu4e~view-msg msg
mu4e~view-hdrs-buffer hdrsbuf
mu4e~view-headers-buffer headersbuf
mu4e~view-buffer buf)
(erase-buffer)
@ -326,16 +327,16 @@ is nil, and otherwise open it."
;; but that's not very useful in this case
(define-key map "z" 'mu4e-view-kill-buffer-and-window)
(define-key map "s" 'mu4e-search)
(define-key map "s" 'mu4e-headers-search)
(define-key map "b" 'mu4e-search-bookmark)
(define-key map "B" 'mu4e-search-bookmark-edit-first)
(define-key map "b" 'mu4e-headers-search-bookmark)
(define-key map "B" 'mu4e-headers-search-bookmark-edit-first)
(define-key map "%" 'mu4e-view-mark-matches)
(define-key map "t" 'mu4e-view-mark-subthread)
(define-key map "T" 'mu4e-view-mark-thread)
(define-key map "j" 'mu4e-jump-to-maildir)
(define-key map "j" 'mu4e~headers-jump-to-maildir)
(define-key map "g" 'mu4e-view-go-to-url)
@ -440,8 +441,8 @@ is nil, and otherwise open it."
(define-key menumap [reply] '("Reply" . mu4e-compose-reply))
(define-key menumap [sepa3] '("--"))
(define-key menumap [search] '("Search" . mu4e-search))
(define-key menumap [jump] '("Jump to maildir" . mu4e-jump-to-maildir))
(define-key menumap [search] '("Search" . mu4e-headers-search))
(define-key menumap [jump] '("Jump to maildir" . mu4e~headers-jump-to-maildir))
(define-key menumap [sepa4] '("--"))
(define-key menumap [next] '("Next" . mu4e~view-next-header))
@ -456,7 +457,7 @@ is nil, and otherwise open it."
\\{mu4e-view-mode-map}."
(use-local-map mu4e-view-mode-map)
(make-local-variable 'mu4e~view-hdrs-buffer)
(make-local-variable 'mu4e~view-headers-buffer)
(make-local-variable 'mu4e~view-msg)
(make-local-variable 'mu4e~view-link-map)
@ -588,16 +589,16 @@ number them so they can be opened using `mu4e-view-go-to-url'."
(flush-lines "^[:blank:]*>")
(setq mu4e~view-cited-hidden t))))
(defun mu4e~view-hdrs-move (lines)
(defun mu4e~view-headers-move (lines)
"Move point LINES lines forward (if LINES is positive) or
backward (if LINES is negative). If this succeeds, return the new
docid. Otherwise, return nil."
(when (buffer-live-p mu4e~view-hdrs-buffer)
(with-current-buffer mu4e~view-hdrs-buffer
(mu4e~hdrs-move lines))))
(when (buffer-live-p mu4e~view-headers-buffer)
(with-current-buffer mu4e~view-headers-buffer
(mu4e~headers-move lines))))
(defun mu4e~view-next-header()(interactive)(mu4e~view-hdrs-move 1))
(defun mu4e~view-prev-header()(interactive)(mu4e~view-hdrs-move -1))
(defun mu4e~view-next-header()(interactive)(mu4e~view-headers-move 1))
(defun mu4e~view-prev-header()(interactive)(mu4e~view-headers-move -1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -623,7 +624,7 @@ docid. Otherwise, return nil."
"Redisplay the current message, without wrapped lines or hidden
citations."
(interactive)
(mu4e-view mu4e~view-msg mu4e~view-hdrs-buffer t)
(mu4e-view mu4e~view-msg mu4e~view-headers-buffer t)
(setq
mu4e~view-lines-wrapped nil
mu4e~view-cited-hidden nil))
@ -656,25 +657,25 @@ if nil), then do it. The actions are specified in
match and a regular expression to match with. Then, mark all
matching messages with that mark."
(interactive)
(when (buffer-live-p mu4e~view-hdrs-buffer)
(with-current-buffer mu4e~view-hdrs-buffer
(mu4e-hdrs-mark-matches))))
(when (buffer-live-p mu4e~view-headers-buffer)
(with-current-buffer mu4e~view-headers-buffer
(mu4e-headers-mark-matches))))
(defun mu4e-view-mark-thread ()
"Ask user for a kind of mark (move, delete etc.), and apply it to
all messages in the thread at point in the headers view."
(interactive)
(when (buffer-live-p mu4e~view-hdrs-buffer)
(with-current-buffer mu4e~view-hdrs-buffer
(mu4e-hdrs-mark-thread))))
(when (buffer-live-p mu4e~view-headers-buffer)
(with-current-buffer mu4e~view-headers-buffer
(mu4e-headers-mark-thread))))
(defun mu4e-view-mark-subthread ()
"Ask user for a kind of mark (move, delete etc.), and apply it to
all messages in the thread at point in the headers view."
(interactive)
(when (buffer-live-p mu4e~view-hdrs-buffer)
(with-current-buffer mu4e~view-hdrs-buffer
(mu4e-hdrs-mark-subthread))))
(when (buffer-live-p mu4e~view-headers-buffer)
(with-current-buffer mu4e~view-headers-buffer
(mu4e-headers-mark-subthread))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -801,10 +802,10 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )."
;;; marking
(defun mu4e~view-mark-set (mark)
"Set mark on the current messages."
(unless (buffer-live-p mu4e~view-hdrs-buffer)
(unless (buffer-live-p mu4e~view-headers-buffer)
(error "No headers buffer available"))
(let ((docid (mu4e-msg-field mu4e~view-msg :docid)))
(with-current-buffer mu4e~view-hdrs-buffer
(with-current-buffer mu4e~view-headers-buffer
(if (eq mark 'move)
(mu4e-mark-for-move-set)
(mu4e-mark-at-point mark)))))
@ -853,7 +854,7 @@ user that unmarking only works in the header list."
that execution can only take place in n the header list."
(interactive)
(if (mu4e~split-view-p)
(with-current-buffer mu4e~view-hdrs-buffer
(with-current-buffer mu4e~view-headers-buffer
(mu4e-mark-execute-all))
(message "Execution needs to be done in the header list view")))

View File

@ -29,7 +29,7 @@
(eval-when-compile (require 'cl))
(require 'mu4e-meta) ;; autogenerated file with metadata (version etc.)
(require 'mu4e-hdrs) ;; headers view
(require 'mu4e-headers) ;; headers view
(require 'mu4e-view) ;; message view
(require 'mu4e-main) ;; main screen
(require 'mu4e-compose) ;; message composition / sending
@ -44,13 +44,13 @@
;; to handle them.
;;
;;
;; these are all defined in mu4e-hdrs
(setq mu4e-update-func 'mu4e~hdrs-update-handler)
(setq mu4e-header-func 'mu4e~hdrs-header-handler)
(setq mu4e-found-func 'mu4e~hdrs-found-handler)
(setq mu4e-view-func 'mu4e~hdrs-view-handler)
(setq mu4e-remove-func 'mu4e~hdrs-remove-handler)
(setq mu4e-erase-func 'mu4e~hdrs-clear)
;; these are all defined in mu4e-headers
(setq mu4e-update-func 'mu4e~headers-update-handler)
(setq mu4e-header-func 'mu4e~headers-header-handler)
(setq mu4e-found-func 'mu4e~headers-found-handler)
(setq mu4e-view-func 'mu4e~headers-view-handler)
(setq mu4e-remove-func 'mu4e~headers-remove-handler)
(setq mu4e-erase-func 'mu4e~headers-clear)
;; these ones are define in mu4e-utils
(setq mu4e-info-func 'mu4e-info-handler)

View File

@ -34,7 +34,7 @@
"Store a link to a mu4e query or message."
(cond
;; storing links to queries
((eq major-mode 'mu4e-hdrs-mode)
((eq major-mode 'mu4e-headers-mode)
(let* ((query (mu4e-last-query))
desc link)
(org-store-link-props :type "mu4e" :query query)
@ -67,11 +67,10 @@ the query (for paths starting with 'query:')."
((string-match "^msgid:\\(.+\\)" path)
(mu4e-view-message-with-msgid (match-string 1 path)))
((string-match "^query:\\(.+\\)" path)
(mu4e-search (match-string 1 path)))
(mu4e-headers-search (match-string 1 path) current-prefix-arg))
(t (message "mu4e: unrecognized link type '%s'" path))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'org-mu4e)
;;; org-mu4e.el ends here