X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-hello.el;h=f95a86877595812453f6f3f960228132f2805e31;hb=a56010ac8b89a2489eee5c78469f05cee85ec858;hp=acf40bc4f11c7371cb6193ed76f2bb1205065e7b;hpb=251d57f56b2bf22771f2d8617151ef6b3d81d04f;p=notmuch diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index acf40bc4..f95a8687 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -139,11 +139,6 @@ So: maximize (length (car elem))) 0)) -(defun notmuch-hello-roundup (dividend divisor) - "Return the rounded up value of dividing `dividend' by `divisor'." - (+ (/ dividend divisor) - (if (> (% dividend divisor) 0) 1 0))) - (defun notmuch-hello-reflect-generate-row (ncols nrows row list) (let ((len (length list))) (loop for col from 0 to (- ncols 1) @@ -159,7 +154,7 @@ So: "Reflect a `ncols' wide matrix represented by `list' along the diagonal." ;; Not very lispy... - (let ((nrows (notmuch-hello-roundup (length list) ncols))) + (let ((nrows (ceiling (length list) ncols))) (loop for row from 0 to (- nrows 1) append (notmuch-hello-reflect-generate-row ncols nrows row list)))) @@ -264,6 +259,36 @@ should be. Returns a cons cell `(tags-per-line width)'." (notmuch-poll) (notmuch-hello-update)) + +(defvar notmuch-hello-mode-map + (let ((map (copy-keymap widget-keymap))) + (define-key map "v" '(lambda () "Display the notmuch version" (interactive) + (message "notmuch version %s" (notmuch-version)))) + (define-key map "?" 'notmuch-help) + (define-key map "q" 'kill-this-buffer) + (define-key map "=" 'notmuch-hello-update) + (define-key map "G" 'notmuch-hello-poll-and-update) + (define-key map (kbd "") 'widget-backward) + (define-key map "m" 'notmuch-mua-mail) + (define-key map "s" 'notmuch-hello-goto-search) + map) + "Keymap for \"notmuch hello\" buffers.") +(fset 'notmuch-hello-mode-map notmuch-hello-mode-map) + +(defun notmuch-hello-mode () + "Major mode for convenient notmuch navigation. This is your entry portal into notmuch. + +Complete list of currently available key bindings: + +\\{notmuch-hello-mode-map}" + (interactive) + (kill-all-local-variables) + (use-local-map notmuch-hello-mode-map) + (setq major-mode 'notmuch-hello-mode + mode-name "notmuch-hello") + ;;(setq buffer-read-only t) +) + (defun notmuch-hello (&optional no-display) (interactive) @@ -288,6 +313,9 @@ should be. Returns a cons cell `(tags-per-line width)'." (let ((inhibit-read-only t)) (erase-buffer)) + (unless (eq major-mode 'notmuch-hello-mode) + (notmuch-hello-mode)) + (let ((all (overlay-lists))) ;; Delete all the overlays. (mapc 'delete-overlay (car all)) @@ -446,15 +474,6 @@ should be. Returns a cons cell `(tags-per-line width)'." (let ((fill-column (- (window-width) notmuch-hello-indent))) (center-region start (point)))) - (use-local-map widget-keymap) - (local-set-key "=" 'notmuch-hello-update) - (local-set-key "G" 'notmuch-hello-poll-and-update) - (local-set-key "m" 'notmuch-mua-mail) - (local-set-key "q" '(lambda () (interactive) (kill-buffer (current-buffer)))) - (local-set-key "s" 'notmuch-hello-goto-search) - (local-set-key "v" '(lambda () (interactive) - (message "notmuch version %s" (notmuch-version)))) - (widget-setup) (when final-target-pos