* mu4e-headers: make refreshing default when changing sort etc.; also turn off

threading when sorting for anything but date
This commit is contained in:
djcb
2012-06-15 11:46:11 +03:00
parent 6c854e4a25
commit 79f17ab4ad
2 changed files with 34 additions and 27 deletions

View File

@ -147,7 +147,7 @@ PREDICATE-FUNC as PARAM. This is useful for getting user-input.")
("to" . to)) ("to" . to))
"List of cells describing the various sort-options (in the format "List of cells describing the various sort-options (in the format
needed for `mu4e-read-option'.") needed for `mu4e-read-option'.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e~headers-clear () (defun mu4e~headers-clear ()
@ -332,7 +332,7 @@ after the end of the search results."
;; highlight the first message ;; highlight the first message
(mu4e~headers-highlight (mu4e~headers-docid-at-point (point-min))))))))) (mu4e~headers-highlight (mu4e~headers-docid-at-point (point-min)))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro mu4e~headers-defun-mark-func (mark) (defmacro mu4e~headers-defun-mark-func (mark)
"Define a function mu4e~headers-mark-MARK." "Define a function mu4e~headers-mark-MARK."
@ -341,7 +341,7 @@ after the end of the search results."
`(defun ,funcname () ,docstring `(defun ,funcname () ,docstring
(interactive) (interactive)
(mu4e-headers-mark-and-next (quote ,mark))))) (mu4e-headers-mark-and-next (quote ,mark)))))
;; define our mark functions; there must be some way to do this in a loop but ;; define our mark functions; there must be some way to do this in a loop but
;; since `mu4e~headers-defun-mark-func' is a macro, the argument must be a ;; since `mu4e~headers-defun-mark-func' is a macro, the argument must be a
;; literal value. ;; literal value.
@ -359,7 +359,7 @@ after the end of the search results."
(defvar mu4e-headers-mode-map nil (defvar mu4e-headers-mode-map nil
"Keymap for *mu4e-headers* buffers.") "Keymap for *mu4e-headers* buffers.")
(unless mu4e-headers-mode-map (unless mu4e-headers-mode-map
(setq mu4e-headers-mode-map (setq mu4e-headers-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -423,11 +423,11 @@ after the end of the search results."
(define-key map (kbd "-") 'mu4e~headers-mark-unflag) (define-key map (kbd "-") 'mu4e~headers-mark-unflag)
(define-key map (kbd "&") 'mu4e-headers-mark-custom) (define-key map (kbd "&") 'mu4e-headers-mark-custom)
(define-key map "m" 'mu4e-headers-mark-for-move-and-next) (define-key map "m" 'mu4e-headers-mark-for-move-and-next)
(define-key map (kbd "*") 'mu4e~headers-mark-deferred) (define-key map (kbd "*") 'mu4e~headers-mark-deferred)
(define-key map (kbd "<kp-multiply>") 'mu4e~headers-mark-deferred) (define-key map (kbd "<kp-multiply>") 'mu4e~headers-mark-deferred)
(define-key map (kbd "#") 'mu4e-mark-resolve-deferred-marks) (define-key map (kbd "#") 'mu4e-mark-resolve-deferred-marks)
(define-key map "U" 'mu4e-mark-unmark-all) (define-key map "U" 'mu4e-mark-unmark-all)
(define-key map "x" 'mu4e-mark-execute-all) (define-key map "x" 'mu4e-mark-execute-all)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -719,7 +719,7 @@ the query history stack."
mu4e-headers-show-threads mu4e-headers-show-threads
mu4e-headers-sortfield mu4e-headers-sortfield
mu4e-headers-sort-revert mu4e-headers-sort-revert
(unless mu4e-headers-full-search mu4e-search-results-limit)))) (unless mu4e-headers-full-search mu4e-search-results-limit))))
(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
@ -765,7 +765,7 @@ parameter). MARKPAIR is a cell (MARK . TARGET)."
(mu4e-headers-for-each (mu4e-headers-for-each
(lambda (msg) (lambda (msg)
(when (funcall mark-pred msg param) (when (funcall mark-pred msg param)
(mu4e-mark-at-point (car markpair) (cdr markpair)))))) (mu4e-mark-at-point (car markpair) (cdr markpair))))))
(defun mu4e-headers-mark-pattern () (defun mu4e-headers-mark-pattern ()
"Ask user for a kind of mark (move, delete etc.), a field to "Ask user for a kind of mark (move, delete etc.), a field to
@ -799,7 +799,7 @@ matching messages with that mark."
mu4e-headers-custom-markers)) mu4e-headers-custom-markers))
(param (when (cdr pred) (eval (cdr pred)))) (param (when (cdr pred) (eval (cdr pred))))
(markpair (mu4e~mark-get-markpair "Mark matched messages with: " t))) (markpair (mu4e~mark-get-markpair "Mark matched messages with: " t)))
(mu4e~headers-mark-for-each-if markpair (car pred) param))) (mu4e~headers-mark-for-each-if markpair (car pred) param)))
(defun mu4e~headers-get-thread-info (msg what) (defun mu4e~headers-get-thread-info (msg what)
"Get WHAT (a symbol, either path or thread-id) for MSG." "Get WHAT (a symbol, either path or thread-id) for MSG."
@ -962,9 +962,9 @@ the last search expression."
(format "(%s) AND %s" mu4e~headers-last-query filter))) (format "(%s) AND %s" mu4e~headers-last-query filter)))
(defun mu4e-headers-change-sorting (&optional rerun) (defun mu4e-headers-change-sorting (&optional dont-refresh)
"Interactively change the sorting/threading parameters. With prefix-argument, "Interactively change the sorting/threading parameters. With prefix-argument,
rerun the last search with the new parameters." do _not_ refresh the last search with the new parameters."
(interactive "P") (interactive "P")
(let* ((sortfield (let* ((sortfield
(mu4e-read-option "Sortfield: " mu4e~headers-sortfield-choices)) (mu4e-read-option "Sortfield: " mu4e~headers-sortfield-choices))
@ -974,34 +974,41 @@ rerun the last search with the new parameters."
(setq (setq
mu4e-headers-sortfield sortfield mu4e-headers-sortfield sortfield
mu4e-headers-sort-revert revert) ;; "descending" means "revert" mu4e-headers-sort-revert revert) ;; "descending" means "revert"
;; turn off threading if we don't sort by date (FIXME)
(unless (eq sortfield 'date)
(setq mu4e-headers-show-threads nil))
(mu4e-message "Sorting by %s (%s)%s" (mu4e-message "Sorting by %s (%s)%s"
(symbol-name sortfield) (symbol-name sortfield)
(if revert "descending" "ascending") (if revert "descending" "ascending")
(if rerun (if dont-refresh
"" " (press 'g' to refresh)")) " (press 'g' to refresh)" ""))
(when rerun (unless dont-refresh
(mu4e-headers-rerun-search)))) (mu4e-headers-rerun-search))))
(defun mu4e-headers-toggle-threading (&optional rerun) (defun mu4e-headers-toggle-threading (&optional dont-refresh)
"Toggle threading on/off for the search results. With prefix-argument, "Toggle threading on/off for the search results. With prefix-argument,
rerun the last search with the new setting for threading." do _not_ refresh the last search with the new setting for
threading."
(interactive "P") (interactive "P")
(setq mu4e-headers-show-threads (not mu4e-headers-show-threads)) (setq mu4e-headers-show-threads (not mu4e-headers-show-threads))
(mu4e-message "Threading turned %s%s" (mu4e-message "Threading turned %s%s"
(if mu4e-headers-show-threads "on" "off") (if mu4e-headers-show-threads "on" "off")
(if rerun "" " (press 'g' to refresh)")) (if dont-refresh
(when rerun " (press 'g' to refresh)" ""))
(unless dont-refresh
(mu4e-headers-rerun-search))) (mu4e-headers-rerun-search)))
(defun mu4e-headers-toggle-full-search (&optional rerun) (defun mu4e-headers-toggle-full-search (&optional dont-refresh)
"Toggle full-search on/off for the search results. With prefix-argument, "Toggle full-search on/off for the search results. With prefix-argument,
rerun the last search with the new setting for threading." do _not_ refresh the last search with the new setting for
threading."
(interactive "P") (interactive "P")
(setq mu4e-headers-full-search (not mu4e-headers-full-search)) (setq mu4e-headers-full-search (not mu4e-headers-full-search))
(mu4e-message "Full search turned %s%s" (mu4e-message "Full search turned %s%s"
(if mu4e-headers-full-search "on" "off") (if mu4e-headers-full-search "on" "off")
(if rerun "" " (press 'g' to refresh)")) (if dont-refresh
(when rerun " (press 'g' to refresh)" ""))
(unless dont-refresh
(mu4e-headers-rerun-search))) (mu4e-headers-rerun-search)))
@ -1025,7 +1032,7 @@ current window. "
(insert (propertize "Waiting for message..." (insert (propertize "Waiting for message..."
'face 'mu4e-system-face 'intangible t)) 'face 'mu4e-system-face 'intangible t))
(mu4e~proc-view docid mu4e-view-show-images)))) (mu4e~proc-view docid mu4e-view-show-images))))
(defun mu4e-headers-rerun-search () (defun mu4e-headers-rerun-search ()
"Rerun the search for the last search expression." "Rerun the search for the last search expression."
(interactive) (interactive)
@ -1174,12 +1181,12 @@ ensure we don't disturb other windows."
(and (and
(eq curbuf (window-buffer win)) ;; does win show curbuf? (eq curbuf (window-buffer win)) ;; does win show curbuf?
(not (eq curwin win)) ;; but it's not the curwin? (not (eq curwin win)) ;; but it's not the curwin?
(not (one-window-p))) ;; and not the last one on the frame? (not (one-window-p))) ;; and not the last one on the frame?
(delete-window win)))) ;; delete it! (delete-window win)))) ;; delete it!
;; now, all *other* windows should be gone. kill ourselves, and return ;; now, all *other* windows should be gone. kill ourselves, and return
;; to the main view ;; to the main view
(kill-buffer) (kill-buffer)
(mu4e~main-view))) (mu4e~main-view)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'mu4e-headers) (provide 'mu4e-headers)

View File

@ -617,8 +617,8 @@ affects the sort order.
You can change the sort order with @t{M-x mu4e-headers-change-sorting} or You can change the sort order with @t{M-x mu4e-headers-change-sorting} or
@key{O}, and you can toggle threading on/off using @t{M-x @key{O}, and you can toggle threading on/off using @t{M-x
mu4e-headers-toggle-threading} or @key{P}. For both of these functions, if you mu4e-headers-toggle-threading} or @key{P}. For both of these functions, unless
provide a prefix argument (@key{C-u}), the current search is updated you provide a prefix argument (@key{C-u}), the current search is updated
immediately using the new parameters. You can toggle full-search immediately using the new parameters. You can toggle full-search
(@ref{Searching}) using @t{M-x mu4e-headers-toggle-full-search} or @key{Q}. (@ref{Searching}) using @t{M-x mu4e-headers-toggle-full-search} or @key{Q}.