[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-16 Thread David Edmondson
On Sun, 15 Jan 2012 22:01:05 -0500, Austin Clements  wrote:
> Quoth David Edmondson on Jan 15 at 11:55 am:
> > On Sat, 14 Jan 2012 10:29:31 +0100, Pieter Praet  
> > wrote:
> > > Might I ask, to what key(chord) have you bound this ?  Due to its
> > > usefulness, I'm inclined to bind it to [SPC], but on second though,
> > > that might be a bit on the intense side...
> > 
> > C-c= globally. That's clobbered in a couple of major modes, but not
> > enough to bother me so far.
> 
> Might it make sense to bind this across the notmuch mode maps by
> default?  This would at least make this feature more visible as well
> as quite useful to people who dedicate an Emacs instance to notmuch.

The elisp manual says:

   * Don't define `C-c LETTER' as a key in Lisp programs.  Sequences
 consisting of `C-c' and a letter (either upper or lower case) are
 reserved for users; they are the *only* sequences reserved for
 users, so do not block them.

...

   * Sequences consisting of `C-c' followed by a control character or a
 digit are reserved for major modes.

   * Sequences consisting of `C-c' followed by `{', `}', `<', `>', `:'
 or `;' are also reserved for major modes.

   * Sequences consisting of `C-c' followed by any other punctuation
 character are allocated for minor modes.  Using them in a major
 mode is not absolutely prohibited, but if you do that, the major
 mode binding may be shadowed from time to time by minor modes.

which I read to mean that C-c= is allocated for use by minor modes. I
could easily be persuaded to change to C-c; and have that bound in our
major modes (and personally bind it globally).
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-15 Thread David Bremner
On Wed, 28 Dec 2011 08:29:58 +, David Edmondson  wrote:
> As suggested by j4ni in #notmuch, rename
> `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
> have it behave accordingly.

pushed, 

d


[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-15 Thread Austin Clements
Quoth David Edmondson on Jan 15 at 11:55 am:
> On Sat, 14 Jan 2012 10:29:31 +0100, Pieter Praet  wrote:
> > Might I ask, to what key(chord) have you bound this ?  Due to its
> > usefulness, I'm inclined to bind it to [SPC], but on second though,
> > that might be a bit on the intense side...
> 
> C-c= globally. That's clobbered in a couple of major modes, but not
> enough to bother me so far.

Might it make sense to bind this across the notmuch mode maps by
default?  This would at least make this feature more visible as well
as quite useful to people who dedicate an Emacs instance to notmuch.


[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-15 Thread David Edmondson
On Sat, 14 Jan 2012 10:29:31 +0100, Pieter Praet  wrote:
> Might I ask, to what key(chord) have you bound this ?  Due to its
> usefulness, I'm inclined to bind it to [SPC], but on second though,
> that might be a bit on the intense side...

C-c= globally. That's clobbered in a couple of major modes, but not
enough to bother me so far.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-15 Thread David Edmondson
On Sat, 14 Jan 2012 10:29:31 +0100, Pieter Praet pie...@praet.org wrote:
 Might I ask, to what key(chord) have you bound this ?  Due to its
 usefulness, I'm inclined to bind it to [SPC], but on second though,
 that might be a bit on the intense side...

C-c= globally. That's clobbered in a couple of major modes, but not
enough to bother me so far.


pgppjX1LeNMgl.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-15 Thread David Bremner
On Wed, 28 Dec 2011 08:29:58 +, David Edmondson d...@dme.org wrote:
 As suggested by j4ni in #notmuch, rename
 `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
 have it behave accordingly.

pushed, 

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


Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-15 Thread Austin Clements
Quoth David Edmondson on Jan 15 at 11:55 am:
 On Sat, 14 Jan 2012 10:29:31 +0100, Pieter Praet pie...@praet.org wrote:
  Might I ask, to what key(chord) have you bound this ?  Due to its
  usefulness, I'm inclined to bind it to [SPC], but on second though,
  that might be a bit on the intense side...
 
 C-c= globally. That's clobbered in a couple of major modes, but not
 enough to bother me so far.

Might it make sense to bind this across the notmuch mode maps by
default?  This would at least make this feature more visible as well
as quite useful to people who dedicate an Emacs instance to notmuch.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-14 Thread Pieter Praet
On Tue, 10 Jan 2012 22:15:02 +0200, Jani Nikula  wrote:
> I don't feel qualified to review,

Allow me to disagree: your feeling and reality appear to be disjoint ATM :)


Peace

-- 
Pieter


[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-14 Thread Pieter Praet
On Wed, 28 Dec 2011 08:29:58 +, David Edmondson  wrote:
> As suggested by j4ni in #notmuch, rename
> `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
> have it behave accordingly.
> 
> Consider `message-mode' buffers to be of interest.
> ---
>  emacs/notmuch.el |   42 ++
>  1 files changed, 30 insertions(+), 12 deletions(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index c678c93..6a44d49 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1055,21 +1055,39 @@ current search results AND that are tagged with the 
> given tag."
>(interactive)
>(notmuch-hello))
>  
> +(defun notmuch-interesting-buffer (b)
> +  "Is the current buffer of interest to a notmuch user?"
> +  (with-current-buffer b
> +(memq major-mode '(notmuch-show-mode
> +notmuch-search-mode
> +notmuch-hello-mode
> +message-mode
> +
>  ;;;###autoload
> -(defun notmuch-jump-to-recent-buffer ()
> -  "Jump to the most recent notmuch buffer (search, show or hello).
> +(defun notmuch-cycle-notmuch-buffers ()
> +  "Cycle through any existing notmuch buffers (search, show or hello).
>  
> -If no recent buffer is found, run `notmuch'."
> +If the current buffer is the only notmuch buffer, bury it. If no
> +notmuch buffers exist, run `notmuch'."
>(interactive)
> -  (let ((last
> -  (loop for buffer in (buffer-list)
> -if (with-current-buffer buffer
> - (memq major-mode '(notmuch-show-mode
> -notmuch-search-mode
> -notmuch-hello-mode)))
> -return buffer)))
> -(if last
> - (switch-to-buffer last)
> +
> +  (let (start first)
> +;; If the current buffer is a notmuch buffer, remember it and then
> +;; bury it.
> +(when (notmuch-interesting-buffer (current-buffer))
> +  (setq start (current-buffer))
> +  (bury-buffer))
> +
> +;; Find the first notmuch buffer.
> +(setq first (loop for buffer in (buffer-list)
> +  if (notmuch-interesting-buffer buffer)
> +  return buffer))
> +
> +(if first
> + ;; If the first one we found is any other than the starting
> + ;; buffer, switch to it.
> + (unless (eq first start)
> +   (switch-to-buffer first))
>(notmuch
>  
>  (setq mail-user-agent 'notmuch-user-agent)
> -- 
> 1.7.7.3

Signed-off-by: Pieter Praet   !


Might I ask, to what key(chord) have you bound this ?  Due to its
usefulness, I'm inclined to bind it to [SPC], but on second though,
that might be a bit on the intense side...


Peace

-- 
Pieter


Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-14 Thread Pieter Praet
On Wed, 28 Dec 2011 08:29:58 +, David Edmondson d...@dme.org wrote:
 As suggested by j4ni in #notmuch, rename
 `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
 have it behave accordingly.
 
 Consider `message-mode' buffers to be of interest.
 ---
  emacs/notmuch.el |   42 ++
  1 files changed, 30 insertions(+), 12 deletions(-)
 
 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
 index c678c93..6a44d49 100644
 --- a/emacs/notmuch.el
 +++ b/emacs/notmuch.el
 @@ -1055,21 +1055,39 @@ current search results AND that are tagged with the 
 given tag.
(interactive)
(notmuch-hello))
  
 +(defun notmuch-interesting-buffer (b)
 +  Is the current buffer of interest to a notmuch user?
 +  (with-current-buffer b
 +(memq major-mode '(notmuch-show-mode
 +notmuch-search-mode
 +notmuch-hello-mode
 +message-mode
 +
  ;;;###autoload
 -(defun notmuch-jump-to-recent-buffer ()
 -  Jump to the most recent notmuch buffer (search, show or hello).
 +(defun notmuch-cycle-notmuch-buffers ()
 +  Cycle through any existing notmuch buffers (search, show or hello).
  
 -If no recent buffer is found, run `notmuch'.
 +If the current buffer is the only notmuch buffer, bury it. If no
 +notmuch buffers exist, run `notmuch'.
(interactive)
 -  (let ((last
 -  (loop for buffer in (buffer-list)
 -if (with-current-buffer buffer
 - (memq major-mode '(notmuch-show-mode
 -notmuch-search-mode
 -notmuch-hello-mode)))
 -return buffer)))
 -(if last
 - (switch-to-buffer last)
 +
 +  (let (start first)
 +;; If the current buffer is a notmuch buffer, remember it and then
 +;; bury it.
 +(when (notmuch-interesting-buffer (current-buffer))
 +  (setq start (current-buffer))
 +  (bury-buffer))
 +
 +;; Find the first notmuch buffer.
 +(setq first (loop for buffer in (buffer-list)
 +  if (notmuch-interesting-buffer buffer)
 +  return buffer))
 +
 +(if first
 + ;; If the first one we found is any other than the starting
 + ;; buffer, switch to it.
 + (unless (eq first start)
 +   (switch-to-buffer first))
(notmuch
  
  (setq mail-user-agent 'notmuch-user-agent)
 -- 
 1.7.7.3

Signed-off-by: Pieter Praet pie...@praet.org  !


Might I ask, to what key(chord) have you bound this ?  Due to its
usefulness, I'm inclined to bind it to [SPC], but on second though,
that might be a bit on the intense side...


Peace

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


Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-14 Thread Pieter Praet
On Tue, 10 Jan 2012 22:15:02 +0200, Jani Nikula j...@nikula.org wrote:
 I don't feel qualified to review,

Allow me to disagree: your feeling and reality appear to be disjoint ATM :)


Peace

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


[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-10 Thread Jani Nikula
On Tue, 10 Jan 2012 16:55:07 +, David Edmondson  wrote:
> On Wed, 28 Dec 2011 08:29:58 +, David Edmondson  wrote:
> > As suggested by j4ni in #notmuch, rename
> > `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
> > have it behave accordingly.
> > 
> > Consider `message-mode' buffers to be of interest.
> 
> Any reviewers?

I don't feel qualified to review, but the patch works for me.

BR,
Jani.


[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-10 Thread David Edmondson
On Wed, 28 Dec 2011 08:29:58 +, David Edmondson  wrote:
> As suggested by j4ni in #notmuch, rename
> `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
> have it behave accordingly.
> 
> Consider `message-mode' buffers to be of interest.

Any reviewers?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



Re: [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2012-01-10 Thread Jani Nikula
On Tue, 10 Jan 2012 16:55:07 +, David Edmondson d...@dme.org wrote:
 On Wed, 28 Dec 2011 08:29:58 +, David Edmondson d...@dme.org wrote:
  As suggested by j4ni in #notmuch, rename
  `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
  have it behave accordingly.
  
  Consider `message-mode' buffers to be of interest.
 
 Any reviewers?

I don't feel qualified to review, but the patch works for me.

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


[PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last.

2011-12-28 Thread David Edmondson
As suggested by j4ni in #notmuch, rename
`notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
have it behave accordingly.

Consider `message-mode' buffers to be of interest.
---
 emacs/notmuch.el |   42 ++
 1 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c678c93..6a44d49 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1055,21 +1055,39 @@ current search results AND that are tagged with the 
given tag.
   (interactive)
   (notmuch-hello))
 
+(defun notmuch-interesting-buffer (b)
+  Is the current buffer of interest to a notmuch user?
+  (with-current-buffer b
+(memq major-mode '(notmuch-show-mode
+  notmuch-search-mode
+  notmuch-hello-mode
+  message-mode
+
 ;;;###autoload
-(defun notmuch-jump-to-recent-buffer ()
-  Jump to the most recent notmuch buffer (search, show or hello).
+(defun notmuch-cycle-notmuch-buffers ()
+  Cycle through any existing notmuch buffers (search, show or hello).
 
-If no recent buffer is found, run `notmuch'.
+If the current buffer is the only notmuch buffer, bury it. If no
+notmuch buffers exist, run `notmuch'.
   (interactive)
-  (let ((last
-(loop for buffer in (buffer-list)
-  if (with-current-buffer buffer
-   (memq major-mode '(notmuch-show-mode
-  notmuch-search-mode
-  notmuch-hello-mode)))
-  return buffer)))
-(if last
-   (switch-to-buffer last)
+
+  (let (start first)
+;; If the current buffer is a notmuch buffer, remember it and then
+;; bury it.
+(when (notmuch-interesting-buffer (current-buffer))
+  (setq start (current-buffer))
+  (bury-buffer))
+
+;; Find the first notmuch buffer.
+(setq first (loop for buffer in (buffer-list)
+if (notmuch-interesting-buffer buffer)
+return buffer))
+
+(if first
+   ;; If the first one we found is any other than the starting
+   ;; buffer, switch to it.
+   (unless (eq first start)
+ (switch-to-buffer first))
   (notmuch
 
 (setq mail-user-agent 'notmuch-user-agent)
-- 
1.7.7.3

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