unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2] emacs: Add `notmuch-jump-to-recent-buffer'.
@ 2011-12-20  8:01 David Edmondson
  2011-12-20 10:27 ` Tomi Ollila
  2011-12-20 11:48 ` David Bremner
  0 siblings, 2 replies; 4+ messages in thread
From: David Edmondson @ 2011-12-20  8:01 UTC (permalink / raw)
  To: notmuch

From a Carl Worth idea: add a function which will select the most
recently used notmuch buffer (search, show or hello). If no recent
buffer is found, run `notmuch'.

It is expected that the user will global bind this command to a key
sequence.
---
 emacs/notmuch.el |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2e9973e..da61aa9 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1055,6 +1055,23 @@ current search results AND that are tagged with the given tag."
   (interactive)
   (notmuch-hello))
 
+;;;###autoload
+(defun notmuch-jump-to-recent-buffer ()
+  "Jump to the most recent notmuch buffer (search, show or hello).
+
+If no recent buffer is found, 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)
+      (notmuch))))
+
 (setq mail-user-agent 'notmuch-user-agent)
 
 (provide 'notmuch)
-- 
1.7.7.3

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

* Re: [PATCH v2] emacs: Add `notmuch-jump-to-recent-buffer'.
  2011-12-20  8:01 [PATCH v2] emacs: Add `notmuch-jump-to-recent-buffer' David Edmondson
@ 2011-12-20 10:27 ` Tomi Ollila
  2011-12-20 10:36   ` David Edmondson
  2011-12-20 11:48 ` David Bremner
  1 sibling, 1 reply; 4+ messages in thread
From: Tomi Ollila @ 2011-12-20 10:27 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Tue, 20 Dec 2011 08:01:46 +0000, David Edmondson <dme@dme.org> wrote:
> >From a Carl Worth idea: add a function which will select the most
> recently used notmuch buffer (search, show or hello). If no recent
> buffer is found, run `notmuch'.
> 
> It is expected that the user will global bind this command to a key
> sequence.
> ---

Thanks Aaron & David for the explanations. I was finally able to test
and byte compile the function separately (as a learning experiment).

LGTM.

I'd like to know how users are going to use this :)

Tomi

>  emacs/notmuch.el |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 2e9973e..da61aa9 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1055,6 +1055,23 @@ current search results AND that are tagged with the given tag."
>    (interactive)
>    (notmuch-hello))
>  
> +;;;###autoload
> +(defun notmuch-jump-to-recent-buffer ()
> +  "Jump to the most recent notmuch buffer (search, show or hello).
> +
> +If no recent buffer is found, 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)
> +      (notmuch))))
> +
>  (setq mail-user-agent 'notmuch-user-agent)
>  
>  (provide 'notmuch)
> -- 
> 1.7.7.3

Tomi

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

* Re: [PATCH v2] emacs: Add `notmuch-jump-to-recent-buffer'.
  2011-12-20 10:27 ` Tomi Ollila
@ 2011-12-20 10:36   ` David Edmondson
  0 siblings, 0 replies; 4+ messages in thread
From: David Edmondson @ 2011-12-20 10:36 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

On Tue, 20 Dec 2011 12:27:02 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> I'd like to know how users are going to use this :)

I use it as a way to jump back to whatever I was doing before I was
distracted by something in the email I was reading.

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

* Re: [PATCH v2] emacs: Add `notmuch-jump-to-recent-buffer'.
  2011-12-20  8:01 [PATCH v2] emacs: Add `notmuch-jump-to-recent-buffer' David Edmondson
  2011-12-20 10:27 ` Tomi Ollila
@ 2011-12-20 11:48 ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: David Bremner @ 2011-12-20 11:48 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Tue, 20 Dec 2011 08:01:46 +0000, David Edmondson <dme@dme.org> wrote:
> From a Carl Worth idea: add a function which will select the most
> recently used notmuch buffer (search, show or hello). If no recent
> buffer is found, run `notmuch'.

pushed

d

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

end of thread, other threads:[~2011-12-20 11:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-20  8:01 [PATCH v2] emacs: Add `notmuch-jump-to-recent-buffer' David Edmondson
2011-12-20 10:27 ` Tomi Ollila
2011-12-20 10:36   ` David Edmondson
2011-12-20 11:48 ` David Bremner

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).