unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Modify kill and exit functions on emacs notmuch mode
@ 2017-06-03 13:00 katsuyuki2388
  2017-06-03 13:00 ` [PATCH 1/2] emacs: retrun to the previous notmuch buffer when exit katsuyuki2388
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: katsuyuki2388 @ 2017-06-03 13:00 UTC (permalink / raw)
  To: notmuch

Hi, I modified kill and exit functions on emacs notmuch mode.
I want to hear your opinion about the change.

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

* [PATCH 1/2] emacs: retrun to the previous notmuch buffer when exit
  2017-06-03 13:00 Modify kill and exit functions on emacs notmuch mode katsuyuki2388
@ 2017-06-03 13:00 ` katsuyuki2388
  2017-06-03 13:00 ` [PATCH 2/2] NEWS: emacs notmuch buffer exit functions are modified katsuyuki2388
  2017-06-04  9:00 ` Modify kill and exit functions on emacs notmuch mode Tomi Ollila
  2 siblings, 0 replies; 6+ messages in thread
From: katsuyuki2388 @ 2017-06-03 13:00 UTC (permalink / raw)
  To: notmuch

From: Kiso Katsuyuki <katsuyuki2388@gmail.com>

When kill and exit from a notmuch mode buffer
(notmuch-show-mode, notmuch-tree-mode,
notmuch-search-mode, notmuch-hello-mode, notmuch-message-mode),
return to the previous notmuch mode buffer. It's because
the previous notmuch buffer is often buried and I have to
select it with a buffer-switching command.
---
 emacs/notmuch-draft.el |  6 ++++--
 emacs/notmuch-lib.el   | 17 +++++++++++++++--
 emacs/notmuch-mua.el   |  7 +++++--
 emacs/notmuch-tree.el  |  6 ++++--
 4 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index fb7f4f55..8717f317 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -214,10 +214,12 @@ applied to newly inserted messages)."
     (set-buffer-modified-p nil)))
 
 (defun notmuch-draft-postpone ()
-  "Save the draft message in the notmuch database and exit buffer."
+  "Save the draft message in the notmuch database, exit buffer,
+and select the previous notmuch buffer."
   (interactive)
   (notmuch-draft-save)
-  (kill-buffer))
+  (kill-buffer)
+  (notmuch-select-previous-notmuch-buffer))
 
 (defun notmuch-draft-resume (id)
   "Resume editing of message with id ID."
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 337b20ac..0371c23f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -260,15 +260,28 @@ depending on the value of `notmuch-poll-script'."
 	  (error "Notmuch: poll script `%s' failed!" notmuch-poll-script)))
     (notmuch-call-notmuch-process "new")))
 
+(defun notmuch-select-previous-notmuch-buffer ()
+  "Select the previous notmuch buffer."
+  (catch 'get-notmuch-buffer
+    (dolist (buffer (buffer-list))
+      (let ((buffer-mode (buffer-local-value 'major-mode buffer)))
+	(when (memq buffer-mode '(notmuch-show-mode
+				  notmuch-tree-mode
+				  notmuch-search-mode
+				  notmuch-hello-mode
+				  notmuch-message-mode))
+	  (throw 'get-notmuch-buffer (switch-to-buffer 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."
+it, in which case it is killed. Then, select the previous notmuch buffer."
   (interactive)
   (if (> (length (get-buffer-window-list nil nil t)) 1)
       (bury-buffer)
-    (kill-buffer)))
+    (kill-buffer))
+  (notmuch-select-previous-notmuch-buffer))
 
 (defun notmuch-documentation-first-line (symbol)
   "Return the first line of the documentation string for SYMBOL."
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 93747b1c..c1d533f7 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -292,6 +292,7 @@ mutiple parts get a header."
 
 (define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
 (define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)
+(define-key notmuch-message-mode-map (kbd "C-c C-k") #'notmuch-mua-kill-buffer)
 (define-key notmuch-message-mode-map (kbd "C-c C-p") #'notmuch-draft-postpone)
 (define-key notmuch-message-mode-map (kbd "C-x C-s") #'notmuch-draft-save)
 
@@ -552,7 +553,8 @@ unencrypted.  Really send? "))))
 
 (defun notmuch-mua-send-and-exit (&optional arg)
   (interactive "P")
-  (notmuch-mua-send-common arg 't))
+  (notmuch-mua-send-common arg 't)
+  (notmuch-select-previous-notmuch-buffer))
 
 (defun notmuch-mua-send (&optional arg)
   (interactive "P")
@@ -560,7 +562,8 @@ unencrypted.  Really send? "))))
 
 (defun notmuch-mua-kill-buffer ()
   (interactive)
-  (message-kill-buffer))
+  (message-kill-buffer)
+  (notmuch-select-previous-notmuch-buffer))
 
 (defun notmuch-mua-message-send-hook ()
   "The default function used for `notmuch-mua-send-hook', this
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index d4d40761..64706397 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -531,10 +531,12 @@ Shows in split pane or whole window according to value of
     (notmuch-tree-next-matching-message)))
 
 (defun notmuch-tree-quit ()
-  "Close the split view or exit tree."
+  "Close the split view or exit tree. When exit from tree, select the
+previous notmuch buffer"
   (interactive)
   (unless (notmuch-tree-close-message-window)
-    (kill-buffer (current-buffer))))
+    (kill-buffer (current-buffer))
+    (notmuch-select-previous-notmuch-buffer)))
 
 (defun notmuch-tree-close-message-window ()
   "Close the message-window. Return t if close succeeds."
-- 
2.12.2

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

* [PATCH 2/2] NEWS: emacs notmuch buffer exit functions are modified
  2017-06-03 13:00 Modify kill and exit functions on emacs notmuch mode katsuyuki2388
  2017-06-03 13:00 ` [PATCH 1/2] emacs: retrun to the previous notmuch buffer when exit katsuyuki2388
@ 2017-06-03 13:00 ` katsuyuki2388
  2017-06-04  9:00 ` Modify kill and exit functions on emacs notmuch mode Tomi Ollila
  2 siblings, 0 replies; 6+ messages in thread
From: katsuyuki2388 @ 2017-06-03 13:00 UTC (permalink / raw)
  To: notmuch

From: Kiso Katsuyuki <katsuyuki2388@gmail.com>

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

diff --git a/NEWS b/NEWS
index 70bce788..af9d5fb8 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,14 @@ Emacs
 
 Fix filename stashing in tree view.
 
+Return to the previous notmuch buffer when kill and exit from a notmuch buffer
+
+  When kill and exit from a notmuch buffer (notmuch-hello-mode,
+  notmuch-search-mode, notmuch-show-mode, notmuch-tree-mode,
+  notmuch-message-mode), the previous notmuch buffer is often buried.
+  So kill and exit functions are modified to return to the previous
+  notmuch buffer.
+
 Notmuch 0.24.1 (2017-04-01)
 ===========================
 
-- 
2.12.2

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

* Re: Modify kill and exit functions on emacs notmuch mode
  2017-06-03 13:00 Modify kill and exit functions on emacs notmuch mode katsuyuki2388
  2017-06-03 13:00 ` [PATCH 1/2] emacs: retrun to the previous notmuch buffer when exit katsuyuki2388
  2017-06-03 13:00 ` [PATCH 2/2] NEWS: emacs notmuch buffer exit functions are modified katsuyuki2388
@ 2017-06-04  9:00 ` Tomi Ollila
  2017-06-04 14:53   ` David Bremner
  2017-06-04 15:37   ` Kiso Katsuyuki
  2 siblings, 2 replies; 6+ messages in thread
From: Tomi Ollila @ 2017-06-04  9:00 UTC (permalink / raw)
  To: katsuyuki2388, notmuch

On Sat, Jun 03 2017, katsuyuki wrote:

> Hi, I modified kill and exit functions on emacs notmuch mode.
> I want to hear your opinion about the change.


Some years ago I had a problem notmuch choosing "strange" buffer when
exiting e.g. mail buffer (and I sent a patch to "fix" that). Eventually
the problem was in my own elisp configurations and after I fixed that
I've had no problems what buffer emacs choose when closing notmuch 
buffers. That doesn't mean that there could still be something to
improve there...

... but as someone(tm) may know, everyone have their own workflow
( https://xkcd.com/1172/ ) in their notmuch usage -- someone may
e.g. start writing email based on arbitrary C code buffer, and
after email send, return to that buffer instead of going to some
other notmuch buffer.

An alternative to this series would be adding a buffer selection
hook variable which anyone can set to bre^H^H^H^improve their
usage.

Tomi

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

* Re: Modify kill and exit functions on emacs notmuch mode
  2017-06-04  9:00 ` Modify kill and exit functions on emacs notmuch mode Tomi Ollila
@ 2017-06-04 14:53   ` David Bremner
  2017-06-04 15:37   ` Kiso Katsuyuki
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2017-06-04 14:53 UTC (permalink / raw)
  To: Tomi Ollila, katsuyuki2388, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

>
> ... but as someone(tm) may know, everyone have their own workflow
> ( https://xkcd.com/1172/ ) in their notmuch usage -- someone may
> e.g. start writing email based on arbitrary C code buffer, and
> after email send, return to that buffer instead of going to some
> other notmuch buffer.
>

Yeah, that was my first thought on seeing this series; that's actually a
pretty typical workflow for me. But I haven't had a chance to test the
series out yet.

d

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

* Re: Modify kill and exit functions on emacs notmuch mode
  2017-06-04  9:00 ` Modify kill and exit functions on emacs notmuch mode Tomi Ollila
  2017-06-04 14:53   ` David Bremner
@ 2017-06-04 15:37   ` Kiso Katsuyuki
  1 sibling, 0 replies; 6+ messages in thread
From: Kiso Katsuyuki @ 2017-06-04 15:37 UTC (permalink / raw)
  To: Tomi Ollila; +Cc: notmuch


> ... but as someone(tm) may know, everyone have their own workflow
> ( https://xkcd.com/1172/ ) in their notmuch usage -- someone may
> e.g. start writing email based on arbitrary C code buffer, and
> after email send, return to that buffer instead of going to some
> other notmuch buffer.

I see. Many people may not feel unusefulness, as you said, and
I misunderstood that the selection priority of asterisk buffers like
"*notmuch-hello*" are lower than file buffers.
The problem seems to be my environmental problem because
there are no difference of priority between asterisk buffers and
file ones by default ('emacs -q').

> An alternative to this series would be adding a buffer selection
> hook variable which anyone can set to bre^H^H^H^improve their
> usage.

I appreciate your advice, but I am satisfied with this change and
will keep this change local now.

Warm Regards,
Kiso

-- 
-----------------------------------------------------------
木曽 勝之 (Katsuyuki Kiso)

mail: katsuyuki2388@gmail.com
-----------------------------------------------------------

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

end of thread, other threads:[~2017-06-04 15:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-03 13:00 Modify kill and exit functions on emacs notmuch mode katsuyuki2388
2017-06-03 13:00 ` [PATCH 1/2] emacs: retrun to the previous notmuch buffer when exit katsuyuki2388
2017-06-03 13:00 ` [PATCH 2/2] NEWS: emacs notmuch buffer exit functions are modified katsuyuki2388
2017-06-04  9:00 ` Modify kill and exit functions on emacs notmuch mode Tomi Ollila
2017-06-04 14:53   ` David Bremner
2017-06-04 15:37   ` Kiso Katsuyuki

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).