]> git.neil.brown.name Git - edlib.git/commitdiff
notmuch: use mark:moving to avoid getting stuck in quoted lines
authorNeilBrown <neil@brown.name>
Fri, 26 May 2023 22:14:13 +0000 (08:14 +1000)
committerNeilBrown <neil@brown.name>
Fri, 26 May 2023 23:24:28 +0000 (09:24 +1000)
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 <neil@brown.name>
DOC/TODO.md
python/module-notmuch.py

index 855e5a7e7d83e03373a4879773e01e5273238dc7..674a889ccf848478b2cc3d934b8ffa905df28c46 100644 (file)
@@ -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??
index 26239a7feaef7036cb6b9aa73ce8865cc9779f88..6dacf8313774fd6989d83c97024ed193d4d37ac9 100644 (file)
@@ -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)