unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Add `notmuch-jump-to-recent-buffer'.
@ 2010-11-22 11:51 David Edmondson
  2011-12-19 15:57 ` David Edmondson
  2011-12-20  8:02 ` Tomi Ollila
  0 siblings, 2 replies; 7+ messages in thread
From: David Edmondson @ 2010-11-22 11:51 UTC (permalink / raw)
  To: notmuch

From a Carl Worth idea: Add `notmuch-jump-to-recent-buffer', 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 |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e8d4d98..67271d1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -962,6 +962,24 @@ 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 (progn
+		    (set-buffer buffer)
+		    (or (eq major-mode 'notmuch-show-mode)
+			(eq major-mode 'notmuch-search-mode)
+			(eq major-mode 'notmuch-hello-mode)))
+	       return buffer)))
+    (if last
+	(switch-to-buffer last)
+      (notmuch))))
+
 (setq mail-user-agent 'notmuch-user-agent)
 
 (provide 'notmuch)
-- 
1.7.2.3

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

* Re: [PATCH] emacs: Add `notmuch-jump-to-recent-buffer'.
  2010-11-22 11:51 [PATCH] emacs: Add `notmuch-jump-to-recent-buffer' David Edmondson
@ 2011-12-19 15:57 ` David Edmondson
  2011-12-19 17:58   ` Aaron Ecay
  2011-12-20  8:02 ` Tomi Ollila
  1 sibling, 1 reply; 7+ messages in thread
From: David Edmondson @ 2011-12-19 15:57 UTC (permalink / raw)
  To: notmuch

On Mon, 22 Nov 2010 11:51:04 +0000, David Edmondson <dme@dme.org> wrote:
> From a Carl Worth idea: Add `notmuch-jump-to-recent-buffer', 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.

There was no discussion of this patch. Was it bad?

dme.
-- 
David Edmondson, http://dme.org

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

* Re: [PATCH] emacs: Add `notmuch-jump-to-recent-buffer'.
  2011-12-19 15:57 ` David Edmondson
@ 2011-12-19 17:58   ` Aaron Ecay
  2011-12-20  8:02     ` David Edmondson
  0 siblings, 1 reply; 7+ messages in thread
From: Aaron Ecay @ 2011-12-19 17:58 UTC (permalink / raw)
  To: David Edmondson, notmuch

(Please excuse the lack of inline comments on the patch – the original
patch email is so old that I had deleted it from my archives!)

progn...set-buffer should be with-current-buffer
or...eq...eq... would be cleaner as (memq major-mode '(foo bar baz))

Otherwise, LGTM

-- 
Aaron Ecay

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

* Re: [PATCH] emacs: Add `notmuch-jump-to-recent-buffer'.
  2010-11-22 11:51 [PATCH] emacs: Add `notmuch-jump-to-recent-buffer' David Edmondson
  2011-12-19 15:57 ` David Edmondson
@ 2011-12-20  8:02 ` Tomi Ollila
  2011-12-20  8:12   ` Aaron Ecay
  2011-12-20  8:15   ` David Edmondson
  1 sibling, 2 replies; 7+ messages in thread
From: Tomi Ollila @ 2011-12-20  8:02 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Mon, 22 Nov 2010 11:51:04 +0000, David Edmondson <dme@dme.org> wrote:

> >From a Carl Worth idea: Add `notmuch-jump-to-recent-buffer', 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.
> ---

See comments inline below.

>  emacs/notmuch.el |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index e8d4d98..67271d1 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -962,6 +962,24 @@ 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 (progn

Are the last few lines above working... if without '(' and no
loop (nor for) function in my emacs (where notmuch loaded).

> +		    (set-buffer buffer)

I really like Aaron's comment about with-current-buffer...

> +		    (or (eq major-mode 'notmuch-show-mode)
> +			(eq major-mode 'notmuch-search-mode)
> +			(eq major-mode 'notmuch-hello-mode)))

... memq is also nice; in case used the list should be done beforehand with
(let* ...

> +	       return buffer)))
> +    (if last
> +	(switch-to-buffer last)
> +      (notmuch))))
> +
>  (setq mail-user-agent 'notmuch-user-agent)
>  
>  (provide 'notmuch)
> -- 
> 1.7.2.3
> 

Tomi 

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

* Re: [PATCH] emacs: Add `notmuch-jump-to-recent-buffer'.
  2011-12-19 17:58   ` Aaron Ecay
@ 2011-12-20  8:02     ` David Edmondson
  0 siblings, 0 replies; 7+ messages in thread
From: David Edmondson @ 2011-12-20  8:02 UTC (permalink / raw)
  To: Aaron Ecay, notmuch

On Mon, 19 Dec 2011 12:58:53 -0500, Aaron Ecay <aaronecay@gmail.com> wrote:
> (Please excuse the lack of inline comments on the patch – the original
> patch email is so old that I had deleted it from my archives!)

You _deleted_ things? /me faints.

> progn...set-buffer should be with-current-buffer
> or...eq...eq... would be cleaner as (memq major-mode '(foo bar baz))

Good comments, thanks. Updated patch sent.

dme.
-- 
David Edmondson, http://dme.org

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

* Re: [PATCH] emacs: Add `notmuch-jump-to-recent-buffer'.
  2011-12-20  8:02 ` Tomi Ollila
@ 2011-12-20  8:12   ` Aaron Ecay
  2011-12-20  8:15   ` David Edmondson
  1 sibling, 0 replies; 7+ messages in thread
From: Aaron Ecay @ 2011-12-20  8:12 UTC (permalink / raw)
  To: Tomi Ollila, David Edmondson, notmuch

Tomi,

On Tue, 20 Dec 2011 10:02:11 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> 
> Are the last few lines above working... if without '(' and no
> loop (nor for) function in my emacs (where notmuch loaded).

This is the `loop' macro from cl.el.  It mimics a Common Lisp idiom
which, strangely enough, looks nothing like Lisp but is sort of a DSL
for specifying imperative loops.  You can find the documentation by
doing C-h i (to open the Info manual in Emacs) then following the “CL”
link.

(One of the coolest features is that it is all implemented via macros,
so the compiler automatically unrolls it into a native Lisp loop.  Thus
the performance hit, if any, is negligible.)

> 
> ... memq is also nice; in case used the list should be done beforehand with
> (let* ...

Given the fact about loop, let* isn’t really applicable.

-- 
Aaron Ecay

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

* Re: [PATCH] emacs: Add `notmuch-jump-to-recent-buffer'.
  2011-12-20  8:02 ` Tomi Ollila
  2011-12-20  8:12   ` Aaron Ecay
@ 2011-12-20  8:15   ` David Edmondson
  1 sibling, 0 replies; 7+ messages in thread
From: David Edmondson @ 2011-12-20  8:15 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

On Tue, 20 Dec 2011 10:02:11 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> > +	 (loop for buffer in (buffer-list)
> > +	       if (progn
> 
> Are the last few lines above working... if without '(' and no
> loop (nor for) function in my emacs (where notmuch loaded).

`loop' is an emacs clone of the all singing ("It slices, it dices!")
Common Lisp `loop' macro in cl-macs.el.

dme.
-- 
David Edmondson, http://dme.org

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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-22 11:51 [PATCH] emacs: Add `notmuch-jump-to-recent-buffer' David Edmondson
2011-12-19 15:57 ` David Edmondson
2011-12-19 17:58   ` Aaron Ecay
2011-12-20  8:02     ` David Edmondson
2011-12-20  8:02 ` Tomi Ollila
2011-12-20  8:12   ` Aaron Ecay
2011-12-20  8:15   ` 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).