diff --git a/TODO b/TODO index 0d32796c..e5f468fe 100644 --- a/TODO +++ b/TODO @@ -18,14 +18,13 @@ - contact completion (see Jacek's 'mu4e: using' mail) - actions for /all/ headers, actions for /all/ attachment - custom header fields in headers-view, message-view - - custom predicate functions for marking - guile integration - check if we can speed up mu4e-proc parsing by using search rather than regexp search - show maildirs as a tree, not a list in speed bar - - make killing all windows (i.e.. 'fullscreen mode' optional) - better naming for draft buffers - review emacs menus + - *BUG* header updating screws up marks ** Done @@ -53,6 +52,8 @@ - make guile/gtk/webkit dependency optional - improve fringe marks (see https://github.com/djcb/mu/issues/21) - mark message, decide what to do with them later (i.e.. 'deferred marking') + - custom predicate functions for marking + - make mu4e buffer killing less aggressive (i.e.., DWIM) # Local Variables: diff --git a/emacs/mu4e-headers.el b/emacs/mu4e-headers.el index 20417c56..5872cb83 100644 --- a/emacs/mu4e-headers.el +++ b/emacs/mu4e-headers.el @@ -1025,16 +1025,7 @@ current window. " (insert (propertize "Waiting for message..." 'face 'mu4e-system-face 'intangible t)) (mu4e~proc-view docid mu4e-view-show-images)))) - -(defun mu4e~headers-quit-buffer () - "Quit the headers view and return to the main view." - (interactive) - (unless (eq major-mode 'mu4e-headers-mode) - (error "Must be in mu4e-headers-mode (%S)" major-mode)) - (mu4e-mark-handle-when-leaving) - (mu4e-quit-buffer) - (mu4e~main-view)) - + (defun mu4e-headers-rerun-search () "Rerun the search for the last search expression." (interactive) @@ -1162,5 +1153,33 @@ region if there is a region, then move to the next message." (mu4e-mark-for-move-set) (mu4e-headers-next)) +(defun mu4e~headers-quit-buffer () + "Quit the mu4e-headers buffer. This is a rather complex function; to +ensure we don't disturb other windows." + (interactive) + (unless (eq major-mode 'mu4e-headers-mode) + (error "Must be in mu4e-headers-mode (%S)" major-mode)) + (mu4e-mark-handle-when-leaving) + (let ((curbuf (current-buffer)) (curwin (selected-window)) + (headers-visible)) + (walk-windows + (lambda (win) + ;; if we find a view window connect to this one, kill it + (when (eq mu4e~headers-view-win win) + (delete-window win) + (setq mu4e~headers-view-win nil)) + ;; and kill any _other_ (non-selected) window that shows the current + ;; buffer + (when + (and + (eq curbuf (window-buffer win)) ;; does win show curbuf? + (not (eq curwin win)) ;; but it's not the curwin? + (not (one-window-p))) ;; and not the last one on the frame? + (delete-window win)))) ;; delete it! + ;; now, all *other* windows should be gone. kill ourselves, and return + ;; to the main view + (kill-buffer) + (mu4e~main-view))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (provide 'mu4e-headers) diff --git a/emacs/mu4e-view.el b/emacs/mu4e-view.el index e5246416..30e0832c 100644 --- a/emacs/mu4e-view.el +++ b/emacs/mu4e-view.el @@ -350,11 +350,11 @@ is nil, and otherwise open it." (setq mu4e-view-mode-map (let ((map (make-sparse-keymap))) - (define-key map "q" 'mu4e-quit-buffer) + (define-key map "q" 'mu4e~view-quit-buffer) ;; note, 'z' is by-default bound to 'bury-buffer' ;; but that's not very useful in this case - (define-key map "z" 'mu4e-quit-buffer) + (define-key map "z" 'mu4e~view-quit-buffer) (define-key map "s" 'mu4e-headers-search) (define-key map "S" 'mu4e-view-search-edit) @@ -454,7 +454,7 @@ is nil, and otherwise open it." (define-key map [menu-bar headers] (cons "View" menumap)) (define-key menumap [quit-buffer] - '("Quit view" . mu4e-quit-buffer)) + '("Quit view" . mu4e~view-quit-buffer)) (define-key menumap [display-help] '("Help" . mu4e-display-manual)) (define-key menumap [sepa0] '("--")) @@ -1026,4 +1026,37 @@ the results." (let ((path (mu4e-field-at-point :path))) (mu4e-process-file-through-pipe path cmd))) +(defun mu4e~view-quit-buffer () + "Quit the mu4e-view buffer. This is a rather complex function; to +ensure we don't disturb other windows." + (interactive) + (unless (eq major-mode 'mu4e-view-mode) + (error "Must be in mu4e-view-mode (%S)" major-mode)) + (let ((curbuf (current-buffer)) (curwin (selected-window)) + (headers-visible)) + (walk-windows + (lambda (win) + ;; check whether the headers buffer window is visible + (when (eq mu4e~view-headers-buffer (window-buffer win)) + (setq headers-visible t)) + ;; and kill any _other_ (non-selected) window that shows the current + ;; buffer + (when + (and + (eq curbuf (window-buffer win)) ;; does win show curbuf? + (not (eq curwin win)) ;; but it's not the curwin? + (not (one-window-p))) ;; and not the last one on the frame? + (delete-window win)))) ;; delete it! + ;; now, all *other* windows should be gone. + ;; if the headers view is also visible, kill ourselves + window; otherwise + ;; switch to the headers view + (if headers-visible + (kill-buffer-and-window) + ;; headers are not visible... + (kill-buffer) + (when (buffer-live-p mu4e~view-headers-buffer) + (switch-to-buffer mu4e~view-headers-buffer))))) + + (provide 'mu4e-view) +;; end of mu4e-view