mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
Hide bodies of message that have already been read.
Also hide all markers. From here, all we really need for legibility is the following: * Hide away citations and signatures * Call out the one-line summary some way, (larger font size?) * Add nesting for replies
This commit is contained in:
parent
f2a4c3e565
commit
9c6a010674
2 changed files with 110 additions and 40 deletions
38
notmuch.c
38
notmuch.c
|
@ -952,10 +952,11 @@ show_message_part (GMimeObject *part, int *part_count)
|
||||||
const char *filename = g_mime_part_get_filename (GMIME_PART (part));
|
const char *filename = g_mime_part_get_filename (GMIME_PART (part));
|
||||||
content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
|
content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
|
||||||
|
|
||||||
printf ("\fattachment{ ID: %d, Content-type: %s, ",
|
printf ("\fattachment{ ID: %d, Content-type: %s\n",
|
||||||
*part_count,
|
*part_count,
|
||||||
g_mime_content_type_to_string (content_type));
|
g_mime_content_type_to_string (content_type));
|
||||||
printf ("Filename: %s ", filename);
|
printf ("Attachment: %s (%s)\n", filename,
|
||||||
|
g_mime_content_type_to_string (content_type));
|
||||||
printf ("\fattachment}\n");
|
printf ("\fattachment}\n");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -977,6 +978,11 @@ show_message_part (GMimeObject *part, int *part_count)
|
||||||
if (wrapper)
|
if (wrapper)
|
||||||
g_mime_data_wrapper_write_to_stream (wrapper, stream);
|
g_mime_data_wrapper_write_to_stream (wrapper, stream);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("Non-text part: %s\n",
|
||||||
|
g_mime_content_type_to_string (content_type));
|
||||||
|
}
|
||||||
|
|
||||||
printf ("\fpart}\n");
|
printf ("\fpart}\n");
|
||||||
|
|
||||||
|
@ -1032,6 +1038,25 @@ show_message_body (const char *filename)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_message_is_unread (notmuch_message_t *message)
|
||||||
|
{
|
||||||
|
notmuch_tags_t *tags;
|
||||||
|
const char *tag;
|
||||||
|
|
||||||
|
for (tags = notmuch_message_get_tags (message);
|
||||||
|
notmuch_tags_has_more (tags);
|
||||||
|
notmuch_tags_advance (tags))
|
||||||
|
{
|
||||||
|
tag = notmuch_tags_get (tags);
|
||||||
|
|
||||||
|
if (strcmp (tag, "unread") == 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
show_command (void *ctx, unused (int argc), unused (char *argv[]))
|
show_command (void *ctx, unused (int argc), unused (char *argv[]))
|
||||||
{
|
{
|
||||||
|
@ -1042,6 +1067,7 @@ show_command (void *ctx, unused (int argc), unused (char *argv[]))
|
||||||
notmuch_messages_t *messages;
|
notmuch_messages_t *messages;
|
||||||
notmuch_message_t *message;
|
notmuch_message_t *message;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int unread;
|
||||||
|
|
||||||
const char *headers[] = {
|
const char *headers[] = {
|
||||||
"Subject", "From", "To", "Cc", "Bcc", "Date"
|
"Subject", "From", "To", "Cc", "Bcc", "Date"
|
||||||
|
@ -1080,8 +1106,11 @@ show_command (void *ctx, unused (int argc), unused (char *argv[]))
|
||||||
notmuch_messages_advance (messages))
|
notmuch_messages_advance (messages))
|
||||||
{
|
{
|
||||||
message = notmuch_messages_get (messages);
|
message = notmuch_messages_get (messages);
|
||||||
|
unread = _message_is_unread (message);
|
||||||
|
|
||||||
printf ("\fmessage{\n");
|
printf ("\fmessage{ ID: %s %s\n",
|
||||||
|
notmuch_message_get_message_id (message),
|
||||||
|
unread ? "unread" : "");
|
||||||
|
|
||||||
printf ("\fheader{\n");
|
printf ("\fheader{\n");
|
||||||
|
|
||||||
|
@ -1095,9 +1124,12 @@ show_command (void *ctx, unused (int argc), unused (char *argv[]))
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("\fheader}\n");
|
printf ("\fheader}\n");
|
||||||
|
printf ("\fbody{\n");
|
||||||
|
|
||||||
show_message_body (notmuch_message_get_filename (message));
|
show_message_body (notmuch_message_get_filename (message));
|
||||||
|
|
||||||
|
printf ("\fbody}\n");
|
||||||
|
|
||||||
printf ("\fmessage}\n");
|
printf ("\fmessage}\n");
|
||||||
|
|
||||||
notmuch_message_destroy (message);
|
notmuch_message_destroy (message);
|
||||||
|
|
112
notmuch.el
112
notmuch.el
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
(defvar notmuch-show-mode-map
|
(defvar notmuch-show-mode-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(define-key map "b" 'notmuch-show-toggle-body-read-visible)
|
||||||
(define-key map "h" 'notmuch-show-toggle-headers-visible)
|
(define-key map "h" 'notmuch-show-toggle-headers-visible)
|
||||||
(define-key map "n" 'notmuch-show-next-message)
|
(define-key map "n" 'notmuch-show-next-message)
|
||||||
(define-key map "p" 'notmuch-show-previous-message)
|
(define-key map "p" 'notmuch-show-previous-message)
|
||||||
|
@ -42,11 +43,17 @@
|
||||||
"Keymap for \"notmuch show\" buffers.")
|
"Keymap for \"notmuch show\" buffers.")
|
||||||
(fset 'notmuch-show-mode-map notmuch-show-mode-map)
|
(fset 'notmuch-show-mode-map notmuch-show-mode-map)
|
||||||
|
|
||||||
(defvar notmuch-show-message-begin-regexp "message{")
|
(defvar notmuch-show-message-begin-regexp "message{")
|
||||||
(defvar notmuch-show-message-end-regexp "message}")
|
(defvar notmuch-show-message-end-regexp "message}")
|
||||||
(defvar notmuch-show-header-begin-regexp "header{")
|
(defvar notmuch-show-header-begin-regexp "header{")
|
||||||
(defvar notmuch-show-header-end-regexp "header}")
|
(defvar notmuch-show-header-end-regexp "header}")
|
||||||
|
(defvar notmuch-show-body-begin-regexp "body{")
|
||||||
|
(defvar notmuch-show-body-end-regexp "body}")
|
||||||
|
(defvar notmuch-show-attachment-begin-regexp "attachment{")
|
||||||
|
(defvar notmuch-show-attachment-end-regexp "attachment}")
|
||||||
|
(defvar notmuch-show-part-begin-regexp "part{")
|
||||||
|
(defvar notmuch-show-part-end-regexp "part}")
|
||||||
|
(defvar notmuch-show-marker-regexp "\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$")
|
||||||
(defvar notmuch-show-headers-visible t)
|
(defvar notmuch-show-headers-visible t)
|
||||||
|
|
||||||
(defun notmuch-show-next-message ()
|
(defun notmuch-show-next-message ()
|
||||||
|
@ -55,8 +62,7 @@
|
||||||
; First, ensure we get off the current message marker
|
; First, ensure we get off the current message marker
|
||||||
(if (not (eobp))
|
(if (not (eobp))
|
||||||
(forward-char))
|
(forward-char))
|
||||||
(if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
|
(re-search-forward notmuch-show-message-begin-regexp nil t)
|
||||||
(goto-char (point-max)))
|
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(recenter 0))
|
(recenter 0))
|
||||||
|
|
||||||
|
@ -64,49 +70,79 @@
|
||||||
"Advance point to the beginning of the previous message in the buffer."
|
"Advance point to the beginning of the previous message in the buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
; First, ensure we get off the current message marker
|
; First, ensure we get off the current message marker
|
||||||
(if (not (eobp))
|
(if (not (bobp))
|
||||||
(forward-char))
|
(previous-line))
|
||||||
(if (not (re-search-backward notmuch-show-message-begin-regexp nil t))
|
(re-search-backward notmuch-show-message-begin-regexp nil t)
|
||||||
(goto-char (point-min)))
|
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(recenter 0))
|
(recenter 0))
|
||||||
|
|
||||||
(defun notmuch-show-markup-this-header ()
|
(defun notmuch-show-markup-body (unread)
|
||||||
(if (re-search-forward notmuch-show-header-begin-regexp nil t)
|
(re-search-forward notmuch-show-body-begin-regexp)
|
||||||
|
(next-line 1)
|
||||||
|
(beginning-of-line)
|
||||||
|
(let ((beg (point)))
|
||||||
|
(re-search-forward notmuch-show-body-end-regexp)
|
||||||
|
(if (not unread)
|
||||||
|
(overlay-put (make-overlay beg (match-beginning 0))
|
||||||
|
'invisible 'notmuch-show-body-read))
|
||||||
|
; (notmuch-show-markup-citations-region beg point)
|
||||||
|
))
|
||||||
|
|
||||||
|
(defun notmuch-show-markup-header ()
|
||||||
|
(re-search-forward notmuch-show-header-begin-regexp)
|
||||||
|
(next-line 2)
|
||||||
|
(beginning-of-line)
|
||||||
|
(let ((beg (point)))
|
||||||
|
(re-search-forward notmuch-show-header-end-regexp)
|
||||||
|
(overlay-put (make-overlay beg (match-beginning 0))
|
||||||
|
'invisible 'notmuch-show-header)))
|
||||||
|
|
||||||
|
(defun notmuch-show-markup-message ()
|
||||||
|
(if (re-search-forward notmuch-show-message-begin-regexp nil t)
|
||||||
(progn
|
(progn
|
||||||
(overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
|
(let ((unread (looking-at ".*unread$")))
|
||||||
'invisible 'notmuch-show-marker)
|
(notmuch-show-markup-header)
|
||||||
(next-line 1)
|
(notmuch-show-markup-body unread)))
|
||||||
(beginning-of-line)
|
|
||||||
(let ((beg (point)))
|
|
||||||
(if (re-search-forward notmuch-show-header-end-regexp nil t)
|
|
||||||
(progn
|
|
||||||
(overlay-put (make-overlay beg (match-beginning 0))
|
|
||||||
'invisible 'notmuch-show-header)
|
|
||||||
(overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
|
|
||||||
'invisible 'notmuch-show-marker)))))
|
|
||||||
(goto-char (point-max))))
|
(goto-char (point-max))))
|
||||||
|
|
||||||
(defun notmuch-show-markup-headers ()
|
(defun notmuch-show-hide-markers ()
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (not (eobp))
|
(while (not (eobp))
|
||||||
(notmuch-show-markup-this-header))))
|
(if (re-search-forward notmuch-show-marker-regexp nil t)
|
||||||
|
(progn
|
||||||
|
(overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
|
||||||
|
'invisible 'notmuch-show-marker))
|
||||||
|
(goto-char (point-max))))))
|
||||||
|
|
||||||
|
(defun notmuch-show-markup-messages ()
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (not (eobp))
|
||||||
|
(notmuch-show-markup-message)))
|
||||||
|
(notmuch-show-hide-markers))
|
||||||
|
|
||||||
(defun notmuch-show-toggle-headers-visible ()
|
(defun notmuch-show-toggle-headers-visible ()
|
||||||
"Toggle visibility of header fields"
|
"Toggle visibility of header fields"
|
||||||
(interactive)
|
(interactive)
|
||||||
(if notmuch-show-headers-visible
|
(if notmuch-show-headers-visible
|
||||||
(progn
|
(add-to-invisibility-spec 'notmuch-show-header)
|
||||||
(add-to-invisibility-spec 'notmuch-show-header)
|
(remove-from-invisibility-spec 'notmuch-show-header))
|
||||||
(set 'notmuch-show-headers-visible nil)
|
(set 'notmuch-show-headers-visible (not notmuch-show-headers-visible))
|
||||||
; Need to force the redisplay for some reason
|
; Need to force the redisplay for some reason
|
||||||
(force-window-update)
|
(force-window-update)
|
||||||
(redisplay t))
|
(redisplay t))
|
||||||
(remove-from-invisibility-spec 'notmuch-show-header)
|
|
||||||
(set 'notmuch-show-headers-visible t)
|
(defun notmuch-show-toggle-body-read-visible ()
|
||||||
(force-window-update)
|
"Toggle visibility of message bodies of read messages"
|
||||||
(redisplay t)))
|
(interactive)
|
||||||
|
(if notmuch-show-body-read-visible
|
||||||
|
(add-to-invisibility-spec 'notmuch-show-body-read)
|
||||||
|
(remove-from-invisibility-spec 'notmuch-show-body-read))
|
||||||
|
(set 'notmuch-show-body-read-visible (not notmuch-show-body-read-visible))
|
||||||
|
; Need to force the redisplay for some reason
|
||||||
|
(force-window-update)
|
||||||
|
(redisplay t))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun notmuch-show-mode ()
|
(defun notmuch-show-mode ()
|
||||||
|
@ -115,6 +151,8 @@
|
||||||
(kill-all-local-variables)
|
(kill-all-local-variables)
|
||||||
(set (make-local-variable 'notmuch-show-headers-visible) t)
|
(set (make-local-variable 'notmuch-show-headers-visible) t)
|
||||||
(notmuch-show-toggle-headers-visible)
|
(notmuch-show-toggle-headers-visible)
|
||||||
|
(set (make-local-variable 'notmuch-show-body-read-visible) t)
|
||||||
|
(notmuch-show-toggle-body-read-visible)
|
||||||
(add-to-invisibility-spec 'notmuch-show-marker)
|
(add-to-invisibility-spec 'notmuch-show-marker)
|
||||||
(use-local-map notmuch-show-mode-map)
|
(use-local-map notmuch-show-mode-map)
|
||||||
(setq major-mode 'notmuch-show-mode
|
(setq major-mode 'notmuch-show-mode
|
||||||
|
@ -136,7 +174,7 @@
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(call-process "notmuch" nil t nil "show" thread-id)
|
(call-process "notmuch" nil t nil "show" thread-id)
|
||||||
(notmuch-show-markup-headers)
|
(notmuch-show-markup-messages)
|
||||||
)
|
)
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue