[PATCH 0/3] minor cleanup and improvements

classic Classic list List threaded Threaded
39 messages Options
12
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 0/3] minor cleanup and improvements

Three minor cleanup or small improvement patches.

David Edmondson (3):
  emacs: Stop the `truncate-string-to-width' madness.
  emacs: Don't mark messages as "unsaved" when printing.
  emacs: Prefer '[No Subject]' to blank subjects.

 emacs/notmuch-lib.el   |    5 +++++
 emacs/notmuch-print.el |    9 +++++++--
 emacs/notmuch-show.el  |    5 ++++-
 emacs/notmuch.el       |   13 ++++---------
 4 files changed, 20 insertions(+), 12 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 1/3] emacs: Stop the `truncate-string-to-width' madness.

There's no need to call `truncate-string-to-width' twice in this code
path.
---
 emacs/notmuch.el |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3ec0816..3f6b977 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -441,18 +441,16 @@ Complete list of currently available key bindings:
   (interactive "P")
   (let ((thread-id (notmuch-search-find-thread-id))
  (subject (notmuch-search-find-subject)))
+
+    (if (string-match "^[ \t]*$" subject)
+ (setq subject "[No Subject]"))
+
     (if (> (length thread-id) 0)
  (notmuch-show thread-id
       (current-buffer)
       notmuch-search-query-string
-      ;; name the buffer based on notmuch-search-find-subject
-      (if (string-match "^[ \t]*$" subject)
-  "[No Subject]"
- (truncate-string-to-width
- (concat "*"
- (truncate-string-to-width subject 32 nil nil t)
- "*")
- 32 nil nil t))
+      ;; Name the buffer based on the subject.
+      (concat "*" (truncate-string-to-width subject 30 nil nil t) "*")
       crypto-switch)
       (message "End of search results."))))
 
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 2/3] emacs: Don't mark messages as "unsaved" when printing.

In reply to this post by David Edmondson
`ps-print-buffer' notes that a buffer is unsaved unless
`buffer-modified-p' returns `nil', so ensure that it does.
---
 emacs/notmuch-print.el |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index f96ccbe..83eb525 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -80,6 +80,7 @@ Optional OUTPUT allows passing a list of flags to muttprint."
 
 (defun notmuch-print-message (msg)
   "Print a message using the user-selected mechanism."
+  (set-buffer-modified-p nil)
   (funcall notmuch-print-mechanism msg))
 
 (provide 'notmuch-print)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

In reply to this post by David Edmondson
---
 emacs/notmuch-lib.el   |    5 +++++
 emacs/notmuch-print.el |    8 ++++++--
 emacs/notmuch-show.el  |    5 ++++-
 emacs/notmuch.el       |    5 +----
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 241fe8c..de33575 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,11 @@ the user hasn't set this variable with the old or new value."
   (interactive)
   (kill-buffer (current-buffer)))
 
+(defun notmuch-prettify-subject (subject)
+  (if (string-match "^[ \t]*$" subject)
+      (setq subject "[No Subject]"))
+  subject)
+
 ;;
 
 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index 83eb525..51bb740 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: David Edmondson <[hidden email]>
 
+(require 'notmuch-lib)
+
 (defcustom notmuch-print-mechanism 'notmuch-print-lpr
   "How should printing be done?"
   :group 'notmuch
@@ -56,14 +58,16 @@ Optional OUTPUT allows passing a list of flags to muttprint."
 
 (defun notmuch-print-ps-print (msg)
   "Print a message buffer using the ps-print package."
-  (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+  (let ((subject (notmuch-prettify-subject
+  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
     (rename-buffer subject t)
     (ps-print-buffer)))
 
 (defun notmuch-print-ps-print/evince (msg)
   "Preview a message buffer using ps-print and evince."
   (let ((ps-file (make-temp-file "notmuch"))
- (subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+ (subject (notmuch-prettify-subject
+  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
     (rename-buffer subject t)
     (ps-print-buffer ps-file)
     (notmuch-print-run-evince ps-file)))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..c602b3e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -985,7 +985,7 @@ buffer."
       (notmuch-show-next-open-message))
 
     ;; Set the header line to the subject of the first open message.
-    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
+    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))
 
     (notmuch-show-mark-read)))
 
@@ -1216,6 +1216,9 @@ Some useful entries are:
 (defun notmuch-show-get-depth ()
   (notmuch-show-get-prop :depth))
 
+(defun notmuch-show-get-pretty-subject ()
+  (notmuch-prettify-subject (notmuch-show-get-subject)))
+
 (defun notmuch-show-set-tags (tags)
   "Set the tags of the current message."
   (notmuch-show-set-prop :tags tags)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3f6b977..ce1e232 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -440,10 +440,7 @@ Complete list of currently available key bindings:
   "Display the currently selected thread."
   (interactive "P")
   (let ((thread-id (notmuch-search-find-thread-id))
- (subject (notmuch-search-find-subject)))
-
-    (if (string-match "^[ \t]*$" subject)
- (setq subject "[No Subject]"))
+ (subject (notmuch-prettify-subject (notmuch-search-find-subject))))
 
     (if (> (length thread-id) 0)
  (notmuch-show thread-id
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

On Wed, 25 Jan 2012 13:08:33 +0000, David Edmondson <[hidden email]> wrote:
> ---
>  emacs/notmuch-lib.el   |    5 +++++
>  emacs/notmuch-print.el |    8 ++++++--
>  emacs/notmuch-show.el  |    5 ++++-
>  emacs/notmuch.el       |    5 +----
>  4 files changed, 16 insertions(+), 7 deletions(-)

Don't apply this one. Some odd interaction when I test with Jameson's
patches to re-work movement through a thread.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 0/3 v2] minor cleanup and improvements

In reply to this post by David Edmondson
Three minor cleanup or small improvement patches.

v2: Fix the case where subject can be `nil' in patch 3.

David Edmondson (3):
  emacs: Stop the `truncate-string-to-width' madness.
  emacs: Don't mark messages as "unsaved" when printing.
  emacs: Prefer '[No Subject]' to blank subjects.

 emacs/notmuch-lib.el   |    6 ++++++
 emacs/notmuch-print.el |    9 +++++++--
 emacs/notmuch-show.el  |    5 ++++-
 emacs/notmuch.el       |   13 ++++---------
 4 files changed, 21 insertions(+), 12 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 1/3] emacs: Stop the `truncate-string-to-width' madness.

There's no need to call `truncate-string-to-width' twice in this code
path.
---
 emacs/notmuch.el |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3ec0816..3f6b977 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -441,18 +441,16 @@ Complete list of currently available key bindings:
   (interactive "P")
   (let ((thread-id (notmuch-search-find-thread-id))
  (subject (notmuch-search-find-subject)))
+
+    (if (string-match "^[ \t]*$" subject)
+ (setq subject "[No Subject]"))
+
     (if (> (length thread-id) 0)
  (notmuch-show thread-id
       (current-buffer)
       notmuch-search-query-string
-      ;; name the buffer based on notmuch-search-find-subject
-      (if (string-match "^[ \t]*$" subject)
-  "[No Subject]"
- (truncate-string-to-width
- (concat "*"
- (truncate-string-to-width subject 32 nil nil t)
- "*")
- 32 nil nil t))
+      ;; Name the buffer based on the subject.
+      (concat "*" (truncate-string-to-width subject 30 nil nil t) "*")
       crypto-switch)
       (message "End of search results."))))
 
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 2/3] emacs: Don't mark messages as "unsaved" when printing.

In reply to this post by David Edmondson
`ps-print-buffer' notes that a buffer is unsaved unless
`buffer-modified-p' returns `nil', so ensure that it does.
---
 emacs/notmuch-print.el |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index f96ccbe..83eb525 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -80,6 +80,7 @@ Optional OUTPUT allows passing a list of flags to muttprint."
 
 (defun notmuch-print-message (msg)
   "Print a message using the user-selected mechanism."
+  (set-buffer-modified-p nil)
   (funcall notmuch-print-mechanism msg))
 
 (provide 'notmuch-print)
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

In reply to this post by David Edmondson
---
 emacs/notmuch-lib.el   |    6 ++++++
 emacs/notmuch-print.el |    8 ++++++--
 emacs/notmuch-show.el  |    5 ++++-
 emacs/notmuch.el       |    5 +----
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 241fe8c..5b8a41c 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,12 @@ the user hasn't set this variable with the old or new value."
   (interactive)
   (kill-buffer (current-buffer)))
 
+(defun notmuch-prettify-subject (subject)
+  (if (and subject
+   (string-match "^[ \t]*$" subject))
+      (setq subject "[No Subject]"))
+  subject)
+
 ;;
 
 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
index 83eb525..51bb740 100644
--- a/emacs/notmuch-print.el
+++ b/emacs/notmuch-print.el
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: David Edmondson <[hidden email]>
 
+(require 'notmuch-lib)
+
 (defcustom notmuch-print-mechanism 'notmuch-print-lpr
   "How should printing be done?"
   :group 'notmuch
@@ -56,14 +58,16 @@ Optional OUTPUT allows passing a list of flags to muttprint."
 
 (defun notmuch-print-ps-print (msg)
   "Print a message buffer using the ps-print package."
-  (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+  (let ((subject (notmuch-prettify-subject
+  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
     (rename-buffer subject t)
     (ps-print-buffer)))
 
 (defun notmuch-print-ps-print/evince (msg)
   "Preview a message buffer using ps-print and evince."
   (let ((ps-file (make-temp-file "notmuch"))
- (subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
+ (subject (notmuch-prettify-subject
+  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
     (rename-buffer subject t)
     (ps-print-buffer ps-file)
     (notmuch-print-run-evince ps-file)))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..c602b3e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -985,7 +985,7 @@ buffer."
       (notmuch-show-next-open-message))
 
     ;; Set the header line to the subject of the first open message.
-    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
+    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))
 
     (notmuch-show-mark-read)))
 
@@ -1216,6 +1216,9 @@ Some useful entries are:
 (defun notmuch-show-get-depth ()
   (notmuch-show-get-prop :depth))
 
+(defun notmuch-show-get-pretty-subject ()
+  (notmuch-prettify-subject (notmuch-show-get-subject)))
+
 (defun notmuch-show-set-tags (tags)
   "Set the tags of the current message."
   (notmuch-show-set-prop :tags tags)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3f6b977..ce1e232 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -440,10 +440,7 @@ Complete list of currently available key bindings:
   "Display the currently selected thread."
   (interactive "P")
   (let ((thread-id (notmuch-search-find-thread-id))
- (subject (notmuch-search-find-subject)))
-
-    (if (string-match "^[ \t]*$" subject)
- (setq subject "[No Subject]"))
+ (subject (notmuch-prettify-subject (notmuch-search-find-subject))))
 
     (if (> (length thread-id) 0)
  (notmuch-show thread-id
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 0/3 v2] minor cleanup and improvements

In reply to this post by David Edmondson
On Wed, 25 Jan 2012 13:48:31 +0000, David Edmondson <[hidden email]> wrote:
>   emacs: Stop the `truncate-string-to-width' madness.
>   emacs: Don't mark messages as "unsaved" when printing.
>   emacs: Prefer '[No Subject]' to blank subjects.

Can I get reviewers for these? The middle one is trivial. The others are
simple.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

In reply to this post by David Edmondson
On Fri, 27 Jan 2012 10:23:07 +0000, Mark Walters <[hidden email]> wrote:
> I am very much not a lisp expert

Me neither, so please do continue to review stuff.

> The patch 1/3 seems to set the show buffer line to *[No Subject]* where
> it used to be just [No Subject]. (I have no preference: I just wasn't
> sure if that was intentional.

There was inconsistency before, now the buffer name always has the
surrounding *s.

> Patch 3/3:
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index e6a5b31..c602b3e 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -985,7 +985,7 @@ buffer."
> >        (notmuch-show-next-open-message))
> >  
> >      ;; Set the header line to the subject of the first open message.
> > -    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
> > +    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))
> >  
> >      (notmuch-show-mark-read)))
> >  
> > @@ -1216,6 +1216,9 @@ Some useful entries are:
> >  (defun notmuch-show-get-depth ()
> >    (notmuch-show-get-prop :depth))
> >  
> > +(defun notmuch-show-get-pretty-subject ()
> > +  (notmuch-prettify-subject (notmuch-show-get-subject)))
> > +
> >  (defun notmuch-show-set-tags (tags)
> >    "Set the tags of the current message."
> >    (notmuch-show-set-prop :tags tags)
>
> As far as I can see notmuch-show-get-pretty-subject is only called once
> so I wondered why you bothered with a new function. But as I say I have
> almost zero lisp experience so no feel for lisp style.
Just mirroring the existing structure really.
`notmuch-show-get-<something>' to access details of the message. I've no
strong preference.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

In reply to this post by David Edmondson

I am very much not a lisp expert but for what it's worth I read/reviewed
the patches and like them with a couple of minor queries that I am happy
to be overruled on

The patch 1/3 seems to set the show buffer line to *[No Subject]* where
it used to be just [No Subject]. (I have no preference: I just wasn't
sure if that was intentional.

Patch 2/3 is obviously fine and good.

Patch 3/3:

> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index e6a5b31..c602b3e 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -985,7 +985,7 @@ buffer."
>        (notmuch-show-next-open-message))
>  
>      ;; Set the header line to the subject of the first open message.
> -    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
> +    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))
>  
>      (notmuch-show-mark-read)))
>  
> @@ -1216,6 +1216,9 @@ Some useful entries are:
>  (defun notmuch-show-get-depth ()
>    (notmuch-show-get-prop :depth))
>  
> +(defun notmuch-show-get-pretty-subject ()
> +  (notmuch-prettify-subject (notmuch-show-get-subject)))
> +
>  (defun notmuch-show-set-tags (tags)
>    "Set the tags of the current message."
>    (notmuch-show-set-prop :tags tags)

As far as I can see notmuch-show-get-pretty-subject is only called once
so I wondered why you bothered with a new function. But as I say I have
almost zero lisp experience so no feel for lisp style.

Best wishes

Mark

(sorry for the resend: I sent from the wrong address the first time)
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 2/3] emacs: Don't mark messages as "unsaved" when printing.

In reply to this post by David Edmondson
On Wed, 25 Jan 2012 13:48:33 +0000, David Edmondson <[hidden email]> wrote:
> `ps-print-buffer' notes that a buffer is unsaved unless
> `buffer-modified-p' returns `nil', so ensure that it does.

pushed,

d
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 2/3] emacs: Don't mark messages as "unsaved" when printing.

In reply to this post by David Edmondson
On Wed, 25 Jan 2012 13:48:33 +0000, David Edmondson <[hidden email]> wrote:
> `ps-print-buffer' notes that a buffer is unsaved unless
> `buffer-modified-p' returns `nil', so ensure that it does.
> ---

Pushed.

d
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

In reply to this post by David Edmondson

Oh one other question: I think a search result line in the emacs
interface just has a blank if a thread has no subject. Would it be
appropriate to change that to [No Subject] too? (I have no preference)

Best wishes

Mark

On Fri, 27 Jan 2012 10:28:56 +0000, David Edmondson <[hidden email]> wrote:

> On Fri, 27 Jan 2012 10:23:07 +0000, Mark Walters <[hidden email]> wrote:
> > I am very much not a lisp expert
>
> Me neither, so please do continue to review stuff.
>
> > The patch 1/3 seems to set the show buffer line to *[No Subject]* where
> > it used to be just [No Subject]. (I have no preference: I just wasn't
> > sure if that was intentional.
>
> There was inconsistency before, now the buffer name always has the
> surrounding *s.
>
> > Patch 3/3:
> > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > > index e6a5b31..c602b3e 100644
> > > --- a/emacs/notmuch-show.el
> > > +++ b/emacs/notmuch-show.el
> > > @@ -985,7 +985,7 @@ buffer."
> > >        (notmuch-show-next-open-message))
> > >  
> > >      ;; Set the header line to the subject of the first open message.
> > > -    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
> > > +    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))
> > >  
> > >      (notmuch-show-mark-read)))
> > >  
> > > @@ -1216,6 +1216,9 @@ Some useful entries are:
> > >  (defun notmuch-show-get-depth ()
> > >    (notmuch-show-get-prop :depth))
> > >  
> > > +(defun notmuch-show-get-pretty-subject ()
> > > +  (notmuch-prettify-subject (notmuch-show-get-subject)))
> > > +
> > >  (defun notmuch-show-set-tags (tags)
> > >    "Set the tags of the current message."
> > >    (notmuch-show-set-prop :tags tags)
> >
> > As far as I can see notmuch-show-get-pretty-subject is only called once
> > so I wondered why you bothered with a new function. But as I say I have
> > almost zero lisp experience so no feel for lisp style.
>
> Just mirroring the existing structure really.
> `notmuch-show-get-<something>' to access details of the message. I've no
> strong preference.
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

On Fri, 27 Jan 2012 13:31:27 +0000, Mark Walters <[hidden email]> wrote:
> Oh one other question: I think a search result line in the emacs
> interface just has a blank if a thread has no subject. Would it be
> appropriate to change that to [No Subject] too? (I have no preference)

Yes, makes sense. In the next version.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
Austin Clements Austin Clements
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 1/3] emacs: Stop the `truncate-string-to-width' madness.

In reply to this post by David Edmondson
Quoth David Edmondson on Jan 25 at  1:48 pm:
> There's no need to call `truncate-string-to-width' twice in this code
> path.

LGTM if what I point out below is okay.  Technically this changes the
behavior of this code, but what it did before was obviously wrong (if
you do roll a new version, I'd mention this in the commit message; but
no need to do that just for this).

> ---
>  emacs/notmuch.el |   14 ++++++--------
>  1 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 3ec0816..3f6b977 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -441,18 +441,16 @@ Complete list of currently available key bindings:
>    (interactive "P")
>    (let ((thread-id (notmuch-search-find-thread-id))
>   (subject (notmuch-search-find-subject)))
> +
> +    (if (string-match "^[ \t]*$" subject)
> + (setq subject "[No Subject]"))
> +

Is subject necessarily a string at this point?  Previously this only
ran if the code determined there was a thread at point.

>      (if (> (length thread-id) 0)
>   (notmuch-show thread-id
>        (current-buffer)
>        notmuch-search-query-string
> -      ;; name the buffer based on notmuch-search-find-subject
> -      (if (string-match "^[ \t]*$" subject)
> -  "[No Subject]"
> - (truncate-string-to-width
> - (concat "*"
> - (truncate-string-to-width subject 32 nil nil t)
> - "*")
> - 32 nil nil t))
> +      ;; Name the buffer based on the subject.
> +      (concat "*" (truncate-string-to-width subject 30 nil nil t) "*")
>        crypto-switch)
>        (message "End of search results."))))
>  
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Austin Clements Austin Clements
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 3/3] emacs: Prefer '[No Subject]' to blank subjects.

In reply to this post by David Edmondson
LGTM other than what Mark pointed out about this not applying to
subjects in the search buffer.

Quoth David Edmondson on Jan 25 at  1:48 pm:

> ---
>  emacs/notmuch-lib.el   |    6 ++++++
>  emacs/notmuch-print.el |    8 ++++++--
>  emacs/notmuch-show.el  |    5 ++++-
>  emacs/notmuch.el       |    5 +----
>  4 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 241fe8c..5b8a41c 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -130,6 +130,12 @@ the user hasn't set this variable with the old or new value."
>    (interactive)
>    (kill-buffer (current-buffer)))
>  
> +(defun notmuch-prettify-subject (subject)
> +  (if (and subject
> +   (string-match "^[ \t]*$" subject))
> +      (setq subject "[No Subject]"))
> +  subject)
> +
>  ;;
>  
>  (defun notmuch-common-do-stash (text)
> diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
> index 83eb525..51bb740 100644
> --- a/emacs/notmuch-print.el
> +++ b/emacs/notmuch-print.el
> @@ -19,6 +19,8 @@
>  ;;
>  ;; Authors: David Edmondson <[hidden email]>
>  
> +(require 'notmuch-lib)
> +
>  (defcustom notmuch-print-mechanism 'notmuch-print-lpr
>    "How should printing be done?"
>    :group 'notmuch
> @@ -56,14 +58,16 @@ Optional OUTPUT allows passing a list of flags to muttprint."
>  
>  (defun notmuch-print-ps-print (msg)
>    "Print a message buffer using the ps-print package."
> -  (let ((subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
> +  (let ((subject (notmuch-prettify-subject
> +  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
>      (rename-buffer subject t)
>      (ps-print-buffer)))
>  
>  (defun notmuch-print-ps-print/evince (msg)
>    "Preview a message buffer using ps-print and evince."
>    (let ((ps-file (make-temp-file "notmuch"))
> - (subject (plist-get (notmuch-show-get-prop :headers msg) :Subject)))
> + (subject (notmuch-prettify-subject
> +  (plist-get (notmuch-show-get-prop :headers msg) :Subject))))
>      (rename-buffer subject t)
>      (ps-print-buffer ps-file)
>      (notmuch-print-run-evince ps-file)))
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index e6a5b31..c602b3e 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -985,7 +985,7 @@ buffer."
>        (notmuch-show-next-open-message))
>  
>      ;; Set the header line to the subject of the first open message.
> -    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
> +    (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))
>  
>      (notmuch-show-mark-read)))
>  
> @@ -1216,6 +1216,9 @@ Some useful entries are:
>  (defun notmuch-show-get-depth ()
>    (notmuch-show-get-prop :depth))
>  
> +(defun notmuch-show-get-pretty-subject ()
> +  (notmuch-prettify-subject (notmuch-show-get-subject)))
> +
>  (defun notmuch-show-set-tags (tags)
>    "Set the tags of the current message."
>    (notmuch-show-set-prop :tags tags)
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 3f6b977..ce1e232 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -440,10 +440,7 @@ Complete list of currently available key bindings:
>    "Display the currently selected thread."
>    (interactive "P")
>    (let ((thread-id (notmuch-search-find-thread-id))
> - (subject (notmuch-search-find-subject)))
> -
> -    (if (string-match "^[ \t]*$" subject)
> - (setq subject "[No Subject]"))
> + (subject (notmuch-prettify-subject (notmuch-search-find-subject))))
>  
>      (if (> (length thread-id) 0)
>   (notmuch-show thread-id
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 1/3] emacs: Stop the `truncate-string-to-width' madness.

In reply to this post by Austin Clements
On Sat, 28 Jan 2012 00:09:58 -0500, Austin Clements <[hidden email]> wrote:

> Quoth David Edmondson on Jan 25 at  1:48 pm:
> > There's no need to call `truncate-string-to-width' twice in this code
> > path.
>
> LGTM if what I point out below is okay.  Technically this changes the
> behavior of this code, but what it did before was obviously wrong (if
> you do roll a new version, I'd mention this in the commit message; but
> no need to do that just for this).
>
> > ---
> >  emacs/notmuch.el |   14 ++++++--------
> >  1 files changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> > index 3ec0816..3f6b977 100644
> > --- a/emacs/notmuch.el
> > +++ b/emacs/notmuch.el
> > @@ -441,18 +441,16 @@ Complete list of currently available key bindings:
> >    (interactive "P")
> >    (let ((thread-id (notmuch-search-find-thread-id))
> >   (subject (notmuch-search-find-subject)))
> > +
> > +    (if (string-match "^[ \t]*$" subject)
> > + (setq subject "[No Subject]"))
> > +
>
> Is subject necessarily a string at this point?  Previously this only
> ran if the code determined there was a thread at point.
No, it's a bug. It's fixed in the third patch, but should be fixed here
as well.

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 0/2 v2] minor cleanup and improvements

In reply to this post by David Edmondson
Address the comments from Mark and Austin:
 - Don't assume that `subject' is a string,
 - Show [No Subject] in search output

David Edmondson (2):
  emacs: Stop the `truncate-string-to-width' madness.
  emacs: Prefer '[No Subject]' to blank subjects.

 emacs/notmuch-lib.el   |    9 +++++++++
 emacs/notmuch-print.el |    8 ++++++--
 emacs/notmuch-show.el  |    5 ++++-
 emacs/notmuch.el       |   15 +++++----------
 4 files changed, 24 insertions(+), 13 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
12
Loading...