* fix next / unmark behavior in view, headers

This commit is contained in:
djcb 2012-05-20 19:59:57 +03:00
parent c1bfc0949a
commit ea101876e2
2 changed files with 26 additions and 25 deletions

View File

@ -97,6 +97,10 @@ are of the form:
"Each header starts (invisibly) with the `mu4e~headers-docid-pre', "Each header starts (invisibly) with the `mu4e~headers-docid-pre',
followed by the docid, followed by `mu4e~headers-docid-post'.") followed by the docid, followed by `mu4e~headers-docid-post'.")
(defvar mu4e~headers-view-win nil
"The view window connected to this headers view.")
(defun mu4e~headers-clear () (defun mu4e~headers-clear ()
"Clear the header buffer and related data structures." "Clear the header buffer and related data structures."
(when (buffer-live-p mu4e~headers-buffer) (when (buffer-live-p mu4e~headers-buffer)
@ -621,27 +625,25 @@ update the query history stack."
(replace-regexp-in-string "\"" "\\\\\"" expr) ;; escape "\" (replace-regexp-in-string "\"" "\\\\\"" expr) ;; escape "\"
(unless search-all mu4e-search-results-limit)) (unless search-all mu4e-search-results-limit))
;;; when we're starting a new search, we also kill the ;;; when we're starting a new search, we also kill the
;;; view buffer, if any ;;; view window, if any
(mu4e-view-kill-buffer-and-window))) (ignore-errors (delete-window mu4e~headers-view-win))))
(defun mu4e~headers-redraw-get-view-window () (defun mu4e~headers-redraw-get-view-window ()
"Close all windows, redraw the headers buffer based on the value "Close all windows, redraw the headers buffer based on the value
of `mu4e-split-view', and return a window for the message view." of `mu4e-split-view', and return a window for the message view."
(unless (buffer-live-p mu4e~headers-buffer) (unless (buffer-live-p mu4e~headers-buffer)
(error "No headers buffer available")) (error "No headers buffer available"))
(walk-windows (ignore-errors (delete-window mu4e~headers-view-win))
(lambda (win)
(when (> (count-windows) 2)
(delete-window win))) nil nil)
(switch-to-buffer mu4e~headers-buffer) (switch-to-buffer mu4e~headers-buffer)
(cond (setq mu4e~headers-view-win
((eq mu4e-split-view 'horizontal) ;; split horizontally (cond
(split-window-vertically mu4e-headers-visible-lines)) ((eq mu4e-split-view 'horizontal) ;; split horizontally
((eq mu4e-split-view 'vertical) ;; split vertically (split-window-vertically mu4e-headers-visible-lines))
(split-window-horizontally mu4e-headers-visible-columns)) ((eq mu4e-split-view 'vertical) ;; split vertically
(t ;; no splitting; just use the currently selected one (split-window-horizontally mu4e-headers-visible-columns))
(selected-window)))) (t ;; no splitting; just use the currently selected one
(selected-window))))
mu4e~headers-view-win)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; search-based marking ;; search-based marking
@ -838,6 +840,7 @@ IGNORE-HISTORY is true, do *not* update the query history stack."
(or search-all current-prefix-arg) (or search-all current-prefix-arg)
ignore-history))) ignore-history)))
(defun mu4e-headers-search-edit (search-all) (defun mu4e-headers-search-edit (search-all)
"Edit the last search expression. If SEARCH-ALL (prefix-argument) "Edit the last search expression. If SEARCH-ALL (prefix-argument)
is non-nil, retrieve *all* results, otherwise only get up to is non-nil, retrieve *all* results, otherwise only get up to
@ -902,7 +905,7 @@ current window. "
(mu4e~proc-view docid mu4e-view-show-images)))) (mu4e~proc-view docid mu4e-view-show-images))))
(defun mu4e~headers-kill-buffer-and-window () (defun mu4e~headers-kill-buffer-and-window ()
"Quit the message view and return to the main view." "Quit the headers view and return to the main view."
(interactive) (interactive)
(mu4e-mark-handle-when-leaving) (mu4e-mark-handle-when-leaving)
(let ((buf mu4e~headers-buffer)) (let ((buf mu4e~headers-buffer))
@ -956,18 +959,16 @@ docid. Otherwise, return nil."
(error "Must be in mu4e-headers-mode (%S)" major-mode)) (error "Must be in mu4e-headers-mode (%S)" major-mode))
(let ((succeeded (= 0 (forward-line lines))) (let ((succeeded (= 0 (forward-line lines)))
(docid (mu4e~headers-docid-at-point))) (docid (mu4e~headers-docid-at-point)))
;; trick to move point, even if this function is called when this window ;; move point, even if this function is called when this window is not
;; is not visible ;; visible
(when docid (when docid
(set-window-point (get-buffer-window mu4e~headers-buffer) (point)) (set-window-point (get-buffer-window mu4e~headers-buffer) (point))
;; attempt to highlight the new line, display the message ;; attempt to highlight the new line, display the message
(mu4e~headers-highlight docid) (mu4e~headers-highlight docid)
;; if there already is a visible message view, show the message (when (window-live-p mu4e~headers-view-win)
(when (and (buffer-live-p mu4e~view-buffer) (select-window (mu4e~headers-redraw-get-view-window)
(window-live-p (get-buffer-window mu4e~view-buffer))) (mu4e-headers-view-message)))
(mu4e-headers-view-message))) docid)))
;; return the docid only if the move succeeded
(when succeeded docid)))
(defun mu4e-headers-next (&optional n) (defun mu4e-headers-next (&optional n)
"Move point to the next message header. If this succeeds, return "Move point to the next message header. If this succeeds, return

View File

@ -601,7 +601,7 @@ Seen; if the message is not New/Unread, do nothing."
(save-excursion (save-excursion
(goto-char (point-max)) (goto-char (point-max))
(mu4e-display-image imgfile mu4e-view-image-max-width))))))))) (mu4e-display-image imgfile mu4e-view-image-max-width)))))))))
;; this is fairly simplistic... ;; this is fairly simplistic...
(defun mu4e~view-make-urls-clickable () (defun mu4e~view-make-urls-clickable ()
"Turn things that look like URLs into clickable things, and "Turn things that look like URLs into clickable things, and
@ -913,7 +913,7 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )."
user that unmarking only works in the header list." user that unmarking only works in the header list."
(interactive) (interactive)
(if (mu4e~split-view-p) (if (mu4e~split-view-p)
(mu4e-mark-unmark-all) (mu4e~view-in-headers-context (mu4e-mark-unmark-all))
(mu4e-message "Unmarking needs to be done in the header list view"))) (mu4e-message "Unmarking needs to be done in the header list view")))
(defun mu4e-view-unmark () (defun mu4e-view-unmark ()