* mu4e-hdrs.el: cleanup the handling of the mark fringe

This commit is contained in:
djcb 2012-04-28 09:08:28 +03:00
parent b01390785e
commit 645eac4076
1 changed files with 48 additions and 33 deletions

View File

@ -98,15 +98,24 @@ are of the form:
;;;; internal variables/constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst mu4e~hdrs-fringe " " "*internal* The space on the left of
message headers to put marks.")
;; the fringe is the space on the left of headers, where we put marks below some
;; handy definitions; only `mu4e-hdrs-fringe-len' should be change (if ever),
;; the others follow from that.
(defconst mu4e~hdrs-fringe-len 2
"Width of the fringe for marks on the left.")
(defconst mu4e~hdrs-fringe (make-string mu4e~hdrs-fringe-len ?\s)
"The space on the left of message headers to put marks.")
(defconst mu4e~hdrs-fringe-format (format "%%-%ds" mu4e~hdrs-fringe-len)
"Format string to set a mark and leave remaining space.")
;; docid cookies
(defconst mu4e~docid-pre "\376"
"Each header starts (invisibly) with the `mu4e-docid-pre',
followed by the docid, followd by `mu4e-docid-post'.")
followed by the docid, followed by `mu4e-docid-post'.")
(defconst mu4e~docid-post "\377"
"Each header starts (invisibly) with the `mu4e-docid-pre',
followed by the docid, followd by `mu4e-docid-post'.")
followed by the docid, followed by `mu4e-docid-post'.")
(defun mu4e~hdrs-clear ()
"Clear the header buffer and related data structures."
@ -454,7 +463,7 @@ after the end of the search results."
(setq header-line-format
(cons
(make-string
(+ (length mu4e~hdrs-fringe) (floor (fringe-columns 'left t))) ?\s)
(+ mu4e~hdrs-fringe-len (floor (fringe-columns 'left t))) ?\s)
(map 'list
(lambda (item)
(let ((field (cdr (assoc (car item) mu4e-header-names)))
@ -561,12 +570,16 @@ with DOCID which must be present in the headers buffer."
;; (which is invisible). jump past that…
(unless (re-search-forward mu4e~docid-post nil t)
(error "Cannot find the `mu4e~docid-post' separator"))
;; we found the separator we move point one to the right for the
;; the area to write the marker.
;;(forward-char)
;; clear old marks, and add the new ones.
(delete-char (length mu4e~hdrs-fringe))
(insert (propertize mark 'face 'mu4e-hdrs-marks-face) " ") ;; FIXME
(let ((msg (get-text-property (point) 'msg)))
(delete-char mu4e~hdrs-fringe-len)
(insert (propertize
(format mu4e~hdrs-fringe-format mark)
'face 'mu4e-header-marks-face
'docid docid
'msg msg)))
(goto-char oldpoint))))
@ -584,7 +597,9 @@ at (point-max) otherwise. If MSG is not nil, add it as the text-property `msg'."
(propertize
(concat
(mu4e~docid-cookie docid)
mu4e~hdrs-fringe str "\n") 'docid docid 'msg msg)))))))
mu4e~hdrs-fringe
str "\n")
'docid docid 'msg msg)))))))
(defun mu4e~hdrs-remove-header (docid &optional ignore-missing)
"Remove header with DOCID at POINT; when IGNORE-MISSING is