Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id A9B04429E2D for ; Sat, 2 Jul 2011 21:28:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EkYqXF1KaUcp for ; Sat, 2 Jul 2011 21:28:20 -0700 (PDT) Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id C086E429E27 for ; Sat, 2 Jul 2011 21:28:17 -0700 (PDT) Received: by mail-bw0-f53.google.com with SMTP id 12so3982009bwg.26 for ; Sat, 02 Jul 2011 21:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=LdacNmCovR0PwCTfVuzOpJhGNa/gP8sk5WFQ+O3CWhA=; b=L5WUTZuVvIxLepcMS7SSt7A8K5VkuQPprSFcvDpnoZXWaSlDbMJLaSJ+AcpJReMtta vC+rL4igEd90w38sFypf80YOnfrrI9eKuqrE8nTz2/PTfAw1r5MtSKOC54Qk3Sc/GjDb nl7Te4A8Pmk8uBkLvQFS+EPJejf3ASj5go98s= Received: by 10.204.57.82 with SMTP id b18mr4381487bkh.95.1309667297389; Sat, 02 Jul 2011 21:28:17 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id l24sm4384900bkw.3.2011.07.02.21.28.15 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 02 Jul 2011 21:28:16 -0700 (PDT) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH 2/2] emacs: skip forward to visible text in notmuch-show-message-extent Date: Sun, 3 Jul 2011 08:28:06 +0400 Message-Id: <1309667286-10357-2-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1309667286-10357-1-git-send-email-dmitry.kurochkin@gmail.com> References: <1309667286-10357-1-git-send-email-dmitry.kurochkin@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 04:28:23 -0000 The patch rewrites `notmuch-show-message-extent' to be more robust. The main goal is to make it work as expected if point is invisible. Besides, there are no more point movements and property search functions are used instead manual loops. The comment regarding properties strangeness is removed since there is no strangeness here: property ranges (as well as overlay, and many others, I believe) are given as [begin, end), not [begin, end]. --- emacs/notmuch-show.el | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f96743b..cf8b405 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -933,15 +933,18 @@ All currently available key bindings: ;; Movement related functions. -;; There's some strangeness here where a text property applied to a -;; region a->b is not found when point is at b. We walk backwards -;; until finding the property. (defun notmuch-show-message-extent () - (let (r) - (save-excursion - (while (not (setq r (get-text-property (point) :notmuch-message-extent))) - (backward-char))) - r)) + (let ((p (point))) + ;; if point is invisible, skip forward to visible text + (while (invisible-p p) + (setq p (next-single-char-property-change p 'invisible))) + ;; if no visible text found, use the point + (or p (setq p (point))) + (or (get-text-property p :notmuch-message-extent) + ;; if there is no text property, skip to the previous message + (and (setq p (previous-single-char-property-change + p :notmuch-message-extent)) + (get-text-property p :notmuch-message-extent))))) (defun notmuch-show-message-top () (car (notmuch-show-message-extent))) -- 1.7.5.4