Allow a function as mu4e-split-view value
This allows to have a function returning a window as value of
`mu4e-split-view`. I'm using this patch since quite some time locally with the
following function.
```el
(defun th/mu4e-split-view ()
(let* ((headers (mu4e-get-headers-buffer))
(headers-win (and headers (get-buffer-window headers)))
(view (mu4e-get-view-buffer))
(view-win (and view (get-buffer-window view))))
(cond
;; There's a view window, just use it.
(view-win view-win)
;; Just one window, split sensibly, i.e., horizontally or
;; vertically depending on geometry.
((one-window-p) (split-window-sensibly))
;; Otherwise, use the tallest window.
(t (car (sort (delq headers-win (window-list))
(lambda (a b)
(> (window-height a) (window-height b)))))))))
(setq mu4e-split-view #'th/mu4e-split-view)
```
This commit is contained in:
@ -1269,16 +1269,16 @@ of `mu4e-split-view', and return a window for the message view."
|
|||||||
(kill-buffer (mu4e-get-view-buffer)))
|
(kill-buffer (mu4e-get-view-buffer)))
|
||||||
;; get a new view window
|
;; get a new view window
|
||||||
(setq mu4e~headers-view-win
|
(setq mu4e~headers-view-win
|
||||||
(let* ((new-win-func
|
(with-demoted-errors "Unable to split window: %S"
|
||||||
(cond
|
(cond
|
||||||
((eq mu4e-split-view 'horizontal) ;; split horizontally
|
((eq mu4e-split-view 'horizontal) ;; split horizontally
|
||||||
'(split-window-vertically mu4e-headers-visible-lines))
|
(split-window-vertically mu4e-headers-visible-lines))
|
||||||
((eq mu4e-split-view 'vertical) ;; split vertically
|
((eq mu4e-split-view 'vertical) ;; split vertically
|
||||||
'(split-window-horizontally mu4e-headers-visible-columns)))))
|
(split-window-horizontally mu4e-headers-visible-columns))
|
||||||
(cond ((with-demoted-errors "Unable to split window: %S"
|
((functionp mu4e-split-view)
|
||||||
(eval new-win-func)))
|
(funcall mu4e-split-view))
|
||||||
(t ;; no splitting; just use the currently selected one
|
(t ;; no splitting; just use the currently selected one
|
||||||
(selected-window)))))))
|
(selected-window)))))))
|
||||||
|
|
||||||
;;; Search-based marking
|
;;; Search-based marking
|
||||||
|
|
||||||
|
|||||||
@ -91,8 +91,10 @@ A symbol which is either:
|
|||||||
* `vertical': split vertically (headers on the left).
|
* `vertical': split vertically (headers on the left).
|
||||||
* `single-window': view and headers in one window (mu4e will try not to
|
* `single-window': view and headers in one window (mu4e will try not to
|
||||||
touch your window layout), main view in minibuffer
|
touch your window layout), main view in minibuffer
|
||||||
|
* a function: the function is responsible to return some window for
|
||||||
|
the view.
|
||||||
* anything else: don't split (show either headers or messages,
|
* anything else: don't split (show either headers or messages,
|
||||||
not both)
|
not both).
|
||||||
Also see `mu4e-headers-visible-lines'
|
Also see `mu4e-headers-visible-lines'
|
||||||
and `mu4e-headers-visible-columns'."
|
and `mu4e-headers-visible-columns'."
|
||||||
:type '(choice (const :tag "Split horizontally" horizontal)
|
:type '(choice (const :tag "Split horizontally" horizontal)
|
||||||
@ -515,4 +517,3 @@ Or go to the top level if there is none."
|
|||||||
|
|
||||||
(provide 'mu4e-helpers)
|
(provide 'mu4e-helpers)
|
||||||
;;; mu4e-helpers.el ends here
|
;;; mu4e-helpers.el ends here
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user