[PATCH] alot: send batch keypresses back to urwid (v2)
authorChris Mason <chris.mason@fusionio.com>
Sun, 17 Mar 2013 14:32:37 +0000 (10:32 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:54:00 +0000 (09:54 -0800)
f2/6f7408ce22edf2ff8d2e55a9c9cb8e18c4da41 [new file with mode: 0644]

diff --git a/f2/6f7408ce22edf2ff8d2e55a9c9cb8e18c4da41 b/f2/6f7408ce22edf2ff8d2e55a9c9cb8e18c4da41
new file mode 100644 (file)
index 0000000..4311ce8
--- /dev/null
@@ -0,0 +1,143 @@
+Return-Path: <clmason@fusionio.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 60235431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Mar 2013 07:32:42 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id pjzzo00TFYCu for <notmuch@notmuchmail.org>;\r
+       Sun, 17 Mar 2013 07:32:42 -0700 (PDT)\r
+Received: from dkim1.fusionio.com (dkim1.fusionio.com [66.114.96.53])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id E06B8431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Mar 2013 07:32:41 -0700 (PDT)\r
+Received: from mx1.fusionio.com (unknown [10.101.1.160])\r
+       by dkim1.fusionio.com (Postfix) with ESMTP id C0D807C04D8\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Mar 2013 08:32:39 -0600 (MDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com;\r
+       s=default; t=1363530759;\r
+       bh=r/vn4zZaOJ02KoHebNJs5w87dPn2zhXz2ntMhY1eBVc=;\r
+       h=From:To:References:In-Reply-To:Subject:Date;\r
+       b=p19vtkHNpMzYrqGAYDzD7m3kPd70AL9/Kat7+MOevXG8iduBJD5Hagz9xPVZrBqna\r
+       mHwU2nzs3+TxN7Ltmp8e7ZD44/wl4A6h4CB0VpQ9ngmX6zNU9opEFgCxvcOAbHkDLB\r
+       ZEQ0aZKe10HjyAJGc12tcX4NMdwRDwcoSASRDvts=\r
+X-ASG-Debug-ID: 1363530759-03d6a52abf135e0001-ZmzXr9\r
+Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21])\r
+       by mx1.fusionio.com with ESMTP id NF7hAkAQRDlU6w2O\r
+       (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO);\r
+       Sun, 17 Mar 2013 08:32:39 -0600 (MDT)\r
+X-Barracuda-Envelope-From: clmason@fusionio.com\r
+Received: from localhost (67.247.72.189) by mail.fusionio.com (10.101.1.19)\r
+       with Microsoft SMTP Server (TLS) id 8.3.83.0;\r
+       Sun, 17 Mar 2013 08:32:38 -0600\r
+Content-Type: text/plain; charset="utf-8"\r
+MIME-Version: 1.0\r
+Content-Transfer-Encoding: quoted-printable\r
+From: Chris Mason <chris.mason@fusionio.com>\r
+User-Agent: alot/0.3.4\r
+To: Chris Mason <chris.mason@fusionio.com>, <notmuch@notmuchmail.org>, Patrick\r
+       Totzke <patricktotzke@gmail.com>\r
+References: <20130316184238.11801.82067@localhost.localdomain>\r
+In-Reply-To: <20130316184238.11801.82067@localhost.localdomain>\r
+Message-ID: <20130317143237.6912.75793@localhost.localdomain>\r
+Subject: [PATCH] alot: send batch keypresses back to urwid (v2)\r
+Date: Sun, 17 Mar 2013 10:32:37 -0400\r
+X-ASG-Orig-Subj: [PATCH] alot: send batch keypresses back to urwid (v2)\r
+X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21]\r
+X-Barracuda-Start-Time: 1363530759\r
+X-Barracuda-Encrypted: AES128-SHA\r
+X-Barracuda-URL: http://10.101.1.180:8000/cgi-mod/mark.cgi\r
+X-Virus-Scanned: by bsmtpd at fusionio.com\r
+X-Barracuda-Bayes: INNOCENT GLOBAL 0.0990 1.0000 -1.3986\r
+X-Barracuda-Spam-Score: 2.10\r
+X-Barracuda-Spam-Status: No,\r
+       SCORE=2.10 using per-user scores of TAG_LEVEL=1000.0\r
+       QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests=BSF_SC0_MV0035,\r
+       BSF_SC0_SA550, BSF_SC0_SA_TO_FROM_ADDR_MATCH\r
+X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.125457\r
+       Rule breakdown below\r
+       pts rule name              description\r
+       ---- ----------------------\r
+       --------------------------------------------------\r
+       0.50 BSF_SC0_SA_TO_FROM_ADDR_MATCH Sender Address Matches Recipient\r
+       Address 2.50 BSF_SC0_SA550          Custom Rule SA550\r
+       0.50 BSF_SC0_MV0035         Custom Rule BSF_SC0_MV0035\r
+X-Mailman-Approved-At: Sun, 17 Mar 2013 16:42:40 -0700\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 17 Mar 2013 14:32:42 -0000\r
+\r
+Looks like the urwid code is sending us arrays of [ 'j', 'j', 'j' ... ]\r
+when I hold down the key, but alot is only acting on one of them.\r
+ =\r
+\r
+This changes the fire routine to send back all the keys that were sent\r
+to us.  It may be a horrible idea, and I'm not sure if urwid always sends us\r
+arrays of the same thing.\r
+\r
+But it's dramatically faster, so how can it be bad?  V2 catches the\r
+second caller of fire()\r
+\r
+Signed-off-by: Chris Mason <chris.mason@fusionio.com>\r
+\r
+diff --git a/alot/ui.py b/alot/ui.py\r
+index 3593c60..cdc66a6 100644\r
+--- a/alot/ui.py\r
++++ b/alot/ui.py\r
+@@ -119,18 +119,20 @@ class UI(object):\r
+                 self.input_queue =3D []\r
+                 self.update()\r
+ =\r
+\r
+-            def fire(ignored, cmdline):\r
++            def fire(ignored, cmdline, count):\r
+                 clear()\r
+                 logging.debug("cmdline: '%s'" % cmdline)\r
+                 # move keys are always passed\r
+                 if cmdline in ['move up', 'move down', 'move page up',\r
+                                'move page down']:\r
+-                    return [cmdline[5:]]\r
++                    return [cmdline[5:]] * count\r
+                 elif not self._locked:\r
+                     try:\r
+                         self.apply_commandline(cmdline)\r
+                     except CommandParseError, e:\r
+                         self.notify(e.message, priority=3D'error')\r
++            def fire_one(ignored, cmdline):\r
++                return fire(ignored, cmdline, 1)\r
+ =\r
+\r
+             key =3D keys[0]\r
+             self.input_queue.append(key)\r
+@@ -147,9 +149,9 @@ class UI(object):\r
+                         if self._alarm is not None:\r
+                             self.mainloop.remove_alarm(self._alarm)\r
+                         self._alarm =3D self.mainloop.set_alarm_in(\r
+-                            timeout, fire, cmdline)\r
++                            timeout, fire_one, cmdline)\r
+                     else:\r
+-                        return fire(self.mainloop, cmdline)\r
++                        return fire(self.mainloop, cmdline, len(keys))\r
+ =\r
+\r
+             elif not candidates:\r
+                 # case: no sequence with prefix keyseq is mapped\r