unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Cc: Tomi Ollila <tomi.ollila@iki.fi>
Subject: [PATCH 1/2] emacs: add show view bindings to move to previous/next thread
Date: Sat, 25 May 2013 15:14:25 +0300	[thread overview]
Message-ID: <1369484066-20228-1-git-send-email-jani@nikula.org> (raw)

We have most of the plumbing in place, add the bindings M-n and M-p.

---

v2: reduce duplication by adding PREVIOUS argument to
    notmuch-show-next-thread instead of adding a separate function for
    moving to previous thread (Mark)
---
 emacs/notmuch-show.el |   28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d56154e..a903395 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -39,6 +39,7 @@
 
 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
 (declare-function notmuch-search-next-thread "notmuch" nil)
+(declare-function notmuch-search-previous-thread "notmuch" nil)
 (declare-function notmuch-search-show-thread "notmuch" nil)
 
 (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date")
@@ -1273,6 +1274,8 @@ reset based on the original query."
 	(define-key map "P" 'notmuch-show-previous-message)
 	(define-key map "n" 'notmuch-show-next-open-message)
 	(define-key map "p" 'notmuch-show-previous-open-message)
+	(define-key map (kbd "M-n") 'notmuch-show-next-thread-show)
+	(define-key map (kbd "M-p") 'notmuch-show-previous-thread-show)
 	(define-key map (kbd "DEL") 'notmuch-show-rewind)
 	(define-key map " " 'notmuch-show-advance-and-archive)
 	(define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
@@ -1834,17 +1837,34 @@ argument, hide all of the messages."
   (interactive)
   (backward-button 1))
 
-(defun notmuch-show-next-thread (&optional show-next)
-  "Move to the next item in the search results, if any."
+(defun notmuch-show-next-thread (&optional show previous)
+  "Move to the next item in the search results, if any.
+
+If SHOW is non-nil, open the next item in a show
+buffer. Otherwise just highlight the next item in the search
+buffer. If PREVIOUS is non-nil, move to the previous item in the
+search results instead."
   (interactive "P")
   (let ((parent-buffer notmuch-show-parent-buffer))
     (notmuch-kill-this-buffer)
     (when (buffer-live-p parent-buffer)
       (switch-to-buffer parent-buffer)
-      (notmuch-search-next-thread)
-      (if show-next
+      (if previous
+	  (notmuch-search-previous-thread)
+	(notmuch-search-next-thread))
+      (if show
 	  (notmuch-search-show-thread)))))
 
+(defun notmuch-show-next-thread-show ()
+  "Show the next thread in the search results, if any."
+  (interactive)
+  (notmuch-show-next-thread t))
+
+(defun notmuch-show-previous-thread-show ()
+  "Show the previous thread in the search results, if any."
+  (interactive)
+  (notmuch-show-next-thread t t))
+
 (defun notmuch-show-archive-thread (&optional unarchive)
   "Archive each message in thread.
 
-- 
1.7.10.4

             reply	other threads:[~2013-05-25 12:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-25 12:14 Jani Nikula [this message]
2013-05-25 12:14 ` [PATCH 2/2] TODO: keybindings for next/previous thread done Jani Nikula
2013-06-01  1:05   ` David Bremner
2013-05-25 13:39 ` [PATCH 1/2] emacs: add show view bindings to move to previous/next thread Mark Walters
2013-05-25 18:08   ` Jani Nikula
2013-05-25 21:13 ` [PATCH] " Mark Walters
2013-05-26 23:36   ` 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=1369484066-20228-1-git-send-email-jani@nikula.org \
    --to=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /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).