[PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-25 Thread David Bremner
Mark Walters  writes:

> We add a hook to the show buffer in the message window to close the
> message window when that buffer quits.  It checks that the
> message-window is still displaying the show-message buffer and then
> closes it.

pushed.

d


[PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-25 Thread Tomi Ollila
On Tue, Dec 25 2012, Mark Walters  wrote:

> We add a hook to the show buffer in the message window to close the
> message window when that buffer quits.  It checks that the
> message-window is still displaying the show-message buffer and then
> closes it.
> ---
> This is just a slightly tidier version of the previous patch. It is
> more natural to reuse the nomuch-pick-message-window variable (as it
> serves the same pupose) rather than adding a new variable and
> cluttering up the name space (and it also keeps the clutter in the
> notmuch-pick namespace).
>
> I think this a good candidate for 0.15: it fixes an annoying bug in pick. 
>
> Best wishes
>
> Mark
>
>
>  contrib/notmuch-pick/notmuch-pick.el |   19 +++
>  1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/contrib/notmuch-pick/notmuch-pick.el 
> b/contrib/notmuch-pick/notmuch-pick.el
> index 1a553d4..7d01f4c 100644
> --- a/contrib/notmuch-pick/notmuch-pick.el
> +++ b/contrib/notmuch-pick/notmuch-pick.el
> @@ -157,6 +157,10 @@
>  (make-variable-buffer-local 'notmuch-pick-query-context)
>  (defvar notmuch-pick-buffer-name nil)
>  (make-variable-buffer-local 'notmuch-pick-buffer-name)
> +;; This variable is the window used for the message pane. It is set
> +;; in both the parent pick buffer and the child show buffer. It is
> +;; used to try and close the message pane when quitting pick or the
> +;; child show buffer.
>  (defvar notmuch-pick-message-window nil)
>  (make-variable-buffer-local 'notmuch-pick-message-window)
>  (put 'notmuch-pick-message-window 'permanent-local t)
> @@ -324,6 +328,16 @@ Does NOT change the database."
>  (notmuch-prettify-subject (notmuch-search-find-subject)))
>(notmuch-pick-show-match-message-with-wait))
>  
> +(defun notmuch-pick-message-window-kill-hook ()
> +  (let ((buffer (current-buffer)))
> +(when (and (window-live-p notmuch-pick-message-window)
> +(eq (window-buffer notmuch-pick-message-window) buffer))
> +  ;; We do not want an error if this is the sole window in the
> +  ;; frame and I do not know how to test for that in emacs pre
> +  ;; 24. Hence we just ignore-errors.
> +  (ignore-errors
> + (delete-window notmuch-pick-message-window)
> +
>  (defun notmuch-pick-show-message ()
>"Show the current message (in split-pane)."
>(interactive)
> @@ -341,6 +355,11 @@ Does NOT change the database."
>   (let ((notmuch-show-indent-messages-width 0))
> (setq current-prefix-arg '(4))
> (setq buffer (notmuch-show id nil nil nil
> +  ;; We need the `let' as notmuch-pick-message-window is buffer local.
> +  (let ((window notmuch-pick-message-window))
> + (with-current-buffer buffer
> +   (setq notmuch-pick-message-window window)
> +   (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook)))
>(notmuch-pick-tag-update-display (list "-unread"))
>(setq notmuch-pick-message-buffer buffer


LGTM. 

Tomi

PS: (unrelated) Mark: check if notmuch-show-mark-read-tags should be used in
   line:
   (notmuch-pick-tag-update-display (list "-unread"))

> -- 
> 1.7.9.1


[PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-25 Thread Mark Walters
We add a hook to the show buffer in the message window to close the
message window when that buffer quits.  It checks that the
message-window is still displaying the show-message buffer and then
closes it.
---
This is just a slightly tidier version of the previous patch. It is
more natural to reuse the nomuch-pick-message-window variable (as it
serves the same pupose) rather than adding a new variable and
cluttering up the name space (and it also keeps the clutter in the
notmuch-pick namespace).

I think this a good candidate for 0.15: it fixes an annoying bug in pick. 

Best wishes

Mark


 contrib/notmuch-pick/notmuch-pick.el |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 1a553d4..7d01f4c 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -157,6 +157,10 @@
 (make-variable-buffer-local 'notmuch-pick-query-context)
 (defvar notmuch-pick-buffer-name nil)
 (make-variable-buffer-local 'notmuch-pick-buffer-name)
+;; This variable is the window used for the message pane. It is set
+;; in both the parent pick buffer and the child show buffer. It is
+;; used to try and close the message pane when quitting pick or the
+;; child show buffer.
 (defvar notmuch-pick-message-window nil)
 (make-variable-buffer-local 'notmuch-pick-message-window)
 (put 'notmuch-pick-message-window 'permanent-local t)
@@ -324,6 +328,16 @@ Does NOT change the database."
 (notmuch-prettify-subject (notmuch-search-find-subject)))
   (notmuch-pick-show-match-message-with-wait))

+(defun notmuch-pick-message-window-kill-hook ()
+  (let ((buffer (current-buffer)))
+(when (and (window-live-p notmuch-pick-message-window)
+  (eq (window-buffer notmuch-pick-message-window) buffer))
+  ;; We do not want an error if this is the sole window in the
+  ;; frame and I do not know how to test for that in emacs pre
+  ;; 24. Hence we just ignore-errors.
+  (ignore-errors
+   (delete-window notmuch-pick-message-window)
+
 (defun notmuch-pick-show-message ()
   "Show the current message (in split-pane)."
   (interactive)
@@ -341,6 +355,11 @@ Does NOT change the database."
(let ((notmuch-show-indent-messages-width 0))
  (setq current-prefix-arg '(4))
  (setq buffer (notmuch-show id nil nil nil
+  ;; We need the `let' as notmuch-pick-message-window is buffer local.
+  (let ((window notmuch-pick-message-window))
+   (with-current-buffer buffer
+ (setq notmuch-pick-message-window window)
+ (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook)))
   (notmuch-pick-tag-update-display (list "-unread"))
   (setq notmuch-pick-message-buffer buffer

-- 
1.7.9.1



[PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-25 Thread Mark Walters
We add a hook to the show buffer in the message window to close the
message window when that buffer quits.  It checks that the
message-window is still displaying the show-message buffer and then
closes it.
---
This is just a slightly tidier version of the previous patch. It is
more natural to reuse the nomuch-pick-message-window variable (as it
serves the same pupose) rather than adding a new variable and
cluttering up the name space (and it also keeps the clutter in the
notmuch-pick namespace).

I think this a good candidate for 0.15: it fixes an annoying bug in pick. 

Best wishes

Mark


 contrib/notmuch-pick/notmuch-pick.el |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 1a553d4..7d01f4c 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -157,6 +157,10 @@
 (make-variable-buffer-local 'notmuch-pick-query-context)
 (defvar notmuch-pick-buffer-name nil)
 (make-variable-buffer-local 'notmuch-pick-buffer-name)
+;; This variable is the window used for the message pane. It is set
+;; in both the parent pick buffer and the child show buffer. It is
+;; used to try and close the message pane when quitting pick or the
+;; child show buffer.
 (defvar notmuch-pick-message-window nil)
 (make-variable-buffer-local 'notmuch-pick-message-window)
 (put 'notmuch-pick-message-window 'permanent-local t)
@@ -324,6 +328,16 @@ Does NOT change the database.
 (notmuch-prettify-subject (notmuch-search-find-subject)))
   (notmuch-pick-show-match-message-with-wait))
 
+(defun notmuch-pick-message-window-kill-hook ()
+  (let ((buffer (current-buffer)))
+(when (and (window-live-p notmuch-pick-message-window)
+  (eq (window-buffer notmuch-pick-message-window) buffer))
+  ;; We do not want an error if this is the sole window in the
+  ;; frame and I do not know how to test for that in emacs pre
+  ;; 24. Hence we just ignore-errors.
+  (ignore-errors
+   (delete-window notmuch-pick-message-window)
+
 (defun notmuch-pick-show-message ()
   Show the current message (in split-pane).
   (interactive)
@@ -341,6 +355,11 @@ Does NOT change the database.
(let ((notmuch-show-indent-messages-width 0))
  (setq current-prefix-arg '(4))
  (setq buffer (notmuch-show id nil nil nil
+  ;; We need the `let' as notmuch-pick-message-window is buffer local.
+  (let ((window notmuch-pick-message-window))
+   (with-current-buffer buffer
+ (setq notmuch-pick-message-window window)
+ (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook)))
   (notmuch-pick-tag-update-display (list -unread))
   (setq notmuch-pick-message-buffer buffer
 
-- 
1.7.9.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-25 Thread Tomi Ollila
On Tue, Dec 25 2012, Mark Walters markwalters1...@gmail.com wrote:

 We add a hook to the show buffer in the message window to close the
 message window when that buffer quits.  It checks that the
 message-window is still displaying the show-message buffer and then
 closes it.
 ---
 This is just a slightly tidier version of the previous patch. It is
 more natural to reuse the nomuch-pick-message-window variable (as it
 serves the same pupose) rather than adding a new variable and
 cluttering up the name space (and it also keeps the clutter in the
 notmuch-pick namespace).

 I think this a good candidate for 0.15: it fixes an annoying bug in pick. 

 Best wishes

 Mark


  contrib/notmuch-pick/notmuch-pick.el |   19 +++
  1 files changed, 19 insertions(+), 0 deletions(-)

 diff --git a/contrib/notmuch-pick/notmuch-pick.el 
 b/contrib/notmuch-pick/notmuch-pick.el
 index 1a553d4..7d01f4c 100644
 --- a/contrib/notmuch-pick/notmuch-pick.el
 +++ b/contrib/notmuch-pick/notmuch-pick.el
 @@ -157,6 +157,10 @@
  (make-variable-buffer-local 'notmuch-pick-query-context)
  (defvar notmuch-pick-buffer-name nil)
  (make-variable-buffer-local 'notmuch-pick-buffer-name)
 +;; This variable is the window used for the message pane. It is set
 +;; in both the parent pick buffer and the child show buffer. It is
 +;; used to try and close the message pane when quitting pick or the
 +;; child show buffer.
  (defvar notmuch-pick-message-window nil)
  (make-variable-buffer-local 'notmuch-pick-message-window)
  (put 'notmuch-pick-message-window 'permanent-local t)
 @@ -324,6 +328,16 @@ Does NOT change the database.
  (notmuch-prettify-subject (notmuch-search-find-subject)))
(notmuch-pick-show-match-message-with-wait))
  
 +(defun notmuch-pick-message-window-kill-hook ()
 +  (let ((buffer (current-buffer)))
 +(when (and (window-live-p notmuch-pick-message-window)
 +(eq (window-buffer notmuch-pick-message-window) buffer))
 +  ;; We do not want an error if this is the sole window in the
 +  ;; frame and I do not know how to test for that in emacs pre
 +  ;; 24. Hence we just ignore-errors.
 +  (ignore-errors
 + (delete-window notmuch-pick-message-window)
 +
  (defun notmuch-pick-show-message ()
Show the current message (in split-pane).
(interactive)
 @@ -341,6 +355,11 @@ Does NOT change the database.
   (let ((notmuch-show-indent-messages-width 0))
 (setq current-prefix-arg '(4))
 (setq buffer (notmuch-show id nil nil nil
 +  ;; We need the `let' as notmuch-pick-message-window is buffer local.
 +  (let ((window notmuch-pick-message-window))
 + (with-current-buffer buffer
 +   (setq notmuch-pick-message-window window)
 +   (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook)))
(notmuch-pick-tag-update-display (list -unread))
(setq notmuch-pick-message-buffer buffer


LGTM. 

Tomi

PS: (unrelated) Mark: check if notmuch-show-mark-read-tags should be used in
   line:
   (notmuch-pick-tag-update-display (list -unread))

 -- 
 1.7.9.1
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-25 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:

 We add a hook to the show buffer in the message window to close the
 message window when that buffer quits.  It checks that the
 message-window is still displaying the show-message buffer and then
 closes it.

pushed.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-16 Thread Mark Walters
We add a hook to the show buffer in the message window to close the
message window when that buffer quits.  It checks that the
message-window is still displaying the show-message buffer and then
closes it.
---

This is (probably) a rather better version than the previous
attempt. It uses hooks rather than redefining notmuch-kill-this-buffer
and it avoids errors if the user has made the message pane the whole
frame.

Best wishes

Mark


 contrib/notmuch-pick/notmuch-pick.el |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 043e9e7..8383589 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -160,6 +160,9 @@
 (defvar notmuch-pick-message-window nil)
 (make-variable-buffer-local 'notmuch-pick-message-window)
 (put 'notmuch-pick-message-window 'permanent-local t)
+(defvar notmuch-show-message-window nil)
+(make-variable-buffer-local 'notmuch-show-message-window)
+(put 'notmuch-show-message-window 'permanent-local t)
 (defvar notmuch-pick-message-buffer nil)
 (make-variable-buffer-local 'notmuch-pick-message-buffer-name)
 (put 'notmuch-pick-message-buffer-name 'permanent-local t)
@@ -389,6 +392,16 @@ Does NOT change the database."
 (notmuch-prettify-subject (notmuch-search-find-subject)))
   (notmuch-pick-show-match-message-with-wait))

+(defun notmuch-pick-message-window-kill-hook ()
+  (let ((buffer (current-buffer)))
+(when (and (window-live-p notmuch-show-message-window)
+  (eq (window-buffer notmuch-show-message-window) buffer))
+  ;; We do not want an error if this is the sole window in the
+  ;; frame and I do not know how to test for that in emacs pre
+  ;; 24. Hence we just ignore-errors.
+  (ignore-errors
+   (delete-window notmuch-show-message-window)
+
 (defun notmuch-pick-show-message ()
   "Show the current message (in split-pane)."
   (interactive)
@@ -406,6 +419,11 @@ Does NOT change the database."
(let ((notmuch-show-indent-messages-width 0))
  (setq current-prefix-arg '(4))
  (setq buffer (notmuch-show id nil nil nil
+  ;; We need the `let' as notmuch-pick-message-window is buffer local.
+  (let ((window notmuch-pick-message-window))
+   (with-current-buffer buffer
+ (setq notmuch-show-message-window window)
+ (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook)))
   (notmuch-pick-tag-update-display (list "-unread"))
   (setq notmuch-pick-message-buffer buffer

-- 
1.7.9.1



[PATCH] contrib: pick: close message pane when quitting from show in the message pane

2012-12-16 Thread Mark Walters
We add a hook to the show buffer in the message window to close the
message window when that buffer quits.  It checks that the
message-window is still displaying the show-message buffer and then
closes it.
---

This is (probably) a rather better version than the previous
attempt. It uses hooks rather than redefining notmuch-kill-this-buffer
and it avoids errors if the user has made the message pane the whole
frame.

Best wishes

Mark


 contrib/notmuch-pick/notmuch-pick.el |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 043e9e7..8383589 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -160,6 +160,9 @@
 (defvar notmuch-pick-message-window nil)
 (make-variable-buffer-local 'notmuch-pick-message-window)
 (put 'notmuch-pick-message-window 'permanent-local t)
+(defvar notmuch-show-message-window nil)
+(make-variable-buffer-local 'notmuch-show-message-window)
+(put 'notmuch-show-message-window 'permanent-local t)
 (defvar notmuch-pick-message-buffer nil)
 (make-variable-buffer-local 'notmuch-pick-message-buffer-name)
 (put 'notmuch-pick-message-buffer-name 'permanent-local t)
@@ -389,6 +392,16 @@ Does NOT change the database.
 (notmuch-prettify-subject (notmuch-search-find-subject)))
   (notmuch-pick-show-match-message-with-wait))
 
+(defun notmuch-pick-message-window-kill-hook ()
+  (let ((buffer (current-buffer)))
+(when (and (window-live-p notmuch-show-message-window)
+  (eq (window-buffer notmuch-show-message-window) buffer))
+  ;; We do not want an error if this is the sole window in the
+  ;; frame and I do not know how to test for that in emacs pre
+  ;; 24. Hence we just ignore-errors.
+  (ignore-errors
+   (delete-window notmuch-show-message-window)
+
 (defun notmuch-pick-show-message ()
   Show the current message (in split-pane).
   (interactive)
@@ -406,6 +419,11 @@ Does NOT change the database.
(let ((notmuch-show-indent-messages-width 0))
  (setq current-prefix-arg '(4))
  (setq buffer (notmuch-show id nil nil nil
+  ;; We need the `let' as notmuch-pick-message-window is buffer local.
+  (let ((window notmuch-pick-message-window))
+   (with-current-buffer buffer
+ (setq notmuch-show-message-window window)
+ (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook)))
   (notmuch-pick-tag-update-display (list -unread))
   (setq notmuch-pick-message-buffer buffer
 
-- 
1.7.9.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch