X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.el;h=6c9004ecfa0307519d4acd16ea8c7c580ffba2d0;hp=d41e6daf5e5a1351a88966327986bd1e117d2271;hb=0d58d46f7af39ba85209a7026644d36998c88a45;hpb=24b2f7699f7492d589cff54f06c58693e7207d34 diff --git a/notmuch.el b/notmuch.el index d41e6daf..6c9004ec 100644 --- a/notmuch.el +++ b/notmuch.el @@ -95,13 +95,13 @@ move past the indentation when testing this pattern, (so that the pattern can still test against the entire line).") (defvar notmuch-show-signature-button-format - "[ %d-line hidden signature. Click/Enter to show ]" + "[ %d-line signature. Click/Enter to toggle visibility. ]" "String used to construct button text for hidden signatures Can use up to one integer format parameter, i.e. %d") (defvar notmuch-show-citation-button-format - "[ %d-line hidden citation. Click/Enter to show ]" + "[ %d more citation lines. Click/Enter to toggle visibility. ]" "String used to construct button text for hidden citations. Can use up to one integer format parameter, i.e. %d") @@ -109,8 +109,11 @@ Can use up to one integer format parameter, i.e. %d") (defvar notmuch-show-signature-lines-max 12 "Maximum length of signature that will be hidden by default.") -(defvar notmuch-show-citation-lines-min 4 - "Minimum length of citation that will be hidden.") +(defvar notmuch-show-citation-lines-prefix 4 + "Always show at least this many lines of a citation. + +If there is one more line, show that, otherwise collapse +remaining lines into a button.") (defvar notmuch-command "notmuch" "Command to run the notmuch binary.") @@ -619,7 +622,7 @@ which this thread was originally shown." (define-button-type 'notmuch-button-invisibility-toggle-type 'action 'notmuch-toggle-invisible-action 'follow-link t - 'face "default") + 'face 'font-lock-comment-face) (define-button-type 'notmuch-button-citation-toggle-type 'help-echo "mouse-1, RET: Show citation" :supertype 'notmuch-button-invisibility-toggle-type) (define-button-type 'notmuch-button-signature-toggle-type 'help-echo "mouse-1, RET: Show signature" @@ -683,13 +686,16 @@ is what to put on the button." (let* ((cite-start (match-beginning 0)) (cite-end (match-end 0)) (cite-lines (count-lines cite-start cite-end))) - (if (>= cite-lines notmuch-show-citation-lines-min) - (notmuch-show-region-to-button - cite-start cite-end - "citation" - indent - (format notmuch-show-citation-button-format cite-lines) - )))) + (when (> cite-lines (1+ notmuch-show-citation-lines-prefix)) + (goto-char cite-start) + (forward-line notmuch-show-citation-lines-prefix) + (notmuch-show-region-to-button + (point) cite-end + "citation" + indent + (format notmuch-show-citation-button-format + (- cite-lines notmuch-show-citation-lines-prefix)) + )))) (if (and (< (point) end) (re-search-forward signature-regexp end t)) (let* ((sig-start (match-beginning 0)) @@ -1440,12 +1446,15 @@ current search results AND that are tagged with the given tag." (define-key map "?" 'notmuch-help) (define-key map "x" 'kill-this-buffer) (define-key map "q" 'kill-this-buffer) + (define-key map "m" 'message-mail) + (define-key map "e" 'notmuch-folder-show-empty-toggle) (define-key map ">" 'notmuch-folder-last) (define-key map "<" 'notmuch-folder-first) (define-key map "=" 'notmuch-folder) (define-key map "s" 'notmuch-search) (define-key map [mouse-1] 'notmuch-folder-show-search) (define-key map (kbd "RET") 'notmuch-folder-show-search) + (define-key map " " 'notmuch-folder-show-search) (define-key map "p" 'notmuch-folder-previous) (define-key map "n" 'notmuch-folder-next) map) @@ -1515,22 +1524,40 @@ Currently available key bindings: (goto-char (point-max)) (forward-line -1)) +(defun notmuch-folder-count (search) + (car (process-lines notmuch-command "count" search))) + +(setq notmuch-folder-show-empty t) + +(defun notmuch-folder-show-empty-toggle () + "Toggle the listing of empty folders" + (interactive) + (setq notmuch-folder-show-empty (not notmuch-folder-show-empty)) + (notmuch-folder)) + (defun notmuch-folder-add (folders) (if folders - (let ((name (car (car folders))) + (let* ((name (car (car folders))) (inhibit-read-only t) - (search (cdr (car folders)))) - (insert name) - (indent-to 16 1) - (call-process notmuch-command nil t nil "count" search) + (search (cdr (car folders))) + (count (notmuch-folder-count search))) + (if (or notmuch-folder-show-empty + (not (equal count "0"))) + (progn + (insert name) + (indent-to 16 1) + (insert count) + (insert "\n") + ) + ) (notmuch-folder-add (cdr folders))))) (defun notmuch-folder-find-name () (save-excursion (beginning-of-line) (let ((beg (point))) - (forward-word) - (filter-buffer-substring beg (point))))) + (re-search-forward "\\([ \t]*[^ \t]+\\)") + (filter-buffer-substring (match-beginning 1) (match-end 1))))) (defun notmuch-folder-show-search (&optional folder) "Show a search window for the search related to the specified folder."