* mu4e-hdrs: fixes for the markless headers buffer

This commit is contained in:
djcb
2012-04-07 18:25:22 +03:00
parent b7f2b4e609
commit 1b65acdec0

View File

@ -129,7 +129,7 @@ from the database. This function will hide the removed message from
the current list of headers." the current list of headers."
(when (buffer-live-p mu4e-hdrs-buffer) (when (buffer-live-p mu4e-hdrs-buffer)
(with-current-buffer mu4e-hdrs-buffer (with-current-buffer mu4e-hdrs-buffer
(mu4e-hdrs-remove-header docid pos)))) (mu4e-hdrs-remove-header docid))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -399,11 +399,8 @@ at the beginning of lines to identify headers."
(defun mu4e--docid-at-point (&optional point) (defun mu4e--docid-at-point (&optional point)
"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."
(if point
(save-excursion (save-excursion
(goto-char point) (when point( goto-char point))
(get-text-property (line-beginning-position) 'docid))
;; in this case, we don't need save-excursion, should be a bit faster
(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,15 +462,15 @@ at (point-max) otherwise."
;;(mu4e-select-headers-window-if-visible) ;;(mu4e-select-headers-window-if-visible)
(save-excursion (save-excursion
(goto-char point) (goto-char point)
;; make sure the output window is selected, which it wouldn't be if called ;; make sure the output window is selected, which it wouldn't be if
;; from e.g. speedbar (output looks choppy when another window is ;; called from e.g. speedbar (output looks choppy when another window
;; selected). We use switch-to-buffer for its window-selecting side-effect - ;; is selected). We use switch-to-buffer for its window-selecting
;; but only if the window is visible ;; side-effect - but only if the window is visible
(insert (insert
(mu4e--docid-cookie docid) (mu4e--docid-cookie docid)
(propertize (concat mu4e-hdrs-fringe str "\n") 'docid docid))))))) (propertize (concat mu4e-hdrs-fringe str "\n") 'docid docid)))))))
(defun mu4e-hdrs-remove-header (docid point) (defun mu4e-hdrs-remove-header (docid)
"Remove header with DOCID at POINT." "Remove header with DOCID at POINT."
(with-current-buffer mu4e-hdrs-buffer (with-current-buffer mu4e-hdrs-buffer
(unless (mu4e--goto-docid docid) (unless (mu4e--goto-docid docid)
@ -618,9 +615,10 @@ work well."
(defun mu4e-hdrs-view () (defun mu4e-hdrs-view ()
"View message at point." "View message at point."
(let ((docid (mu4e-hdrs-get-docid))) (with-current-buffer mu4e-hdrs-buffer
(let ((docid (mu4e--docid-at-point)))
(unless docid (error "No message at point.")) (unless docid (error "No message at point."))
(mu4e-proc-view-msg docid))) (mu4e-proc-view-msg docid))))
(defun mu4e-hdrs-docid-is-marked (docid) (defun mu4e-hdrs-docid-is-marked (docid)
"Is the given docid marked?" "Is the given docid marked?"
@ -717,7 +715,7 @@ the new docid. Otherwise, return nil."
(interactive) (interactive)
(with-current-buffer mu4e-hdrs-buffer (with-current-buffer mu4e-hdrs-buffer
(when (= 0 (forward-line 1)) (when (= 0 (forward-line 1))
(or (mu4e-hdrs-get-docid) (mu4e-next-header)) ;; skip non-headers (or (mu4e--docid-at-point) (mu4e-next-header)) ;; skip non-headers
;; 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
(set-window-point (get-buffer-window mu4e-hdrs-buffer) (point))))) (set-window-point (get-buffer-window mu4e-hdrs-buffer) (point)))))
@ -728,7 +726,7 @@ return the new docid. Otherwise, return nil."
(interactive) (interactive)
(with-current-buffer mu4e-hdrs-buffer (with-current-buffer mu4e-hdrs-buffer
(when (= 0 (forward-line -1)) (when (= 0 (forward-line -1))
(or (mu4e-hdrs-get-docid) (mu4e-prev-header)) ;; skip non-headers (or (mu4e--docid-at-point) (mu4e-prev-header)) ;; skip non-headers
;; 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
(set-window-point (get-buffer-window mu4e-hdrs-buffer) (point))))) (set-window-point (get-buffer-window mu4e-hdrs-buffer) (point)))))
@ -749,7 +747,8 @@ up to `mu4e-search-results-limit'."
"Mark message at point for moving to maildir TARGET. If target is "Mark message at point for moving to maildir TARGET. If target is
not provided, function asks for it." not provided, function asks for it."
(interactive) (interactive)
(unless (mu4e-hdrs-get-docid) (with-current-buffer mu4e-hdrs-buffer
(unless (mu4e--docid-at-point)
(error "No message at point.")) (error "No message at point."))
(with-current-buffer mu4e-hdrs-buffer (with-current-buffer mu4e-hdrs-buffer
(let* ((target (or target (mu4e-ask-maildir "Move message to: "))) (let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
@ -758,11 +757,11 @@ not provided, function asks for it."
(concat "/" target))) (concat "/" target)))
(fulltarget (concat mu4e-maildir target))) (fulltarget (concat mu4e-maildir target)))
(when (or (file-directory-p fulltarget) (when (or (file-directory-p fulltarget)
(and (yes-or-no-p (and (yes-or-no-(point)
(format "%s does not exist. Create now?" fulltarget)) (format "%s does not exist. Create now?" fulltarget))
(mu4e-proc-mkdir fulltarget))) (mu4e-proc-mkdir fulltarget)))
(mu4e-hdrs-mark 'move target) (mu4e-hdrs-mark 'move target)
(mu4e-next-header))))) (mu4e-next-header))))))
(defun mu4e-mark (mark) (defun mu4e-mark (mark)
@ -836,7 +835,7 @@ for draft messages."
(if (eq compose-type 'new) (if (eq compose-type 'new)
(mu4e-send-compose-handler 'new) (mu4e-send-compose-handler 'new)
;; otherwise, we need the doc-id ;; otherwise, we need the doc-id
(let ((docid (mu4e-hdrs-get-docid))) (let ((docid (mu4e--docid-at-point)))
(unless docid (error "No message at point.")) (unless docid (error "No message at point."))
;; note, the first two chars of the line (the mark margin) does *not* ;; 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 ;; have the 'draft property; thus, we check one char before the end of