On Mon, 16 Jan 2012 23:10:27 +0200, Jani Nikula <jani at nikula.org> wrote: > On Mon, 16 Jan 2012 17:46:55 +0100, Pieter Praet <pieter at praet.org> wrote: > > Make `notmuch-cycle-notmuch-buffers' more Lispy and merge into `notmuch', > > eliminating the need to hog yet another keybind. > > What does "merge" mean here? [...]
"One function ought to be enough for anybody." ? :) [1] > [...] Will it still be possible for me to hit one > key to unconditionally get to notmuch-hello, and another to cycle > through the buffers? I wouldn't want to lose that ability. > Sure, but then your new key should be bound to `notmuch' instead of `notmuch-cycle-notmuch-buffers', and the key originally bound to `notmuch' should be remapped to `notmuch-hello'. > > --- > > emacs/notmuch.el | 40 ++++++++++++++-------------------------- > > 1 files changed, 14 insertions(+), 26 deletions(-) > > > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > > index ef4dcc7..539b3a0 100644 > > --- a/emacs/notmuch.el > > +++ b/emacs/notmuch.el > > @@ -1067,7 +1067,20 @@ current search results AND that are tagged with the > > given tag." > > (defun notmuch () > > "Run notmuch and display saved searches, known tags, etc." > > (interactive) > > - (notmuch-hello)) > > + (let* ((old-buffer (current-buffer)) > > + (interesting-buffers > > + (delq nil (mapcar (lambda (b) > > + (if (notmuch-interesting-buffer b) b)) > > + (buffer-list)))) > > + (next-buffer (first > > + (delq nil (mapcar (lambda (b) > > + (unless (eq old-buffer b) b)) > > + interesting-buffers))))) > > + (if next-buffer > > + (progn > > + (switch-to-buffer next-buffer) > > + (bury-buffer old-buffer)) > > + (notmuch-hello)))) > > notmuch-cycle-notmuch-buffers pretty much explains in the name what it > does, but additionally it has documentation, and explanatory > comments. Please don't drop those. > Agreed. Less intrusive patch available [2]. > BR, > Jani > > > > > > > (defun notmuch-interesting-buffer (b) > > "Is the current buffer of interest to a notmuch user?" > > @@ -1078,31 +1091,6 @@ current search results AND that are tagged with the > > given tag." > > message-mode)))) > > > > ;;;###autoload > > -(defun notmuch-cycle-notmuch-buffers () > > - "Cycle through any existing notmuch buffers (search, show or hello). > > - > > -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)) > > - (notmuch)))) > > > > (setq mail-user-agent 'notmuch-user-agent) > > > > -- > > 1.7.8.1 > > > > _______________________________________________ > > notmuch mailing list > > notmuch at notmuchmail.org > > http://notmuchmail.org/mailman/listinfo/notmuch Peace -- Pieter [1] http://www.computerworld.com/s/article/9101699 [2] id:"1326881084-25432-1-git-send-email-pieter at praet.org"