unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Add `notmuch-show-elide-same-subject', controlling the appearance of collapsed messages in notmuch-show mode.
@ 2010-11-05  9:50 David Edmondson
  2010-11-05 17:51 ` Carl Worth
  0 siblings, 1 reply; 5+ messages in thread
From: David Edmondson @ 2010-11-05  9:50 UTC (permalink / raw)
  To: notmuch

If `notmuch-show-elide-same-subject' is set to `t' then collapsed
messages do not show a "Subject:" line if the subject is the same as
that of the previous message.
---
 emacs/notmuch-show.el |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7ec6aa5..07cf846 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -58,6 +58,12 @@ any given message."
   :group 'notmuch
   :type 'boolean)
 
+(defcustom notmuch-show-elide-same-subject nil
+  "Do not show the subject of a collapsed message if it is the
+same as that of the previous message."
+  :group 'notmuch
+  :type 'boolean)
+
 (defcustom notmuch-show-relative-dates t
   "Display relative dates in the message summary line."
   :group 'notmuch
@@ -381,17 +387,24 @@ current buffer, if possible."
 (defun notmuch-show-make-symbol (type)
   (make-symbol (concat "notmuch-show-" type)))
 
+(defun notmuch-show-strip-re (string)
+  (replace-regexp-in-string "^\\([Rr]e: *\\)+" "" string))
+
+(defvar notmuch-show-previous-subject "")
+(make-variable-buffer-local 'notmuch-show-previous-subject)
+
 (defun notmuch-show-insert-msg (msg depth)
   "Insert the message MSG at depth DEPTH in the current thread."
-  (let ((headers (plist-get msg :headers))
-	;; Indentation causes the buffer offset of the start/end
-	;; points to move, so we must use markers.
-	message-start message-end
-	content-start content-end
-	headers-start headers-end
-	body-start body-end
-	(headers-invis-spec (notmuch-show-make-symbol "header"))
-	(message-invis-spec (notmuch-show-make-symbol "message")))
+  (let* ((headers (plist-get msg :headers))
+	 ;; Indentation causes the buffer offset of the start/end
+	 ;; points to move, so we must use markers.
+	 message-start message-end
+	 content-start content-end
+	 headers-start headers-end
+	 body-start body-end
+	 (headers-invis-spec (notmuch-show-make-symbol "header"))
+	 (message-invis-spec (notmuch-show-make-symbol "message"))
+	 (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))
 
     ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
     ;; removing items from `buffer-invisibility-spec' (which is what
@@ -428,10 +441,15 @@ current buffer, if possible."
     (insert "\n")
     (save-excursion
       (goto-char content-start)
-      (forward-line 1)
+      (when (and notmuch-show-elide-same-subject
+		 (not (string= notmuch-show-previous-subject
+			       bare-subject)))
+	(forward-line 1))
       (setq headers-start (point-marker)))
     (setq headers-end (point-marker))
 
+    (setq notmuch-show-previous-subject bare-subject)
+
     (setq body-start (point-marker))
     (notmuch-show-insert-body msg (plist-get msg :body) depth)
     ;; Ensure that the body ends with a newline.
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] emacs: Add `notmuch-show-elide-same-subject', controlling the appearance of collapsed messages in notmuch-show mode.
  2010-11-05  9:50 [PATCH] emacs: Add `notmuch-show-elide-same-subject', controlling the appearance of collapsed messages in notmuch-show mode David Edmondson
@ 2010-11-05 17:51 ` Carl Worth
  2010-11-07 22:16   ` Sebastian Spaeth
  2010-11-08 10:44   ` [PATCH] emacs: Elide the display of repeated subjects in thread display mode David Edmondson
  0 siblings, 2 replies; 5+ messages in thread
From: Carl Worth @ 2010-11-05 17:51 UTC (permalink / raw)
  To: David Edmondson, notmuch

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

On Fri,  5 Nov 2010 09:50:15 +0000, David Edmondson <dme@dme.org> wrote:
> If `notmuch-show-elide-same-subject' is set to `t' then collapsed
> messages do not show a "Subject:" line if the subject is the same as
> that of the previous message.

Sounds cool. Thanks! (Will test and merge later.)

> +(defcustom notmuch-show-elide-same-subject nil
> +  "Do not show the subject of a collapsed message if it is the
> +same as that of the previous message."

There seems to be a compulsion on the part of some patch submitters to
not change the status quo of the interface. Let's stop doing that
please. Almost all new features that are proposed are strict
improvements, and as such they should be enabled by default, (and
perhaps even unconditional in some cases).

I really want to avoid the situation of "Oh, default notmuch-emacs is a
piece of junk---but if you tune a dozen knobs in the configuration, then
it starts to work well".

So lets start turning more improvements on by default.

Thanks,

-Carl

-- 
carl.d.worth@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] emacs: Add `notmuch-show-elide-same-subject', controlling the appearance of collapsed messages in notmuch-show mode.
  2010-11-05 17:51 ` Carl Worth
@ 2010-11-07 22:16   ` Sebastian Spaeth
  2010-11-08 10:44   ` [PATCH] emacs: Elide the display of repeated subjects in thread display mode David Edmondson
  1 sibling, 0 replies; 5+ messages in thread
From: Sebastian Spaeth @ 2010-11-07 22:16 UTC (permalink / raw)
  To: notmuch

On Fri, 05 Nov 2010 10:51:52 -0700, Carl Worth <cworth@cworth.org> wrote:
> > +(defcustom notmuch-show-elide-same-subject nil
> > +  "Do not show the subject of a collapsed message if it is the
> > +same as that of the previous message."

Just for the record. I really think this is an improvement that doesn't
need a pref to clutter up my prefs. If it is good, let's just use it
:-).

Sebastian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] emacs: Elide the display of repeated subjects in thread display mode.
  2010-11-05 17:51 ` Carl Worth
  2010-11-07 22:16   ` Sebastian Spaeth
@ 2010-11-08 10:44   ` David Edmondson
  2010-11-08 10:50     ` [PATCH] emacs: Simplify subjects more aggressively David Edmondson
  1 sibling, 1 reply; 5+ messages in thread
From: David Edmondson @ 2010-11-08 10:44 UTC (permalink / raw)
  To: notmuch

Collapsed messages do not show a "Subject:" line if the subject is the
same as that of the previous message.
---

Remove the preference setting.

 emacs/notmuch-show.el |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7ec6aa5..13964c2 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -381,17 +381,24 @@ current buffer, if possible."
 (defun notmuch-show-make-symbol (type)
   (make-symbol (concat "notmuch-show-" type)))
 
+(defun notmuch-show-strip-re (string)
+  (replace-regexp-in-string "^\\([Rr]e: *\\)+" "" string))
+
+(defvar notmuch-show-previous-subject "")
+(make-variable-buffer-local 'notmuch-show-previous-subject)
+
 (defun notmuch-show-insert-msg (msg depth)
   "Insert the message MSG at depth DEPTH in the current thread."
-  (let ((headers (plist-get msg :headers))
-	;; Indentation causes the buffer offset of the start/end
-	;; points to move, so we must use markers.
-	message-start message-end
-	content-start content-end
-	headers-start headers-end
-	body-start body-end
-	(headers-invis-spec (notmuch-show-make-symbol "header"))
-	(message-invis-spec (notmuch-show-make-symbol "message")))
+  (let* ((headers (plist-get msg :headers))
+	 ;; Indentation causes the buffer offset of the start/end
+	 ;; points to move, so we must use markers.
+	 message-start message-end
+	 content-start content-end
+	 headers-start headers-end
+	 body-start body-end
+	 (headers-invis-spec (notmuch-show-make-symbol "header"))
+	 (message-invis-spec (notmuch-show-make-symbol "message"))
+	 (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))))
 
     ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
     ;; removing items from `buffer-invisibility-spec' (which is what
@@ -428,10 +435,17 @@ current buffer, if possible."
     (insert "\n")
     (save-excursion
       (goto-char content-start)
-      (forward-line 1)
+      ;; If the subject of this message is the same as that of the
+      ;; previous message, don't display it when this message is
+      ;; collapsed.
+      (when (not (string= notmuch-show-previous-subject
+			  bare-subject))
+	(forward-line 1))
       (setq headers-start (point-marker)))
     (setq headers-end (point-marker))
 
+    (setq notmuch-show-previous-subject bare-subject)
+
     (setq body-start (point-marker))
     (notmuch-show-insert-body msg (plist-get msg :body) depth)
     ;; Ensure that the body ends with a newline.
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] emacs: Simplify subjects more aggressively.
  2010-11-08 10:44   ` [PATCH] emacs: Elide the display of repeated subjects in thread display mode David Edmondson
@ 2010-11-08 10:50     ` David Edmondson
  0 siblings, 0 replies; 5+ messages in thread
From: David Edmondson @ 2010-11-08 10:50 UTC (permalink / raw)
  To: notmuch

Remove 're: ' or 'Re: ' from anywhere within a subject line rather
than just at the beginning. This is to accommodate threads where a
mailing list sometimes inserts a subject prefix.

For example, if a thread has the subjects:

    [Orgmode] org-indent, org-inlinetask: patches on github
    Re: [Orgmode] org-indent, org-inlinetask: patches on github
    [Orgmode] Re: org-indent, org-inlinetask: patches on github

the last of these would not have been considered the same and would
therefore have been shown.
---
 emacs/notmuch-show.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index efcb335..08654f1 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -408,7 +408,7 @@ current buffer, if possible."
   (make-symbol (concat "notmuch-show-" type)))
 
 (defun notmuch-show-strip-re (string)
-  (replace-regexp-in-string "^\\([Rr]e: *\\)+" "" string))
+  (replace-regexp-in-string "\\([Rr]e: *\\)+" "" string))
 
 (defvar notmuch-show-previous-subject "")
 (make-variable-buffer-local 'notmuch-show-previous-subject)
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-08 10:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05  9:50 [PATCH] emacs: Add `notmuch-show-elide-same-subject', controlling the appearance of collapsed messages in notmuch-show mode David Edmondson
2010-11-05 17:51 ` Carl Worth
2010-11-07 22:16   ` Sebastian Spaeth
2010-11-08 10:44   ` [PATCH] emacs: Elide the display of repeated subjects in thread display mode David Edmondson
2010-11-08 10:50     ` [PATCH] emacs: Simplify subjects more aggressively David Edmondson

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).