* mu4e-hdrs.el: get rid of the thread-marks, no longer needed

This commit is contained in:
djcb
2012-04-11 02:08:02 +03:00
parent 86c4e7042a
commit 250026f2d6

View File

@ -43,8 +43,7 @@ message headers to put marks.")
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(with-current-buffer mu4e-hdrs-buffer (with-current-buffer mu4e-hdrs-buffer
(erase-buffer) (erase-buffer)
(when mu4e-marks-map (clrhash mu4e-marks-map)) (when mu4e-marks-map (clrhash mu4e-marks-map))))))
(when mu4e-thread-info-map (clrhash mu4e-thread-info-map))))))
(defun mu4e-hdrs-search (expr &optional full-search) (defun mu4e-hdrs-search (expr &optional full-search)
@ -104,6 +103,13 @@ headers."
(when (mu4e-hdrs-docid-is-marked docid) (when (mu4e-hdrs-docid-is-marked docid)
(mu4e-hdrs-mark 'unmark)) (mu4e-hdrs-mark 'unmark))
;; re-use the thread info from the old one; this is needed because
;; *update* message don't have thread info by themselves (unlike
;; search results)
;; but since we still have the search results, re-use those
(plist-put msg :thread
(mu4e--field-for-docid docid :thread))
;; first, remove the old one (otherwise, we'd have two headers with ;; first, remove the old one (otherwise, we'd have two headers with
;; the same docid... ;; the same docid...
(mu4e-hdrs-remove-handler docid) (mu4e-hdrs-remove-handler docid)
@ -163,16 +169,12 @@ into a string."
(first-child "\\ ") (first-child "\\ ")
(duplicate "= ") (duplicate "= ")
(t "| ")))))) (t "| "))))))
;; FIXME: when updating an header line, we don't know the thread
;; stuff
(defun mu4e-hdrs-header-handler (msg &optional point) (defun mu4e-hdrs-header-handler (msg &optional point)
"Create a one line description of MSG in this buffer, at POINT, "Create a one line description of MSG in this buffer, at POINT,
if provided, or at the end of the buffer otherwise." if provided, or at the end of the buffer otherwise."
(when (buffer-live-p mu4e-hdrs-buffer) (when (buffer-live-p mu4e-hdrs-buffer)
(let* ((docid (plist-get msg :docid)) (let* ((docid (plist-get msg :docid))
(thread-info
(or (plist-get msg :thread) (gethash docid mu4e-thread-info-map)))
(line (line
(mapconcat (mapconcat
(lambda (f-w) (lambda (f-w)
@ -180,7 +182,10 @@ if provided, or at the end of the buffer otherwise."
(val (plist-get msg field)) (val (plist-get msg field))
(str (str
(case field (case field
(:subject (concat (mu4e-thread-prefix thread-info) val)) (:subject
(concat ;; prefix subject with a thread indicator
(mu4e-thread-prefix (plist-get msg :thread))
val))
((:maildir :path) val) ((:maildir :path) val)
((:to :from :cc :bcc) (mu4e-hdrs-contact-str val)) ((:to :from :cc :bcc) (mu4e-hdrs-contact-str val))
;; if we (ie. `user-mail-address' is the 'From', show ;; if we (ie. `user-mail-address' is the 'From', show
@ -213,9 +218,6 @@ if provided, or at the end of the buffer otherwise."
(t ;; else (t ;; else
(propertize line 'face 'mu4e-header-face))))) (propertize line 'face 'mu4e-header-face)))))
;; store the thread info, so we can use it when updating the message
(when (and thread-info mu4e-thread-info-map)
(puthash docid thread-info mu4e-thread-info-map))
;; now, append the header line ;; now, append the header line
(mu4e-hdrs-add-header line docid point msg)))) (mu4e-hdrs-add-header line docid point msg))))
@ -362,7 +364,6 @@ after the end of the search results."
(make-local-variable 'mu4e-last-expr) (make-local-variable 'mu4e-last-expr)
(make-local-variable 'mu4e-hdrs-proc) (make-local-variable 'mu4e-hdrs-proc)
(make-local-variable 'mu4e-marks-map) (make-local-variable 'mu4e-marks-map)
(make-local-variable 'mu4e-thread-info-map)
(make-local-variable 'mu4e--highlighted-docid) (make-local-variable 'mu4e--highlighted-docid)
(make-local-variable 'global-mode-string) (make-local-variable 'global-mode-string)
@ -370,7 +371,6 @@ after the end of the search results."
(setq (setq
mu4e-marks-map (make-hash-table :size 16 :rehash-size 2) mu4e-marks-map (make-hash-table :size 16 :rehash-size 2)
mu4e-thread-info-map (make-hash-table :size 512 :rehash-size 2)
truncate-lines t truncate-lines t
buffer-undo-list t ;; don't record undo information buffer-undo-list t ;; don't record undo information
overwrite-mode 'overwrite-mode-binary overwrite-mode 'overwrite-mode-binary
@ -437,7 +437,8 @@ at the beginning of lines to identify headers."
"Get the docid for the header at POINT, or at current (point) if "Get the docid for the header at POINT, or at current (point) if
nil. Returns the docid, or nil if there is none." nil. Returns the docid, or nil if there is none."
(save-excursion (save-excursion
(when point( goto-char point)) (when point
(goto-char point))
(get-text-property (line-beginning-position) 'docid))) (get-text-property (line-beginning-position) 'docid)))
(defun mu4e--goto-docid (docid &optional to-mark) (defun mu4e--goto-docid (docid &optional to-mark)
@ -465,6 +466,13 @@ docid DOCID, or nil if it cannot be found."
(setq pos (mu4e--goto-docid docid))) (setq pos (mu4e--goto-docid docid)))
pos)) pos))
(defun mu4e--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)
(mu4e-field-at-point field))))
;;;; markers mark headers for ;;;; markers mark headers for
(defun mu4e--mark-header (docid mark) (defun mu4e--mark-header (docid mark)
"(Visually) mark the header for DOCID with character MARK." "(Visually) mark the header for DOCID with character MARK."
@ -512,18 +520,6 @@ at (point-max) otherwise. If MSG is not nil, add it as the text-property `msg'."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; threadinfo-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar mu4e-thread-info-map nil
"Map (hash) of docid->threadinfo; when filling the list of
messages, we fill a map of thread info, such that when a header
changes (e.g., it's read-flag gets set) through some (:update
...) message, we can restore the thread-info (this is needed
since :update messages do not include thread info).")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; marks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; marks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar mu4e-marks-map nil (defvar mu4e-marks-map nil
@ -775,9 +771,10 @@ docid. Otherwise, return nil."
(docid (mu4e--docid-at-point))) (docid (mu4e--docid-at-point)))
;; trick to move point, even if this function is called when this window ;; trick to move point, even if this function is called when this window
;; is not visible ;; is not visible
(when docid
(set-window-point (get-buffer-window mu4e-hdrs-buffer) (point)) (set-window-point (get-buffer-window mu4e-hdrs-buffer) (point))
;; attempt to highlight the new line ;; attempt to highlight the new line
(mu4e-hdrs-highlight docid) (mu4e-hdrs-highlight docid))
;; return the docid only if the move succeeded ;; return the docid only if the move succeeded
(when succeeded docid)))) (when succeeded docid))))