[PATCH] alot: send batch keypresses back to urwid

Chris Mason chris.mason at fusionio.com
Sat Mar 16 11:42:38 PDT 2013


Looks like the urwid code is sending us arrays of [ 'j', 'j', 'j' ... ]
when I hold down the key, but alot is only acting on one of them.

This changes the fire routine to send back all the keys that were sent
to us.  It may be a horrible idea, and I'm not sure if urwid always sends us
arrays of the same thing.

But it's dramatically faster, so how can it be bad?

Signed-off-by: Chris Mason <chris.mason at fusionio.com>

diff --git a/alot/ui.py b/alot/ui.py
index 5d4dd4a..b8ced29 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -119,12 +119,12 @@ class UI(object):
                 self.input_queue = []
                 self.update()
 
-            def fire(ignored, cmdline):
+            def fire(ignored, cmdline, count):
                 clear()
                 logging.debug("cmdline: '%s'" % cmdline)
                 # move keys are always passed
                 if cmdline in ['move up', 'move down', 'move page up', 'move page down']:
-                    return [cmdline[5:]]
+                    return [cmdline[5:]] * count
                 elif not self._locked:
                     try:
                         self.apply_commandline(cmdline)
@@ -147,7 +147,7 @@ class UI(object):
                             self.mainloop.remove_alarm(self._alarm)
                         self._alarm = self.mainloop.set_alarm_in(timeout, fire, cmdline)
                     else:
-                        return fire(self.mainloop, cmdline)
+                        return fire(self.mainloop, cmdline, len(keys))
 
             elif not candidates:
                 # case: no sequence with prefix keyseq is mapped


More information about the notmuch mailing list