* [PATCH] emacs: add global tag history @ 2022-01-26 15:32 inwit 2022-01-26 15:40 ` David Bremner 2023-01-06 11:36 ` David Bremner 0 siblings, 2 replies; 11+ messages in thread From: inwit @ 2022-01-26 15:32 UTC (permalink / raw) To: notmuch; +Cc: inwit Save a list of every tag change in the new variable notmuch-tag-history. --- Storing the full history of tags can prove useful for a) repeated tag changes as in [0] and b) eventually logging and undoing tag changes. This is my first commit in elisp. I expect turbulences ahead. :) [0] https://nmbug.notmuchmail.org/nmweb/show/CCSQ9HR3M748.2IRNNTHYR4A2M%40bisio emacs/notmuch-tag.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index 8af09e68..68341cf2 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -388,6 +388,9 @@ the messages that were tagged." (defvar notmuch-read-tag-changes-history nil "Minibuffer history of `notmuch-read-tag-changes' function.") +(defvar notmuch-tag-history nil + "Global history of `notmuch-tag' function.") + (defun notmuch-tag-completions (&rest search-terms) "Return a list of tags for messages matching SEARCH-TERMS. @@ -478,6 +481,7 @@ notmuch-after-tag-hook will be run." (unless query (error "Nothing to tag!")) (when tag-changes + (push tag-changes notmuch-tag-history) (notmuch-dlet ((tag-changes tag-changes) (query query)) (run-hooks 'notmuch-before-tag-hook)) -- 2.32.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 15:32 [PATCH] emacs: add global tag history inwit @ 2022-01-26 15:40 ` David Bremner 2022-01-26 16:08 ` inwit 2023-01-06 11:36 ` David Bremner 1 sibling, 1 reply; 11+ messages in thread From: David Bremner @ 2022-01-26 15:40 UTC (permalink / raw) To: inwit, notmuch inwit <inwit@sindominio.net> writes: > Save a list of every tag change in the new variable notmuch-tag-history. > --- > Storing the full history of tags can prove useful for a) repeated tag > changes as in [0] and b) eventually logging and undoing tag changes. I guess for undo you will need to save the query as well? Even that will not be perfect (since the messages matching the query could change behind emacs back), but close enough for most interactive use, maybe? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 15:40 ` David Bremner @ 2022-01-26 16:08 ` inwit 2022-01-26 16:29 ` Carl Worth 2022-01-27 12:28 ` David Bremner 0 siblings, 2 replies; 11+ messages in thread From: inwit @ 2022-01-26 16:08 UTC (permalink / raw) To: David Bremner; +Cc: notmuch On 2022-01-26 16:40, David Bremner wrote: > I guess for undo you will need to save the query as well? > > Even that will not be perfect (since the messages matching the query > could change behind emacs back), but close enough for most interactive > use, maybe? I was thinking about saving the IDs of the messages affected by the change, but I still don't know how would I go about that or if it's sensible. Thanks! ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 16:08 ` inwit @ 2022-01-26 16:29 ` Carl Worth 2022-01-26 17:43 ` Jose Antonio Ortega Ruiz 2022-01-26 17:48 ` David Bremner 2022-01-27 12:28 ` David Bremner 1 sibling, 2 replies; 11+ messages in thread From: Carl Worth @ 2022-01-26 16:29 UTC (permalink / raw) To: inwit, David Bremner; +Cc: notmuch On Wed, Jan 26 2022, inwit wrote: >> Even that will not be perfect (since the messages matching the query >> could change behind emacs back), but close enough for most interactive >> use, maybe? > > I was thinking about saving the IDs of the messages affected by the > change, but I still don't know how would I go about that or if it's > sensible. One could imagine a history that would enable a conventional undo stack for a notmuch interface. The trick with making that usable would be the need to refresh views to make what was undone evident, (and the fact that some of the operations could be large/slow). All of those issues kept me from pursuing the idea in early days of coding up the emacs notmuch UI. But someone could certainly explore the implementation further if desired. -Carl ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 16:29 ` Carl Worth @ 2022-01-26 17:43 ` Jose Antonio Ortega Ruiz 2022-01-27 12:23 ` inwit 2022-01-26 17:48 ` David Bremner 1 sibling, 1 reply; 11+ messages in thread From: Jose Antonio Ortega Ruiz @ 2022-01-26 17:43 UTC (permalink / raw) To: notmuch On Wed, Jan 26 2022, Carl Worth wrote: > On Wed, Jan 26 2022, inwit wrote: >>> Even that will not be perfect (since the messages matching the query >>> could change behind emacs back), but close enough for most interactive >>> use, maybe? >> >> I was thinking about saving the IDs of the messages affected by the >> change, but I still don't know how would I go about that or if it's >> sensible. > > One could imagine a history that would enable a conventional undo stack > for a notmuch interface. The trick with making that usable would be the > need to refresh views to make what was undone evident, (and the fact > that some of the operations could be large/slow). > > All of those issues kept me from pursuing the idea in early days of > coding up the emacs notmuch UI. But someone could certainly explore the > implementation further if desired. maybe this could be a buffer-local history variable, for notmuch search and tree search buffers, and the undo feature apply only to the current search buffer. the view update is then well-defined, i think, if it's just changing tags, at least, and per-buffer operation is the normal behaviour of undo/redo in emacs. hooking that up with the regular emacs undo/redo mechanism would be great (in my book at least), but i've never looked at that, so not sure if it's possible. cheers, jao -- Keep away from people who try to belittle your ambitions. Small people always do that, but the really great make you feel that you, too, can become great. - Mark Twain ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 17:43 ` Jose Antonio Ortega Ruiz @ 2022-01-27 12:23 ` inwit 0 siblings, 0 replies; 11+ messages in thread From: inwit @ 2022-01-27 12:23 UTC (permalink / raw) To: Jose Antonio Ortega Ruiz, notmuch On Wed Jan 26, 2022 at 6:43 PM CET, Jose Antonio Ortega Ruiz wrote: > maybe this could be a buffer-local history variable, for notmuch search > and tree search buffers, and the undo feature apply only to the current > search buffer. the view update is then well-defined, i think, if it's > just changing tags, at least, and per-buffer operation is the normal > behaviour of undo/redo in emacs. hooking that up with the regular emacs > undo/redo mechanism would be great (in my book at least), but i've never > looked at that, so not sure if it's possible. This sounds very much like it, yes. Would this need automatic update of the buffer? If a message is deleted, for instance, an undo operation should bring it back to the buffer, right? Of course, this sort of modification is still far in my slow learner horizon... > > cheers, > jao > -- > Keep away from people who try to belittle your ambitions. Small people > always do that, but the really great make you feel that you, too, can > become great. - Mark Twain > _______________________________________________ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-leave@notmuchmail.org ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 16:29 ` Carl Worth 2022-01-26 17:43 ` Jose Antonio Ortega Ruiz @ 2022-01-26 17:48 ` David Bremner 2022-01-26 18:00 ` David Bremner 1 sibling, 1 reply; 11+ messages in thread From: David Bremner @ 2022-01-26 17:48 UTC (permalink / raw) To: Carl Worth, inwit; +Cc: notmuch Carl Worth <cworth@cworth.org> writes: > On Wed, Jan 26 2022, inwit wrote: >>> Even that will not be perfect (since the messages matching the query >>> could change behind emacs back), but close enough for most interactive >>> use, maybe? >> >> I was thinking about saving the IDs of the messages affected by the >> change, but I still don't know how would I go about that or if it's >> sensible. > > One could imagine a history that would enable a conventional undo stack > for a notmuch interface. The trick with making that usable would be the > need to refresh views to make what was undone evident, (and the fact > that some of the operations could be large/slow). > > All of those issues kept me from pursuing the idea in early days of > coding up the emacs notmuch UI. But someone could certainly explore the > implementation further if desired. One thing that has changed since those early days is that we now have lastmod (see notmuch-search-terms(7)): queries, but that is still not atomic. I guess it might not be too hard to have notmuch tag output output the correct lastmod value. Then we could store that as shorthand for a set of messages. d ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 17:48 ` David Bremner @ 2022-01-26 18:00 ` David Bremner 0 siblings, 0 replies; 11+ messages in thread From: David Bremner @ 2022-01-26 18:00 UTC (permalink / raw) To: Carl Worth, inwit; +Cc: notmuch David Bremner <david@tethera.net> writes: > One thing that has changed since those early days is that we now have > lastmod (see notmuch-search-terms(7)): queries, but that is still not > atomic. I guess it might not be too hard to have notmuch tag output > output the correct lastmod value. Then we could store that as shorthand > for a set of messages. Now that I think about it, that wouldn't really be robost either, since something that was changed after that tagging operation would get a new lastmod value. But maybe we could define that as a feature. d ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 16:08 ` inwit 2022-01-26 16:29 ` Carl Worth @ 2022-01-27 12:28 ` David Bremner 1 sibling, 0 replies; 11+ messages in thread From: David Bremner @ 2022-01-27 12:28 UTC (permalink / raw) To: inwit; +Cc: notmuch inwit <inwit@sindominio.net> writes: > On 2022-01-26 16:40, David Bremner wrote: >> I guess for undo you will need to save the query as well? >> >> Even that will not be perfect (since the messages matching the query >> could change behind emacs back), but close enough for most interactive >> use, maybe? > > I was thinking about saving the IDs of the messages affected by the > change, but I still don't know how would I go about that or if it's > sensible. Absent some new feature in notmuch tag, you'd need to do another query to get the set of message-ids. That set would still be subject to change between that query and tagging operation, so that is a bit unsatisfactory. Also the set of message-ids could be impractically large. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2022-01-26 15:32 [PATCH] emacs: add global tag history inwit 2022-01-26 15:40 ` David Bremner @ 2023-01-06 11:36 ` David Bremner 2023-01-10 15:29 ` inwit 1 sibling, 1 reply; 11+ messages in thread From: David Bremner @ 2023-01-06 11:36 UTC (permalink / raw) To: inwit, notmuch; +Cc: inwit inwit <inwit@sindominio.net> writes: > Save a list of every tag change in the new variable notmuch-tag-history. > --- > Storing the full history of tags can prove useful for a) repeated tag > changes as in [0] and b) eventually logging and undoing tag changes. > > This is my first commit in elisp. I expect turbulences ahead. :) > > [0] > https://nmbug.notmuchmail.org/nmweb/show/CCSQ9HR3M748.2IRNNTHYR4A2M%40bisio > > emacs/notmuch-tag.el | 4 ++++ > 1 file changed, 4 insertions(+) Although this patch won't apply anymore, thanks for inspiring the work that lead to supporting undo. Unfortunately I stole the name "notmuch-tag-history" for a buffer local variable, so I guess someone interested in a global history would need to choose a different variable name. d ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] emacs: add global tag history 2023-01-06 11:36 ` David Bremner @ 2023-01-10 15:29 ` inwit 0 siblings, 0 replies; 11+ messages in thread From: inwit @ 2023-01-10 15:29 UTC (permalink / raw) To: David Bremner, notmuch On Fri Jan 6, 2023 at 12:36 PM CET, David Bremner wrote: > Although this patch won't apply anymore, thanks for inspiring the work that > lead to supporting undo. Unfortunately I stole the name > "notmuch-tag-history" for a buffer local variable, so I guess someone > interested in a global history would need to choose a different variable > name. Thanks to you, David! Undo is great. I'd like to make another attempt at global tag history and repeating last tagging operation. I hope to find the time soon! ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-01-10 15:38 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-01-26 15:32 [PATCH] emacs: add global tag history inwit 2022-01-26 15:40 ` David Bremner 2022-01-26 16:08 ` inwit 2022-01-26 16:29 ` Carl Worth 2022-01-26 17:43 ` Jose Antonio Ortega Ruiz 2022-01-27 12:23 ` inwit 2022-01-26 17:48 ` David Bremner 2022-01-26 18:00 ` David Bremner 2022-01-27 12:28 ` David Bremner 2023-01-06 11:36 ` David Bremner 2023-01-10 15:29 ` inwit
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).