From: NeilBrown Date: Fri, 26 May 2023 22:14:13 +0000 (+1000) Subject: notmuch: use mark:moving to avoid getting stuck in quoted lines X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=72ab8afe7b8ce75ffd6c561e01499967083d72f4;p=edlib.git notmuch: use mark:moving to avoid getting stuck in quoted lines Currently the 'point' can get stuck in hidden quoted-line and 'up' movements get lost. Use mark:moving (which is always sent on 'point') to see when this happens, and to escape. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 855e5a7e..674a889c 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -56,6 +56,13 @@ Current priorities Bugs to be fixed ---------------- +- [ ] I cannot dup a mark in a mark:moving handler. That is too + restrictive. I need a different way to decide that incoming marks + get notified. +- [ ] when map-attr returns text to be inserted, check for '<' and + double them +- [ ] when w3m text is copied we get the markup. I find this useful, + but is it *right*?? - [ ] notmuch: don't mark up links in text created by w3m - they are already marked if needed. - [X] notmuch: "reply" should clear unread/new flags. @@ -74,7 +81,7 @@ Bugs to be fixed search to get confused. What should we do? Don't redefine doc:char. Enable mark-moving notification on point and on 'refresh' move to appropriate end of a marker if on one -- [ ] use mark-moving on point to step over "quoted lines" +- [X] use mark-moving on point to step over "quoted lines" - [X] why doesn't doc-to-text auto-load - because only attach- autoloads. I need a complete redesign of autoload - [ ] use mimetypes.guess_type() to interpret filenames in email attachments?? diff --git a/python/module-notmuch.py b/python/module-notmuch.py index 26239a7f..6dacf831 100644 --- a/python/module-notmuch.py +++ b/python/module-notmuch.py @@ -3097,6 +3097,10 @@ class notmuch_message_view(edlib.Pane): self.qview = focus.call("doc:add-view", self) - 1 self.extra_headers = False + self.point = focus.call("doc:point", ret='mark') + self.prev_point = None + self.have_prev = False + self.call("doc:request:mark:moving") choose = {} m = edlib.Mark(focus) @@ -3579,6 +3583,33 @@ class notmuch_message_view(edlib.Pane): focus.call("Display:external-viewer", url) return 1 + def handle_moving(self, key, focus, mark, mark2, **a): + "handle:mark:moving" + if mark == self.point and not self.have_prev: + # We cannot dup because that triggers a recursive notification + #self.prev_point = mark.dup() + self.prev_point = self.vmark_at_or_before(self.qview, mark) + self.have_prev = True + self.damaged(edlib.DAMAGED_VIEW) + return 1 + + def handle_review(self, key, focus, **a): + "handle:Refresh:view" + # if point is in a "quoted line" section that is hidden, + # Move it to start or end opposite prev_point + if not self.have_prev: + return 1 + m = self.vmark_at_or_before(self.qview, self.point) + if m and m != self.point and m['quote-length'] and m['quote-hidden'] == "yes": + if not self.prev_point or self.prev_point < self.point: + # moving toward end of file + m = m.next() + if self.point != m: + self.point.to_mark(m) + self.prev_point = None + self.have_prev = False + return 1 + def notmuch_doc(key, home, focus, comm2, **a): # Create the root notmuch document nm = notmuch_main(home)