* 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
1 changed files with 44 additions and 47 deletions

View File

@ -43,8 +43,7 @@ message headers to put marks.")
(let ((inhibit-read-only t))
(with-current-buffer mu4e-hdrs-buffer
(erase-buffer)
(when mu4e-marks-map (clrhash mu4e-marks-map))
(when mu4e-thread-info-map (clrhash mu4e-thread-info-map))))))
(when mu4e-marks-map (clrhash mu4e-marks-map))))))
(defun mu4e-hdrs-search (expr &optional full-search)
@ -104,6 +103,13 @@ headers."
(when (mu4e-hdrs-docid-is-marked docid)
(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
;; the same docid...
(mu4e-hdrs-remove-handler docid)
@ -163,16 +169,12 @@ into a string."
(first-child "\\ ")
(duplicate "= ")
(t "| "))))))
;; FIXME: when updating an header line, we don't know the thread
;; stuff
(defun mu4e-hdrs-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)
(let* ((docid (plist-get msg :docid))
(thread-info
(or (plist-get msg :thread) (gethash docid mu4e-thread-info-map)))
(line
(mapconcat
(lambda (f-w)
@ -180,7 +182,10 @@ if provided, or at the end of the buffer otherwise."
(val (plist-get msg field))
(str
(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)
((:to :from :cc :bcc) (mu4e-hdrs-contact-str val))
;; 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
(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
(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-hdrs-proc)
(make-local-variable 'mu4e-marks-map)
(make-local-variable 'mu4e-thread-info-map)
(make-local-variable 'mu4e--highlighted-docid)
(make-local-variable 'global-mode-string)
@ -370,7 +371,6 @@ after the end of the search results."
(setq
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
buffer-undo-list t ;; don't record undo information
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
nil. Returns the docid, or nil if there is none."
(save-excursion
(when point( goto-char point))
(when point
(goto-char point))
(get-text-property (line-beginning-position) 'docid)))
(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)))
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
(defun mu4e--mark-header (docid 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar mu4e-marks-map nil
@ -775,9 +771,10 @@ docid. Otherwise, return nil."
(docid (mu4e--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))
;; attempt to highlight the new line
(mu4e-hdrs-highlight docid)
(mu4e-hdrs-highlight docid))
;; return the docid only if the move succeeded
(when succeeded docid))))