Re: [PATCH 26/27] emacs: avoid binding unnamed commands in keymaps

2023-10-29 Thread David Bremner
Ryan Tate  writes:

> Jonas Bernoulli  writes:
>
>> - -(defun notmuch-tree-close-message-pane-and (func) -  "Close 
>> message pane and execute FUNC. 
>
> I am confused why a function used in config files and documented 
> on the notmuch website (to this moment) as an example of how to 
> configure something would be removed, and to be removed without 
> any announcement.

We try our best to minimize the amount of breaking changes (and to
announce them when they happen), but sometimes things slip through. BTW
notmuchmail.org is mostly a wiki, and we rely on the user community to
update it. If you would like to help with that (e.g. to mark those
snippets as broken), see

https://notmuchmail.org/wikiwriteaccess/

> I argue that a user (who is not literally an author of notmuch)
> should be able to reliably use the software, which involves configuring
> it and having that configuration continue to work. 

Sure, that the intention. This is somewhat challenging with the emacs UI
as it exists, since the line between API that people can rely on and
internals is not well drawn in the older code. The changes under
discussion actually make that a bit better by marking some macros as
internal.

As far as your specific technical issue, I guess you can recover the
deleted functions and put them (possibly renamed) in your init.el.

Since you are using Debian, you might be interested in using notmuch
from stable backports; this would mean you will not see several years of
changes all at once.  It's a personal thing whether you prefer more
smaller disruptions over fewer larger ones.
___
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]


Re: [PATCH 26/27] emacs: avoid binding unnamed commands in keymaps

2023-10-28 Thread Ryan Tate

> On Oct 28, 2023, at 5:32 AM, Michael J Gruber 
> 

> Maybe you can help us by rephrasing your complaints into suggestions for 
> documentation updates, and thus help others getting less confused?


I’ve updated the documentation before when I discovered changes after the fact, 
in coordination with this list. I think in cases where the developers here 
don’t want to do that others might be again willing to help. But it would 
really help if breaking changes were prominently flagged. 

That said, it’s a small group of volunteers, and I’m not sure avoiding breakage 
or taking the time to notice breaking changes and send emails to this list is a 
priority. Totally fine and as I’ve expressed before on this list you all have 
my eternal gratitude for your work. It’s just a culture thing. I felt the need 
to express what it feels like on the other side but I won’t in the future. 
Cheers. 
___
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]


Re: [PATCH 26/27] emacs: avoid binding unnamed commands in keymaps

2023-10-28 Thread Michael J Gruber
Am Sa., 28. Okt. 2023 um 06:22 Uhr schrieb Ryan Tate :

>
> Jonas Bernoulli  writes:
>
> > - -(defun notmuch-tree-close-message-pane-and (func) -  "Close
> > message pane and execute FUNC.
>
> I am confused why a function used in config files and documented
> on the notmuch website (to this moment) as an example of how to
> configure something would be removed, and to be removed without
> any announcement.
>
> I argue that a user (who is not literally an author of notmuch)
> should be able to reliably use the software, which involves configuring
> it and having that configuration continue to work. It's not like it was
> remotely easy getting that config setup in the first place.
> ___
>

With all due respect, I suggest you try to (re-)read your posts again
through the eyes of a notmuch author or contributor, for a change of
perspective. Do you still consider your tone appropriate?

Bug reports and constructive suggestions are always welcome here. In fact,
I experienced the notmuch community as absolutely welcoming and zero-drama.
Let's keep it that way. Maybe you can help us by rephrasing your complaints
into suggestions for documentation updates, and thus help others getting
less confused?

Michael
___
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]


Re: [PATCH 26/27] emacs: avoid binding unnamed commands in keymaps

2023-10-27 Thread Ryan Tate



Jonas Bernoulli  writes:

- -(defun notmuch-tree-close-message-pane-and (func) -  "Close 
message pane and execute FUNC. 


I am confused why a function used in config files and documented 
on the notmuch website (to this moment) as an example of how to 
configure something would be removed, and to be removed without 
any announcement.


I argue that a user (who is not literally an author of notmuch)
should be able to reliably use the software, which involves configuring
it and having that configuration continue to work. It's not like it was
remotely easy getting that config setup in the first place. 
___

notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]


[PATCH 26/27] emacs: avoid binding unnamed commands in keymaps

2020-11-08 Thread Jonas Bernoulli
One should never bind unnamed commands in keymaps because doing that
makes it needlessly hard for users to change these bindings.

Replace such anonymous bindings with named commands that are generated
using macros and some boilerplate. Using macros is better than using a
simple loop because that makes it possible for `find-function' to find
the definitions. Eat your boilerplate--it forms character.

Admittedly this approach is quite ugly and it might be better to teach
the original commands to support different buffers directly instead of
requiring wrapper commands to do just that.

Never-the-less as a short-term solution this is better than what we
had before.
---
 emacs/notmuch-tree.el | 126 --
 1 file changed, 72 insertions(+), 54 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 7cc28b62..17863f6a 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -238,57 +238,83 @@ (defvar-local notmuch-tree-message-buffer nil
 if the user has loaded a different buffer in that window.")
 (put 'notmuch-tree-message-buffer 'permanent-local t)
 
-(defun notmuch-tree-to-message-pane (func)
-  "Execute FUNC in message pane.
-
-This function returns a function (so can be used as a keybinding)
-which executes function FUNC in the message pane if it is
-open (if the message pane is closed it does nothing)."
-  `(lambda ()
- ,(concat "(In message pane) " (documentation func t))
+(defmacro notmuch-tree--define-do-in-message-window (name cmd)
+  "Define NAME as a command that calls CMD interactively in the message window.
+If the message pane is closed then this command does nothing.
+Avoid using this macro in new code; it will be removed."
+  `(defun ,name ()
+ ,(concat "(In message window) " (documentation cmd t))
  (interactive)
  (when (window-live-p notmuch-tree-message-window)
(with-selected-window notmuch-tree-message-window
-(call-interactively #',func)
-
-(defun notmuch-tree-inherit-from-message-pane (sym)
-  "Return value of SYM in message-pane if open, or tree-pane if not."
+(call-interactively #',cmd)
+
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-previous-message-button
+ notmuch-show-previous-button)
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-next-message-button
+ notmuch-show-next-button)
+(notmuch-tree--define-do-in-message-window
+ notmuch-tree-toggle-message-process-crypto
+ notmuch-show-toggle-process-crypto)
+
+(defun notmuch-tree--message-process-crypto ()
+  "Return value of `notmuch-show-process-crypto' in the message window.
+If that window isn't alive, then return the current value.
+Avoid using this function in new code; it will be removed."
   (if (window-live-p notmuch-tree-message-window)
   (with-selected-window notmuch-tree-message-window
-   (symbol-value sym))
-(symbol-value sym)))
-
-(defun notmuch-tree-close-message-pane-and (func)
-  "Close message pane and execute FUNC.
-
-This function returns a function (so can be used as a keybinding)
-which closes the message pane if open and then executes function
-FUNC."
-  `(lambda ()
- ,(concat "(Close message pane and) " (documentation func t))
+   notmuch-show-process-crypto)
+notmuch-show-process-crypto))
+
+(defmacro notmuch-tree--define-close-message-window-and (name cmd)
+  "Define NAME as a variant of CMD.
+
+NAME determines the value of `notmuch-show-process-crypto' in the
+message window, closes the window, and then call CMD interactively
+with that value let-bound.  If the message window does not exist,
+then NAME behaves like CMD."
+  `(defun ,name ()
+ ,(concat "(Close message pane and) " (documentation cmd t))
  (interactive)
  (let ((notmuch-show-process-crypto
-   (notmuch-tree-inherit-from-message-pane 
'notmuch-show-process-crypto)))
+   (notmuch-tree--message-process-crypto)))
(notmuch-tree-close-message-window)
-   (call-interactively #',func
+   (call-interactively #',cmd
+
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-help
+ notmuch-help)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-new-mail
+ notmuch-mua-new-mail)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-jump-search
+ notmuch-jump-search)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-forward-message
+ notmuch-show-forward-message)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-reply-sender
+ notmuch-show-reply-sender)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-reply
+ notmuch-show-reply)
+(notmuch-tree--define-close-message-window-and
+ notmuch-tree-view-raw-message
+ notmuch-show-view-raw-message)
 
 (defvar notmuch-tree-mode-map
   (let ((map (make-sparse-keymap)))
 (set-keymap-parent map notmuch-common-keymap)
-;; The following override the global keymap.
-;; Override because we want to close message pane first.
-(defi