Merge pull request #93 from tarsius/undefun

* add various commands to replace anonymous lambas in keymaps
This commit is contained in:
Dirk-Jan C. Binnema
2012-12-23 04:01:13 -08:00
2 changed files with 33 additions and 20 deletions

View File

@ -501,11 +501,9 @@ after the end of the search results."
;; change the number of headers ;; change the number of headers
(define-key map (kbd "C-+") 'mu4e-headers-split-view-resize) (define-key map (kbd "C-+") 'mu4e-headers-split-view-resize)
(define-key map (kbd "C--") (define-key map (kbd "C--") 'mu4e-headers-split-view-shrink)
(lambda () (interactive) (mu4e-headers-split-view-resize -1)))
(define-key map (kbd "<C-kp-add>") 'mu4e-headers-split-view-resize) (define-key map (kbd "<C-kp-add>") 'mu4e-headers-split-view-resize)
(define-key map (kbd "<C-kp-subtract>") (define-key map (kbd "<C-kp-subtract>") 'mu4e-headers-split-view-shrink)
(lambda () (interactive) (mu4e-headers-split-view-resize -1)))
;; switching to view mode (if it's visible) ;; switching to view mode (if it's visible)
@ -1304,9 +1302,11 @@ maildir)."
(mu4e-headers-search (concat "\"maildir:" maildir "\"")))) (mu4e-headers-search (concat "\"maildir:" maildir "\""))))
(defun mu4e-headers-split-view-resize (n) (defun mu4e-headers-split-view-resize (n)
"In horizontal split-view, increase the number of lines shown by "In split-view grow the headers window.
N; in vertical split-view, increase the number of columns shown by In horizontal split-view, increase the number of lines shown by N.
N. Otherwise, don't do anything." In vertical split-view, increase the number of columns shown by N.
If N is negative shrink the headers window.
When not in split-view do nothing."
(interactive "P") (interactive "P")
(let ((n (or n 1)) (let ((n (or n 1))
(hwin (get-buffer-window mu4e~headers-buffer))) (hwin (get-buffer-window mu4e~headers-buffer)))
@ -1321,6 +1321,15 @@ N. Otherwise, don't do anything."
(window-resize hwin n t) (window-resize hwin n t)
(incf mu4e-headers-visible-columns n))))))) (incf mu4e-headers-visible-columns n)))))))
(defun mu4e-headers-split-view-shrink (n)
"In split-view shrink the headers window.
In horizontal split-view, decrease the number of lines shown by N.
In vertical split-view, decrease the number of columns shown by N.
If N is negative grow the headers window.
When not in split-view do nothing."
(interactive "P")
(mu4e-headers-split-view-resize (- n)))
(defun mu4e-headers-action () (defun mu4e-headers-action ()
"Ask user what to do with message-at-point, then do it. "Ask user what to do with message-at-point, then do it.
The actions are specified in `mu4e-headers-actions'." The actions are specified in `mu4e-headers-actions'."

View File

@ -499,22 +499,16 @@ FUNC should be a function taking two arguments:
;; change the number of headers ;; change the number of headers
(define-key map (kbd "C-+") 'mu4e-headers-split-view-resize) (define-key map (kbd "C-+") 'mu4e-headers-split-view-resize)
(define-key map (kbd "C--") (define-key map (kbd "C--") 'mu4e-headers-split-view-shrink)
(lambda () (interactive) (mu4e-headers-split-view-resize -1))) (define-key map (kbd "<C-kp-add>") 'mu4e-headers-split-view-resize)
(define-key map (kbd "<C-kp-add>") 'mu4e-headers-split-view-resize) (define-key map (kbd "<C-kp-subtract>") 'mu4e-headers-split-view-shrink)
(define-key map (kbd "<C-kp-subtract>")
(lambda () (interactive) (mu4e-headers-split-view-resize -1)))
;; intra-message navigation ;; intra-message navigation
(define-key map (kbd "SPC") 'mu4e-view-scroll-up-or-next) (define-key map (kbd "SPC") 'mu4e-view-scroll-up-or-next)
(define-key map (kbd "<home>") (define-key map (kbd "<home>") 'beginning-of-buffer)
#'(lambda () (interactive) (goto-char (point-min)))) (define-key map (kbd "<end>") 'end-of-buffer)
(define-key map (kbd "<end>") (define-key map (kbd "RET") 'mu4e-scroll-up)
#'(lambda () (interactive) (goto-char (point-max)))) (define-key map (kbd "<backspace>") 'mu4e-scroll-up)
(define-key map (kbd "RET")
#'(lambda () (interactive) (scroll-up 1)))
(define-key map (kbd "<backspace>")
#'(lambda () (interactive) (scroll-up -1)))
;; navigation between messages ;; navigation between messages
(define-key map "p" 'mu4e-view-headers-prev) (define-key map "p" 'mu4e-view-headers-prev)
@ -1071,6 +1065,16 @@ anymore, go the next message."
(when mu4e-view-scroll-to-next (when mu4e-view-scroll-to-next
(mu4e-view-headers-next))))) (mu4e-view-headers-next)))))
(defun mu4e-scroll-up ()
"Scroll text of selected window up one line."
(interactive)
(scroll-up 1))
(defun mu4e-scroll-down ()
"Scroll text of selected window down one line."
(interactive)
(scroll-down 1))
(defun mu4e-view-unmark-all () (defun mu4e-view-unmark-all ()
"If we're in split-view, unmark all messages. "If we're in split-view, unmark all messages.
Otherwise, warn user that unmarking only works in the header Otherwise, warn user that unmarking only works in the header