* small fixes / cleanups

This commit is contained in:
djcb 2012-04-29 22:03:27 +03:00
parent 422516a77c
commit f347d5eb1c
3 changed files with 40 additions and 42 deletions

View File

@ -426,7 +426,7 @@ there is no message at point."
((eq major-mode 'mu4e-hdrs-mode) ((eq major-mode 'mu4e-hdrs-mode)
(get-text-property (point) 'msg)) (get-text-property (point) 'msg))
((eq major-mode 'mu4e-view-mode) ((eq major-mode 'mu4e-view-mode)
mu4e-current-msg)))) mu4e~view-msg))))
(if (and (null msg) raise-err) (if (and (null msg) raise-err)
(error "No message at point") (error "No message at point")
msg))) msg)))
@ -435,7 +435,13 @@ there is no message at point."
"Get FIELD (a symbol, see `mu4e-header-names') for the message at "Get FIELD (a symbol, see `mu4e-header-names') for the message at
point in eiter the headers buffer or the view buffer." point in eiter the headers buffer or the view buffer."
(plist-get (mu4e-message-at-point t) field)) (plist-get (mu4e-message-at-point t) field))
(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)))
(defun mu4e-select-other-view () (defun mu4e-select-other-view ()
"When the headers view is selected, select the message view (if "When the headers view is selected, select the message view (if
that has a live window), and vice versa." that has a live window), and vice versa."
@ -443,7 +449,7 @@ that has a live window), and vice versa."
(let* ((other-buf (let* ((other-buf
(cond (cond
((eq major-mode 'mu4e-hdrs-mode) ((eq major-mode 'mu4e-hdrs-mode)
mu4e-view-buffer) mu4e~view-buffer)
((eq major-mode 'mu4e-view-mode) ((eq major-mode 'mu4e-view-mode)
mu4e~hdrs-buffer))) mu4e~hdrs-buffer)))
(other-win (and other-buf (get-buffer-window other-buf)))) (other-win (and other-buf (get-buffer-window other-buf))))

View File

@ -299,19 +299,14 @@ view). Most fields should be self-explanatory. A special one is
;; run-time vars used in multiple places ;; run-time vars used in multiple places
;; headers ;; headers
(defvar mu4e-last-expr nil "*internal* The most recent search expression.")
(defconst mu4e~hdrs-buffer-name "*mu4e-headers*" (defconst mu4e~hdrs-buffer-name "*mu4e-headers*"
"*internal* Name of the buffer for message headers.") "Name of the buffer for message headers.")
(defvar mu4e~hdrs-buffer nil "*internal* Buffer for message headers") (defvar mu4e~hdrs-buffer nil "Buffer for message headers")
; view
;; view (defconst mu4e~view-buffer-name "*mu4e-view*"
(defconst mu4e-view-buffer-name "*mu4e-view*" "Name for the message view buffer")
"*internal* Name for the message view buffer") (defvar mu4e~view-buffer nil "The view buffer.")
(defvar mu4e-view-buffer nil "*internal* The view buffer.")
(defvar mu4e-current-msg nil "*internal* The message being
viewed in view mode.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; our handlers funcs ;; our handlers funcs

View File

@ -36,7 +36,6 @@
(require 'filladapt nil 'noerror) (require 'filladapt nil 'noerror)
(require 'comint) (require 'comint)
;; the message view ;; the message view
(defgroup mu4e-view nil (defgroup mu4e-view nil
"Settings for the message view." "Settings for the message view."
@ -134,6 +133,9 @@ where:
(defvar mu4e~view-lines-wrapped nil "*internal* Whether lines are wrapped.") (defvar mu4e~view-lines-wrapped nil "*internal* Whether lines are wrapped.")
(defvar mu4e~view-cited-hidden nil "*internal* Whether cited lines are hidden.") (defvar mu4e~view-cited-hidden nil "*internal* Whether cited lines are hidden.")
(defvar mu4e~view-msg nil "The message being viewed in view mode.")
(defun mu4e-view-message-with-msgid (msgid) (defun mu4e-view-message-with-msgid (msgid)
"View message with MSGID. This is meant for external programs "View message with MSGID. This is meant for external programs
wanting to show specific messages - for example, `mu4e-org'." wanting to show specific messages - for example, `mu4e-org'."
@ -186,23 +188,23 @@ plist."
(mu4e-body-text msg))) (mu4e-body-text msg)))
(defun mu4e-view (msg hdrsbuf &optional update) (defun mu4e-view (msg hdrsbuf &optional refresh)
"Display the message MSG in a new buffer, and keep in sync with HDRSBUF. "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 'In sync' here means that moving to the next/previous message in
the the message view affects HDRSBUF, as does marking etc. If the the message view affects HDRSBUF, as does marking etc.
UPDATE is nil, the current message may be (visually) 'massaged',
based on the settings of `mu4e~view-wrap-lines' and REFRESH is for re-showing an already existing message.
`mu4e~view-hide-cited'.
As a side-effect, a message that is being viewed loses its 'unread' As a side-effect, a message that is being viewed loses its 'unread'
marking if it still had that." marking if it still had that."
(let ((buf (get-buffer-create mu4e-view-buffer-name))) (let ((buf (get-buffer-create mu4e~view-buffer-name)))
(with-current-buffer buf (with-current-buffer buf
(mu4e-view-mode)
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(setq ;; buffer local (setq ;; buffer local
mu4e-current-msg msg mu4e~view-msg msg
mu4e~view-hdrs-buffer hdrsbuf mu4e~view-hdrs-buffer hdrsbuf
mu4e-view-buffer buf) mu4e~view-buffer buf)
(erase-buffer) (erase-buffer)
(insert (mu4e-view-message-text msg)) (insert (mu4e-view-message-text msg))
@ -214,19 +216,14 @@ marking if it still had that."
(mu4e~view-fontify-footer) (mu4e~view-fontify-footer)
(mu4e~view-make-urls-clickable) (mu4e~view-make-urls-clickable)
(unless update (unless refresh
;; if we're showing the message for the first time, use the values of ;; if we're showing the message for the first time, use the values of
;; user-settable variables `mu4e~view-wrap-lines' and ;; user-settable variables `mu4e~view-wrap-lines' and
;; `mu4e~view-hide-cited' to determine whether we should wrap/hide ;; `mu4e~view-hide-cited' to determine whether we should wrap/hide
(progn (when mu4e~view-lines-wrapped (mu4e~view-wrap-lines))
(when mu4e~view-lines-wrapped (mu4e~view-wrap-lines)) (when mu4e~view-cited-hidden (mu4e~view-hide-cited))
(when mu4e~view-cited-hidden (mu4e~view-hide-cited)))) ;; no use in trying to set flags again
(mu4e~view-mark-as-read-maybe))))))
;; no use in trying to set flags again
(unless update
(mu4e~view-mark-as-read-maybe)))
(mu4e-view-mode))))
(defun mu4e~view-construct-header (key val &optional dont-propertize-val) (defun mu4e~view-construct-header (key val &optional dont-propertize-val)
@ -460,7 +457,7 @@ is nil, and otherwise open it."
(use-local-map mu4e-view-mode-map) (use-local-map mu4e-view-mode-map)
(make-local-variable 'mu4e~view-hdrs-buffer) (make-local-variable 'mu4e~view-hdrs-buffer)
(make-local-variable 'mu4e-current-msg) (make-local-variable 'mu4e~view-msg)
(make-local-variable 'mu4e~view-link-map) (make-local-variable 'mu4e~view-link-map)
(make-local-variable 'mu4e~view-lines-wrapped) (make-local-variable 'mu4e~view-lines-wrapped)
@ -486,9 +483,9 @@ is nil, and otherwise open it."
(defun mu4e~view-mark-as-read-maybe () (defun mu4e~view-mark-as-read-maybe ()
"Clear the current message's New/Unread status and set it to "Clear the current message's New/Unread status and set it to
Seen; if the message is not New/Unread, do nothing." Seen; if the message is not New/Unread, do nothing."
(when mu4e-current-msg (when mu4e~view-msg
(let ((flags (plist-get mu4e-current-msg :flags)) (let ((flags (plist-get mu4e~view-msg :flags))
(docid (plist-get mu4e-current-msg :docid))) (docid (plist-get mu4e~view-msg :docid)))
;; is it a new message? ;; is it a new message?
(when (or (member 'unread flags) (member 'new flags)) (when (or (member 'unread flags) (member 'new flags))
(mu4e~proc-move docid nil "+S-u-N"))))) (mu4e~proc-move docid nil "+S-u-N")))))
@ -626,7 +623,7 @@ docid. Otherwise, return nil."
"Redisplay the current message, without wrapped lines or hidden "Redisplay the current message, without wrapped lines or hidden
citations." citations."
(interactive) (interactive)
(mu4e-view mu4e-current-msg mu4e~view-hdrs-buffer t) (mu4e-view mu4e~view-msg mu4e~view-hdrs-buffer t)
(setq (setq
mu4e~view-lines-wrapped nil mu4e~view-lines-wrapped nil
mu4e~view-cited-hidden nil)) mu4e~view-cited-hidden nil))
@ -634,8 +631,8 @@ citations."
(defun mu4e-view-kill-buffer-and-window () (defun mu4e-view-kill-buffer-and-window ()
"Quit the message view and return to the headers." "Quit the message view and return to the headers."
(interactive) (interactive)
(when (buffer-live-p mu4e-view-buffer) (when (buffer-live-p mu4e~view-buffer)
(with-current-buffer mu4e-view-buffer (with-current-buffer mu4e~view-buffer
(if (fboundp 'window-parent) ;; window-parent is an emacs24ism (if (fboundp 'window-parent) ;; window-parent is an emacs24ism
(if (window-parent) (if (window-parent)
(kill-buffer-and-window) (kill-buffer-and-window)
@ -806,7 +803,7 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )."
"Set mark on the current messages." "Set mark on the current messages."
(unless (buffer-live-p mu4e~view-hdrs-buffer) (unless (buffer-live-p mu4e~view-hdrs-buffer)
(error "No headers buffer available")) (error "No headers buffer available"))
(let ((docid (mu4e-msg-field mu4e-current-msg :docid))) (let ((docid (mu4e-msg-field mu4e~view-msg :docid)))
(with-current-buffer mu4e~view-hdrs-buffer (with-current-buffer mu4e~view-hdrs-buffer
(if (eq mark 'move) (if (eq mark 'move)
(mu4e-mark-for-move-set) (mu4e-mark-for-move-set)