unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: rebind the "Send Message" toolbar/menu items
@ 2021-05-30 10:28 edef
  2021-05-31 23:21 ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: edef @ 2021-05-30 10:28 UTC (permalink / raw)
  To: notmuch; +Cc: edef

All three of C-c C-c, <menu-bar> <Message> <Send Message>,
and <tool-bar> <Send Message> are bound to message-send-and-exit by
message.el, but notmuch-mua.el only overrides the first.

This mostly manifests as confusing Fcc behaviour for GUI users.
---
 emacs/notmuch-mua.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index bbf059a2..86a15f53 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -341,6 +341,8 @@ Typically this is added to `notmuch-mua-send-hook'."
 
 (defvar notmuch-message-mode-map
   (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "<menu-bar> <Message> <Send Message>") #'notmuch-mua-send-and-exit)
+    (define-key map (kbd "<tool-bar> <Send Message>") #'notmuch-mua-send-and-exit)
     (define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
     (define-key map (kbd "C-c C-s") #'notmuch-mua-send)
     (define-key map (kbd "C-c C-p") #'notmuch-draft-postpone)
-- 
2.31.1

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

* Re: [PATCH] emacs: rebind the "Send Message" toolbar/menu items
  2021-05-30 10:28 [PATCH] emacs: rebind the "Send Message" toolbar/menu items edef
@ 2021-05-31 23:21 ` David Bremner
  2021-06-01  6:15   ` [PATCH] emacs: remap send-message and send-message-and-exit edef
  0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2021-05-31 23:21 UTC (permalink / raw)
  To: edef, notmuch; +Cc: edef

edef <edef@edef.eu> writes:

> All three of C-c C-c, <menu-bar> <Message> <Send Message>,
> and <tool-bar> <Send Message> are bound to message-send-and-exit by
> message.el, but notmuch-mua.el only overrides the first.
>
> This mostly manifests as confusing Fcc behaviour for GUI users.

The idea seems reasonable, but after I apply your patch I don't have a
<Send Message> entry in the <Message> menu. I'm not sure what's going
on, I've only tested with Emacs 27.1 on Debian.

d

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

* [PATCH] emacs: remap send-message and send-message-and-exit
  2021-05-31 23:21 ` David Bremner
@ 2021-06-01  6:15   ` edef
  2021-06-02 19:03     ` Tomi Ollila
  0 siblings, 1 reply; 8+ messages in thread
From: edef @ 2021-06-01  6:15 UTC (permalink / raw)
  To: notmuch, david; +Cc: edef

All three of C-c C-c, <menu-bar> <Message> <Send Message>,
and <tool-bar> <Send Message> are bound to message-send-and-exit by
message.el, but notmuch-mua.el only had an explicit override for the
keyboard binding. This mostly manifests as confusing Fcc behaviour for
GUI users.

Patching the bindings for specific keys is rather brittle, since it has
to be aware of every relevant binding. This patch switches to instead
using a remap binding, which turns any binding for message-send or
message-send-and-exit into a binding for the corresponding notmuch-mua
command.
---
The previous patch managed to *disappear* the menu item, but while
figuring out how to make that work correctly, I happened upon a much
simpler and less brittle solution.

 emacs/notmuch-mua.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index bbf059a2..8572aa1b 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -341,8 +341,8 @@ Typically this is added to `notmuch-mua-send-hook'."
 
 (defvar notmuch-message-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
-    (define-key map (kbd "C-c C-s") #'notmuch-mua-send)
+    (define-key map [remap message-send-and-exit] 'notmuch-mua-send-and-exit)
+    (define-key map [remap message-send] 'notmuch-mua-send)
     (define-key map (kbd "C-c C-p") #'notmuch-draft-postpone)
     (define-key map (kbd "C-x C-s") #'notmuch-draft-save)
     map)
-- 
2.31.1

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

* Re: [PATCH] emacs: remap send-message and send-message-and-exit
  2021-06-01  6:15   ` [PATCH] emacs: remap send-message and send-message-and-exit edef
@ 2021-06-02 19:03     ` Tomi Ollila
  2021-06-04 16:50       ` edef
  0 siblings, 1 reply; 8+ messages in thread
From: Tomi Ollila @ 2021-06-02 19:03 UTC (permalink / raw)
  To: edef, notmuch, david; +Cc: edef

On Tue, Jun 01 2021, edef@edef.eu wrote:

> All three of C-c C-c, <menu-bar> <Message> <Send Message>,
> and <tool-bar> <Send Message> are bound to message-send-and-exit by
> message.el, but notmuch-mua.el only had an explicit override for the
> keyboard binding. This mostly manifests as confusing Fcc behaviour for
> GUI users.
>
> Patching the bindings for specific keys is rather brittle, since it has
> to be aware of every relevant binding. This patch switches to instead

After committed to repo this is no longer 'patch'. Simple change
is to use 'commit', 'change', 'changeset' -- alternative is not
to write 'This ...' but reword...

> using a remap binding, which turns any binding for message-send or
> message-send-and-exit into a binding for the corresponding notmuch-mua
> command.
> ---
> The previous patch managed to *disappear* the menu item, but while
> figuring out how to make that work correctly, I happened upon a much
> simpler and less brittle solution.
>
>  emacs/notmuch-mua.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index bbf059a2..8572aa1b 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -341,8 +341,8 @@ Typically this is added to `notmuch-mua-send-hook'."
>  
>  (defvar notmuch-message-mode-map
>    (let ((map (make-sparse-keymap)))
> -    (define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
> -    (define-key map (kbd "C-c C-s") #'notmuch-mua-send)
> +    (define-key map [remap message-send-and-exit] 'notmuch-mua-send-and-exit)
> +    (define-key map [remap message-send] 'notmuch-mua-send)

where did the # characters disappear here ?

afaic #' is the recommended way here...

>      (define-key map (kbd "C-c C-p") #'notmuch-draft-postpone)
>      (define-key map (kbd "C-x C-s") #'notmuch-draft-save)
>      map)
> -- 
> 2.31.1

Tomi

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

* Re: [PATCH] emacs: remap send-message and send-message-and-exit
  2021-06-02 19:03     ` Tomi Ollila
@ 2021-06-04 16:50       ` edef
  2021-06-07 16:09         ` Tomi Ollila
  0 siblings, 1 reply; 8+ messages in thread
From: edef @ 2021-06-04 16:50 UTC (permalink / raw)
  To: Tomi Ollila; +Cc: notmuch

> >  (defvar notmuch-message-mode-map
> >    (let ((map (make-sparse-keymap)))
> > -    (define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
> > -    (define-key map (kbd "C-c C-s") #'notmuch-mua-send)
> > +    (define-key map [remap message-send-and-exit] 'notmuch-mua-send-and-exit)
> > +    (define-key map [remap message-send] 'notmuch-mua-send)
> 
> where did the # characters disappear here ?
> 
> afaic #' is the recommended way here...
I'm not sure where to find that recommendation — the Emacs manual and
information I've found in the wild don't use it for define-key.

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

* Re: [PATCH] emacs: remap send-message and send-message-and-exit
  2021-06-04 16:50       ` edef
@ 2021-06-07 16:09         ` Tomi Ollila
  2021-06-13  8:23           ` [PATCH v2] " edef
  0 siblings, 1 reply; 8+ messages in thread
From: Tomi Ollila @ 2021-06-07 16:09 UTC (permalink / raw)
  To: edef; +Cc: notmuch

On Fri, Jun 04 2021, edef@edef.eu wrote:

>> >  (defvar notmuch-message-mode-map
>> >    (let ((map (make-sparse-keymap)))
>> > -    (define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
>> > -    (define-key map (kbd "C-c C-s") #'notmuch-mua-send)
>> > +    (define-key map [remap message-send-and-exit] 'notmuch-mua-send-and-exit)
>> > +    (define-key map [remap message-send] 'notmuch-mua-send)
>> 
>> where did the # characters disappear here ?
>> 
>> afaic #' is the recommended way here...

> I'm not sure where to find that recommendation — the Emacs manual and
> information I've found in the wild don't use it for define-key.

In this particular case, around the change #' is used, 
and in change ' is used.

(in some other parts in notmuch elisp source there is only ' used
-- consistency -- in one way or another, would be nice...)

emacs sharp quote   can be used in internet searches to find more info,

then, in

http://www.gnu.org/software/emacs/manual/html_node/elisp/Anonymous-Functions.html


  Special Form: function function-object

      This special form returns function-object without evaluating it. In
      this, it is similar to quote (see Quoting). But unlike quote, it also
      serves as a note to the Emacs evaluator and byte-compiler that
      function-object is intended to be used as a function. Assuming
      function-object is a valid lambda expression, this has two effects:

          When the code is byte-compiled, function-object is compiled into a
          byte-code function object (see Byte Compilation).
          When lexical binding is enabled, function-object is converted into
          a closure. See Closures. 

      When function-object is a symbol and the code is byte compiled, the
      byte-compiler will warn if that function is not defined or might not be
      known at run time. 

  The read syntax #' is a short-hand for using function. 

Tomi

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

* [PATCH v2] emacs: remap send-message and send-message-and-exit
  2021-06-07 16:09         ` Tomi Ollila
@ 2021-06-13  8:23           ` edef
  2021-06-27 17:25             ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: edef @ 2021-06-13  8:23 UTC (permalink / raw)
  To: notmuch; +Cc: edef

All three of C-c C-c, <menu-bar> <Message> <Send Message>,
and <tool-bar> <Send Message> are bound to message-send-and-exit by
message.el, but notmuch-mua.el only had an explicit override for the
keyboard binding. This mostly manifests as confusing Fcc behaviour for
GUI users.

Patching the bindings for specific keys is rather brittle, since it has
to be aware of every relevant binding. This change switches to instead
using a remap binding, which turns any binding for message-send or
message-send-and-exit into a binding for the corresponding notmuch-mua
command.
---
Fixed up the nits reported by Tomi Ollila.

 emacs/notmuch-mua.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index bbf059a2..17954fb3 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -341,8 +341,8 @@ Typically this is added to `notmuch-mua-send-hook'."
 
 (defvar notmuch-message-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
-    (define-key map (kbd "C-c C-s") #'notmuch-mua-send)
+    (define-key map [remap message-send-and-exit] #'notmuch-mua-send-and-exit)
+    (define-key map [remap message-send] #'notmuch-mua-send)
     (define-key map (kbd "C-c C-p") #'notmuch-draft-postpone)
     (define-key map (kbd "C-x C-s") #'notmuch-draft-save)
     map)
-- 
2.31.1

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

* Re: [PATCH v2] emacs: remap send-message and send-message-and-exit
  2021-06-13  8:23           ` [PATCH v2] " edef
@ 2021-06-27 17:25             ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2021-06-27 17:25 UTC (permalink / raw)
  To: edef, notmuch; +Cc: edef

edef <edef@edef.eu> writes:

> All three of C-c C-c, <menu-bar> <Message> <Send Message>,
> and <tool-bar> <Send Message> are bound to message-send-and-exit by
> message.el, but notmuch-mua.el only had an explicit override for the
> keyboard binding. This mostly manifests as confusing Fcc behaviour for
> GUI users.
>
> Patching the bindings for specific keys is rather brittle, since it has
> to be aware of every relevant binding. This change switches to instead
> using a remap binding, which turns any binding for message-send or
> message-send-and-exit into a binding for the corresponding notmuch-mua
> command.
> ---
> Fixed up the nits reported by Tomi Ollila.

applied to master, thanks

d

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

end of thread, other threads:[~2021-06-27 17:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-30 10:28 [PATCH] emacs: rebind the "Send Message" toolbar/menu items edef
2021-05-31 23:21 ` David Bremner
2021-06-01  6:15   ` [PATCH] emacs: remap send-message and send-message-and-exit edef
2021-06-02 19:03     ` Tomi Ollila
2021-06-04 16:50       ` edef
2021-06-07 16:09         ` Tomi Ollila
2021-06-13  8:23           ` [PATCH v2] " edef
2021-06-27 17:25             ` 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).