unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Pieter Praet <pieter@praet.org>
To: David Edmondson <dme@dme.org>
Cc: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [RFC] [PATCH v3] emacs: rewrite `notmuch-cycle-notmuch-buffers'
Date: Wed, 18 Jan 2012 11:04:44 +0100	[thread overview]
Message-ID: <1326881084-25432-1-git-send-email-pieter@praet.org> (raw)
In-Reply-To: <87fwfd8h0i.fsf@praet.org>

Get rid of the compile-time `cl' requirement for this particular function.

---
 emacs/notmuch.el |   40 ++++++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ef4dcc7..2426c0a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1084,24 +1084,28 @@ current search results AND that are tagged with the given tag."
 If the current buffer is the only notmuch buffer, bury it. If no
 notmuch buffers exist, run `notmuch'."
   (interactive)
-
-  (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))
+  (let* ((old-buffer (current-buffer))
+	 (next-buffer (first
+	  ;; Find interesting buffers:
+	  ;; Loop over all existing buffers and return those that
+	  ;; satisfy the predicate (`notmuch-interesting-buffer' and
+	  ;; not `eq' to current buffer) integrally;  All others are
+	  ;; replaced with `nil'.  Then strip out all `nil's using
+	  ;; `delq'.  Basically a re-implementation of `cl' package's
+	  ;; `delete-if-not'.
+	  (delq nil
+	   (mapcar (lambda (b)
+		     (and (notmuch-interesting-buffer b)
+			  (not (eq old-buffer b))
+			  b))
+		   (buffer-list))))))
+
+    ;; If there's a next buffer, switch to it and bury the
+    ;; original current buffer.  Otherwise run `notmuch-hello'.
+    (if next-buffer
+    	(progn
+    	  (switch-to-buffer next-buffer)
+    	  (bury-buffer old-buffer))
       (notmuch))))
 
 (setq mail-user-agent 'notmuch-user-agent)
-- 
1.7.8.1

  reply	other threads:[~2012-01-18 10:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-27 10:50 [PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last David Edmondson
2011-12-27 11:02 ` David Edmondson
2011-12-27 19:23 ` Jani Nikula
2011-12-28  8:20   ` David Edmondson
2011-12-28  8:29 ` [PATCH v2] " David Edmondson
2012-01-10 16:55   ` David Edmondson
2012-01-10 20:15     ` Jani Nikula
2012-01-14  9:32       ` Pieter Praet
2012-01-14  9:29   ` Pieter Praet
2012-01-15 11:55     ` David Edmondson
2012-01-16  3:01       ` Austin Clements
2012-01-16  8:43         ` David Edmondson
2012-01-16 10:42           ` [PATCH] [RFC] emacs: merge overhauled `notmuch-cycle-notmuch-buffers' into `notmuch' Pieter Praet
2012-01-16 11:06             ` David Edmondson
2012-01-16 11:28               ` Pieter Praet
2012-01-16 11:32                 ` Pieter Praet
2012-01-16 11:47                 ` David Edmondson
2012-01-16 16:45                   ` Pieter Praet
2012-01-16 16:46                     ` [PATCH] v2 " Pieter Praet
2012-01-16 17:03                       ` David Edmondson
2012-01-18 10:03                         ` Pieter Praet
2012-01-18 10:04                           ` Pieter Praet [this message]
2012-01-18 10:13                           ` David Edmondson
2012-01-18 12:15                             ` Pieter Praet
2012-01-18 12:57                               ` David Edmondson
     [not found]                                 ` <cunboq1mad1.fsf@hotblack-desiato.hh.sledj.net>
2012-01-18 13:48                                   ` Pieter Praet
2012-01-18 22:18                                     ` Aaron Ecay
2012-01-19  0:48                                       ` Austin Clements
2012-01-19  8:19                                       ` David Edmondson
2012-01-19 19:13                                       ` Pieter Praet
2012-01-16 21:10                       ` Jani Nikula
2012-01-18 10:07                         ` Pieter Praet
2012-01-16  2:45   ` [PATCH v2] emacs: Cycle through notmuch buffers rather than jumping to the last David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1326881084-25432-1-git-send-email-pieter@praet.org \
    --to=pieter@praet.org \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).