Re: [PATCH 2/2] emacs: skip forward to visible text in notmuch-show-message-extent
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Tue, 5 Jul 2011 09:38:03 +0000 (13:38 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:58 +0000 (09:38 -0800)
1b/2b191ef1b115f0161f07efd3249132516660f5 [new file with mode: 0644]

diff --git a/1b/2b191ef1b115f0161f07efd3249132516660f5 b/1b/2b191ef1b115f0161f07efd3249132516660f5
new file mode 100644 (file)
index 0000000..8438141
--- /dev/null
@@ -0,0 +1,126 @@
+Return-Path: <dmitry.kurochkin@gmail.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 1548C431FD0\r
+       for <notmuch@notmuchmail.org>; Tue,  5 Jul 2011 02:38:16 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 0Pk3ENz-VzMX for <notmuch@notmuchmail.org>;\r
+       Tue,  5 Jul 2011 02:38:11 -0700 (PDT)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 8483D431FB6\r
+       for <notmuch@notmuchmail.org>; Tue,  5 Jul 2011 02:38:11 -0700 (PDT)\r
+Received: by bwg12 with SMTP id 12so5375853bwg.26\r
+       for <notmuch@notmuchmail.org>; Tue, 05 Jul 2011 02:38:09 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type;\r
+       bh=Zl58+NrUTIoS/GDpMXAbtYF5EUfuc8ybIQqzHO23jcI=;\r
+       b=QRkIUJ5SpSAw6SXK309QijcoJp5bq/0Q2lJCvigI4Z0LaSa/U3BN9MXj/3zemxfqS1\r
+       Lc78K3/5VCqCmdHoeh++vEDtWz92oa3VEcJOmmfpp63S9b3uKbdfdnPZ7216mm7d96D+\r
+       FCWOBzE4OucUgXw0ZlTZ4aOCE75gR5kAEopmc=\r
+Received: by 10.204.138.136 with SMTP id a8mr6768471bku.106.1309858689895;\r
+       Tue, 05 Jul 2011 02:38:09 -0700 (PDT)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id t9sm6368574bkn.8.2011.07.05.02.38.08\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 05 Jul 2011 02:38:08 -0700 (PDT)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] emacs: skip forward to visible text in\r
+       notmuch-show-message-extent\r
+In-Reply-To: <1309667286-10357-2-git-send-email-dmitry.kurochkin@gmail.com>\r
+References: <1309667286-10357-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+       <1309667286-10357-2-git-send-email-dmitry.kurochkin@gmail.com>\r
+User-Agent: Notmuch/0.5-321-g41686e2 (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 05 Jul 2011 13:38:03 +0400\r
+Message-ID: <87iprh5apw.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Tue, 05 Jul 2011 09:38:16 -0000\r
+\r
+On Sun,  3 Jul 2011 08:28:06 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:\r
+> The patch rewrites `notmuch-show-message-extent' to be more\r
+> robust.  The main goal is to make it work as expected if point is\r
+> invisible.  Besides, there are no more point movements and\r
+> property search functions are used instead manual loops.  The\r
+> comment regarding properties strangeness is removed since there\r
+> is no strangeness here: property ranges (as well as overlay, and\r
+> many others, I believe) are given as [begin, end), not [begin,\r
+> end].\r
+\r
+Please do not apply this patch.  I am considering a different solution:\r
+instead of making the trailing newline invisible, make the preceding\r
+newline invisible.  This way a message would always have a visible\r
+newline at the end and it would prevent `beginning-of-visual-line' going\r
+beyond the beginning of message.\r
+\r
+FYI there is a discussion on emacs-devel [1] regarding point adjustment\r
+inside invisible regions.\r
+\r
+Regards,\r
+  Dmitry\r
+\r
+[1] http://thread.gmane.org/gmane.emacs.devel/141479\r
+\r
+> ---\r
+>  emacs/notmuch-show.el |   19 +++++++++++--------\r
+>  1 files changed, 11 insertions(+), 8 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index f96743b..cf8b405 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -933,15 +933,18 @@ All currently available key bindings:\r
+>  \r
+>  ;; Movement related functions.\r
+>  \r
+> -;; There's some strangeness here where a text property applied to a\r
+> -;; region a->b is not found when point is at b. We walk backwards\r
+> -;; until finding the property.\r
+>  (defun notmuch-show-message-extent ()\r
+> -  (let (r)\r
+> -    (save-excursion\r
+> -      (while (not (setq r (get-text-property (point) :notmuch-message-extent)))\r
+> -    (backward-char)))\r
+> -    r))\r
+> +  (let ((p (point)))\r
+> +    ;; if point is invisible, skip forward to visible text\r
+> +    (while (invisible-p p)\r
+> +      (setq p (next-single-char-property-change p 'invisible)))\r
+> +    ;; if no visible text found, use the point\r
+> +    (or p (setq p (point)))\r
+> +    (or (get-text-property p :notmuch-message-extent)\r
+> +    ;; if there is no text property, skip to the previous message\r
+> +    (and (setq p (previous-single-char-property-change\r
+> +                  p :notmuch-message-extent))\r
+> +         (get-text-property p :notmuch-message-extent)))))\r
+>  \r
+>  (defun notmuch-show-message-top ()\r
+>    (car (notmuch-show-message-extent)))\r
+> -- \r
+> 1.7.5.4\r
+> \r