]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.el
Use 'forward-line' instead of 'next-line' while walking search display
[notmuch] / notmuch.el
index 07193066a511d38e7bedb500c31c35168d052b8e..8894a8e194716f444489b1676c3630c545c82c95 100644 (file)
   "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
 
+(defvar notmuch-show-signature-regexp "\\(-- ?\\|_+\\)$"
+  "Pattern to match a line that separates content from signature.
+
+The regexp can (and should) include $ to match the end of the
+line, but should not include ^ to match the beginning of the
+line. This is because notmuch may have inserted additional space
+for indentation at the beginning of the line. But notmuch will
+move past the indentation when testing this pattern, (so that the
+pattern can still test against the entire line).")
+
 (defvar notmuch-show-signature-lines-max 12
   "Maximum length of signature that will be hidden by default.")
 
@@ -443,7 +453,8 @@ which this thread was originally shown."
                           (concat indent
                                   "[" (number-to-string (count-lines beg-sub (point)))
                                   "-line citation. Press 'c' to show.]\n")))))
-      (if (looking-at "[[:space:]]*-- ?$")
+      (move-to-column depth)
+      (if (looking-at notmuch-show-signature-regexp)
          (let ((sig-lines (- (count-lines beg-sub end) 1)))
            (if (<= sig-lines notmuch-show-signature-lines-max)
                (progn
@@ -464,11 +475,15 @@ which this thread was originally shown."
        (let ((beg (point-marker)))
          (re-search-forward notmuch-show-part-end-regexp)
          (let ((end (copy-marker (match-beginning 0))))
+           (goto-char end)
+           (if (not (bolp))
+               (insert "\n"))
            (indent-rigidly beg end depth)
            (notmuch-show-markup-citations-region beg end depth)
            ; Advance to the next part (if any) (so the outer loop can
            ; determine whether we've left the current message.
-           (re-search-forward notmuch-show-part-begin-regexp nil t))))
+           (if (re-search-forward notmuch-show-part-begin-regexp nil t)
+               (beginning-of-line)))))
     (goto-char end)))
 
 (defun notmuch-show-markup-parts-region (beg end depth)
@@ -658,6 +673,9 @@ thread from that buffer can be show when done with this one)."
                  (notmuch-show-toggle-body-read-visible)))))
       )))
 
+(defvar notmuch-search-authors-width 40
+  "Number of columns to use to diplay authors in a notmuch-search buffer.")
+
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "a" 'notmuch-search-archive-thread)
@@ -756,14 +774,24 @@ global search.
     (if (re-search-forward "thread:[a-fA-F0-9]*" nil t)
        (progn
          (forward-char)
-         (overlay-put (make-overlay beg (point)) 'invisible 'notmuch-search)))))
+         (overlay-put (make-overlay beg (point)) 'invisible 'notmuch-search)
+         (re-search-forward ".*\\[[0-9]*/[0-9]*\\] \\([^;]*\\)\\(;\\)")
+         (let* ((authors (buffer-substring (match-beginning 1) (match-end 1)))
+                (authors-length (length authors)))
+           ;; Drop the semi-colon
+           (replace-match "" t nil nil 2)
+           (if (<= authors-length notmuch-search-authors-width)
+               (replace-match (concat authors (make-string
+                                               (- notmuch-search-authors-width
+                                                  authors-length) ? )) t t nil 1)
+             (replace-match (concat (substring authors 0 (- notmuch-search-authors-width 3)) "...") t t nil 1)))))))
 
 (defun notmuch-search-markup-thread-ids ()
   (save-excursion
     (goto-char (point-min))
     (while (not (eobp))
       (notmuch-search-markup-this-thread-id)
-      (next-line))))
+      (forward-line))))
 
 (defun notmuch-search-show-thread ()
   (interactive)