Re: [DRAFT PATCH] emacs: support limiting the number of results shown in search results
[notmuch-archives.git] / 24 / 7474109085d06f60a1e5c2cfe8898457c958e3
1 Return-Path: <dmitry.kurochkin@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id A9B04429E2D\r
6         for <notmuch@notmuchmail.org>; Sat,  2 Jul 2011 21:28:22 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id EkYqXF1KaUcp for <notmuch@notmuchmail.org>;\r
17         Sat,  2 Jul 2011 21:28:20 -0700 (PDT)\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id C086E429E27\r
22         for <notmuch@notmuchmail.org>; Sat,  2 Jul 2011 21:28:17 -0700 (PDT)\r
23 Received: by mail-bw0-f53.google.com with SMTP id 12so3982009bwg.26\r
24         for <notmuch@notmuchmail.org>; Sat, 02 Jul 2011 21:28:17 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=LdacNmCovR0PwCTfVuzOpJhGNa/gP8sk5WFQ+O3CWhA=;\r
28         b=L5WUTZuVvIxLepcMS7SSt7A8K5VkuQPprSFcvDpnoZXWaSlDbMJLaSJ+AcpJReMtta\r
29         vC+rL4igEd90w38sFypf80YOnfrrI9eKuqrE8nTz2/PTfAw1r5MtSKOC54Qk3Sc/GjDb\r
30         nl7Te4A8Pmk8uBkLvQFS+EPJejf3ASj5go98s=\r
31 Received: by 10.204.57.82 with SMTP id b18mr4381487bkh.95.1309667297389;\r
32         Sat, 02 Jul 2011 21:28:17 -0700 (PDT)\r
33 Received: from localhost ([91.144.186.21])\r
34         by mx.google.com with ESMTPS id l24sm4384900bkw.3.2011.07.02.21.28.15\r
35         (version=TLSv1/SSLv3 cipher=OTHER);\r
36         Sat, 02 Jul 2011 21:28:16 -0700 (PDT)\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 2/2] emacs: skip forward to visible text in\r
40         notmuch-show-message-extent\r
41 Date: Sun,  3 Jul 2011 08:28:06 +0400\r
42 Message-Id: <1309667286-10357-2-git-send-email-dmitry.kurochkin@gmail.com>\r
43 X-Mailer: git-send-email 1.7.5.4\r
44 In-Reply-To: <1309667286-10357-1-git-send-email-dmitry.kurochkin@gmail.com>\r
45 References: <1309667286-10357-1-git-send-email-dmitry.kurochkin@gmail.com>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Sun, 03 Jul 2011 04:28:23 -0000\r
59 \r
60 The patch rewrites `notmuch-show-message-extent' to be more\r
61 robust.  The main goal is to make it work as expected if point is\r
62 invisible.  Besides, there are no more point movements and\r
63 property search functions are used instead manual loops.  The\r
64 comment regarding properties strangeness is removed since there\r
65 is no strangeness here: property ranges (as well as overlay, and\r
66 many others, I believe) are given as [begin, end), not [begin,\r
67 end].\r
68 ---\r
69  emacs/notmuch-show.el |   19 +++++++++++--------\r
70  1 files changed, 11 insertions(+), 8 deletions(-)\r
71 \r
72 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
73 index f96743b..cf8b405 100644\r
74 --- a/emacs/notmuch-show.el\r
75 +++ b/emacs/notmuch-show.el\r
76 @@ -933,15 +933,18 @@ All currently available key bindings:\r
77  \r
78  ;; Movement related functions.\r
79  \r
80 -;; There's some strangeness here where a text property applied to a\r
81 -;; region a->b is not found when point is at b. We walk backwards\r
82 -;; until finding the property.\r
83  (defun notmuch-show-message-extent ()\r
84 -  (let (r)\r
85 -    (save-excursion\r
86 -      (while (not (setq r (get-text-property (point) :notmuch-message-extent)))\r
87 -       (backward-char)))\r
88 -    r))\r
89 +  (let ((p (point)))\r
90 +    ;; if point is invisible, skip forward to visible text\r
91 +    (while (invisible-p p)\r
92 +      (setq p (next-single-char-property-change p 'invisible)))\r
93 +    ;; if no visible text found, use the point\r
94 +    (or p (setq p (point)))\r
95 +    (or (get-text-property p :notmuch-message-extent)\r
96 +       ;; if there is no text property, skip to the previous message\r
97 +       (and (setq p (previous-single-char-property-change\r
98 +                     p :notmuch-message-extent))\r
99 +            (get-text-property p :notmuch-message-extent)))))\r
100  \r
101  (defun notmuch-show-message-top ()\r
102    (car (notmuch-show-message-extent)))\r
103 -- \r
104 1.7.5.4\r
105 \r