unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2] emacs: Improve the behaviour of the 'q' binding.
@ 2014-10-29 14:18 David Edmondson
  2014-10-29 14:18 ` David Edmondson
  0 siblings, 1 reply; 5+ messages in thread
From: David Edmondson @ 2014-10-29 14:18 UTC (permalink / raw)
  To: notmuch


emacs: Improve the behaviour of the 'q' binding.

When a user hits 'q' in a notmuch buffer, kill the buffer only if
there are no other windows currently showing it.

v2:
- Change the name of `notmuch-kill-this-buffer' to be clearer.


David Edmondson (1):
  emacs: Improve the behaviour of the 'q' binding.

 emacs/notmuch-lib.el  | 13 +++++++++----
 emacs/notmuch-show.el |  2 +-
 emacs/notmuch-tree.el |  2 +-
 emacs/notmuch.el      |  4 ++--
 4 files changed, 13 insertions(+), 8 deletions(-)

-- 
2.1.1

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

* [PATCH v2] emacs: Improve the behaviour of the 'q' binding.
  2014-10-29 14:18 [PATCH v2] emacs: Improve the behaviour of the 'q' binding David Edmondson
@ 2014-10-29 14:18 ` David Edmondson
  2014-10-31 16:56   ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: David Edmondson @ 2014-10-29 14:18 UTC (permalink / raw)
  To: notmuch

When a user hits 'q' in a notmuch buffer, kill the buffer only if
there are no other windows currently showing it.
---
 emacs/notmuch-lib.el  | 13 +++++++++----
 emacs/notmuch-show.el |  2 +-
 emacs/notmuch-tree.el |  2 +-
 emacs/notmuch.el      |  4 ++--
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 1e166c6..fd25f7c 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -135,7 +135,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
 (defvar notmuch-common-keymap
   (let ((map (make-sparse-keymap)))
     (define-key map "?" 'notmuch-help)
-    (define-key map "q" 'notmuch-kill-this-buffer)
+    (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
     (define-key map "s" 'notmuch-search)
     (define-key map "z" 'notmuch-tree)
     (define-key map "m" 'notmuch-mua-new-mail)
@@ -239,10 +239,15 @@ depending on the value of `notmuch-poll-script'."
 	(call-process notmuch-poll-script nil nil))
     (call-process notmuch-command nil nil nil "new")))
 
-(defun notmuch-kill-this-buffer ()
-  "Kill the current buffer."
+(defun notmuch-bury-or-kill-this-buffer ()
+  "Undisplay the current buffer.
+
+Bury the current buffer, unless there is only one window showing
+it, in which case it is killed."
   (interactive)
-  (kill-buffer (current-buffer)))
+  (if (> (length (get-buffer-window-list nil nil t)) 1)
+      (bury-buffer)
+    (kill-buffer)))
 
 (defun notmuch-documentation-first-line (symbol)
   "Return the first line of the documentation string for SYMBOL."
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index a997482..6e03f1e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1956,7 +1956,7 @@ 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)
+    (notmuch-bury-or-kill-this-buffer)
     (when (buffer-live-p parent-buffer)
       (switch-to-buffer parent-buffer)
       (and (if previous
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e859cc2..8b6cd51 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -234,7 +234,7 @@ FUNC."
     ;; Override because we want to close message pane first.
     (define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and #'notmuch-help))
     ;; Override because we first close message pane and then close tree buffer.
-    (define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit)
+    (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
     ;; Override because we close message pane after the search query is entered.
     (define-key map [remap notmuch-search] 'notmuch-tree-to-search)
     ;; Override because we want to close message pane first.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index b44a907..218486a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -153,7 +153,7 @@ there will be called at other points of notmuch execution."
 (defvar notmuch-search-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map notmuch-common-keymap)
-    (define-key map "x" 'notmuch-kill-this-buffer)
+    (define-key map "x" 'notmuch-bury-or-kill-this-buffer)
     (define-key map (kbd "<DEL>") 'notmuch-search-scroll-down)
     (define-key map "b" 'notmuch-search-scroll-down)
     (define-key map " " 'notmuch-search-scroll-up)
@@ -961,7 +961,7 @@ same relative position within the new buffer."
 	(oldest-first notmuch-search-oldest-first)
 	(target-thread (notmuch-search-find-thread-id 'bare))
 	(query notmuch-search-query-string))
-    (notmuch-kill-this-buffer)
+    (notmuch-bury-or-kill-this-buffer)
     (notmuch-search query oldest-first target-thread target-line)
     (goto-char (point-min))))
 
-- 
2.1.1

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

* Re: [PATCH v2] emacs: Improve the behaviour of the 'q' binding.
  2014-10-29 14:18 ` David Edmondson
@ 2014-10-31 16:56   ` David Bremner
  2014-10-31 17:24     ` [PATCH v1] NEWS: Improved `q` binding David Edmondson
  0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2014-10-31 16:56 UTC (permalink / raw)
  To: David Edmondson, notmuch

David Edmondson <dme@dme.org> writes:

> When a user hits 'q' in a notmuch buffer, kill the buffer only if
> there are no other windows currently showing it.

pushed. That probably deserves a NEWS patch.

d

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

* [PATCH v1] NEWS: Improved `q` binding.
  2014-10-31 16:56   ` David Bremner
@ 2014-10-31 17:24     ` David Edmondson
  2014-11-01  7:14       ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: David Edmondson @ 2014-10-31 17:24 UTC (permalink / raw)
  To: notmuch

---
 NEWS | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index 4718838..723bca0 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,12 @@ Expanded default saved search settings
   The default saved searches now include several more common searches,
   as well as shortcut keys for `notmuch-jump`.
 
+Improved `q` binding in notmuch buffers
+
+  `q` will now bury rather than kill a notmuch search, show or tree
+  buffer if there are multiple windows showing the buffer. If only a
+  single window is showing the buffer, it is killed.
+
 Library changes
 ---------------
 
-- 
1.9.3 (Apple Git-50)

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

* Re: [PATCH v1] NEWS: Improved `q` binding.
  2014-10-31 17:24     ` [PATCH v1] NEWS: Improved `q` binding David Edmondson
@ 2014-11-01  7:14       ` David Bremner
  0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2014-11-01  7:14 UTC (permalink / raw)
  To: David Edmondson, notmuch

David Edmondson <dme@dme.org> writes:

> ---
>  NEWS | 6 ++++++
>  1 file changed, 6 insertions(+)
>

applied, with thanks

d

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

end of thread, other threads:[~2014-11-01  7:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-29 14:18 [PATCH v2] emacs: Improve the behaviour of the 'q' binding David Edmondson
2014-10-29 14:18 ` David Edmondson
2014-10-31 16:56   ` David Bremner
2014-10-31 17:24     ` [PATCH v1] NEWS: Improved `q` binding David Edmondson
2014-11-01  7:14       ` 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).