* mu4e: fix + simplify mu4e-headers-split-view-resize

This commit is contained in:
djcb 2012-10-01 21:17:05 +03:00
parent 72e043a010
commit c482f744b2
2 changed files with 30 additions and 27 deletions

View File

@ -1213,25 +1213,19 @@ maildir)."
N; in vertical split-view, increase the number of columns shown by
N. Otherwise, don't do anything."
(interactive "P")
(when (buffer-live-p mu4e~view-buffer)
(case mu4e-split-view
(horizontal
(let ((newval (+ (or n 1) mu4e-headers-visible-lines)))
(unless (> newval 0)
(mu4e-warn
"Cannot make the number of visible lines any smaller"))
(setq mu4e-headers-visible-lines newval)))
(vertical
(let ((newval (+ (or n 1) mu4e-headers-visible-columns)))
(unless (> newval 0)
(mu4e-warn
"Cannot make the number of visible columns any smaller"))
(setq mu4e-headers-visible-columns newval))))
(let ((viewwin (mu4e~headers-redraw-get-view-window)))
(when (window-live-p viewwin)
(select-window viewwin)
(switch-to-buffer mu4e~view-buffer)))))
(let ((n (or n 1))
(hwin (get-buffer-window mu4e~headers-buffer)))
(when (and (buffer-live-p mu4e~view-buffer) (window-live-p hwin))
(let ((n (or n 1)))
(case mu4e-split-view
;; emacs has weird ideas about what horizontal, vertical means...
(horizontal
(window-resize hwin n nil)
(incf mu4e-headers-visible-lines n))
(vertical
(window-resize hwin n t)
(incf mu4e-headers-visible-columns n)))))))
(defun mu4e-headers-action ()
"Ask user what to do with message-at-point, then do it. The
actions are specified in `mu4e-headers-actions'."

View File

@ -501,12 +501,12 @@ at POINT, or if nil, at (point)."
(define-key map "a" 'mu4e-view-action)
;; change the number of headers
(define-key map (kbd "C-+") 'mu4e-headers-split-view-resize)
(define-key map (kbd "C-+") 'mu4e~view-split-view-resize)
(define-key map (kbd "C--")
(lambda () (interactive) (mu4e-headers-split-view-resize -1)))
(define-key map (kbd "<C-kp-add>") 'mu4e-headers-split-view-resize)
(lambda () (interactive) (mu4e~view-split-view-resize -1)))
(define-key map (kbd "<C-kp-add>") 'mu4e~view-split-view-resize)
(define-key map (kbd "<C-kp-subtract>")
(lambda () (interactive) (mu4e-headers-split-view-resize -1)))
(lambda () (interactive) (mu4e~view-split-view-resize -1)))
;; intra-message navigation
(define-key map (kbd "SPC") 'scroll-up)
@ -1044,20 +1044,29 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )."
(setq buffer-read-only t))
(t (mu4e-error "Unsupported action %S" what))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-view-mark-custom ()
(defun mu4e-view-mark-custom ()
"Run some custom mark function."
(mu4e~view-in-headers-context
(mu4e-headers-mark-custom)))
(defun mu4e~split-view-p ()
(defun mu4e~view-split-view-p ()
"Return t if we're in split-view, nil otherwise."
(member mu4e-split-view '(horizontal vertical)))
(defun mu4e~view-split-view-resize (n)
"In horizontal split-view, increase the number of lines shown by
N; in vertical split-view, increase the number of columns shown by
N. Otherwise, don't do anything."
(interactive "P")
(mu4e~view-in-headers-context
(mu4e-headers-split-view-resize n)))
(defun mu4e-view-unmark-all ()
"If we're in split-view, unmark all messages. Otherwise, warn
user that unmarking only works in the header list."
(interactive)
(if (mu4e~split-view-p)
(if (mu4e~view-split-view-p)
(mu4e~view-in-headers-context (mu4e-mark-unmark-all))
(mu4e-message "Unmarking needs to be done in the header list view")))
@ -1065,7 +1074,7 @@ user that unmarking only works in the header list."
"If we're in split-view, unmark message at point. Otherwise, warn
user that unmarking only works in the header list."
(interactive)
(if (mu4e~split-view-p)
(if (mu4e~view-split-view-p)
(mu4e-view-mark-for-unmark)
(mu4e-message "Unmarking needs to be done in the header list view")))