[PATCH 2/2] emacs: skip forward to visible text in notmuch-show-message-extent
Pieter Praet
pieter at praet.org
Mon Jul 4 01:25:46 PDT 2011
On Sun, 3 Jul 2011 08:28:06 +0400, Dmitry Kurochkin <dmitry.kurochkin at gmail.com> wrote:
> 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
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
Signed-off-by: Pieter Praet <pieter at praet.org>
Though it's worth noting that (as a previous test of yours [1] demonstrates),
it doesn't work consistently when the previous message has a text/html part:
complains with "No URL at point".
Peace
--
Pieter
[1] id:"1309752441-10651-4-git-send-email-dmitry.kurochkin at gmail.com"
More information about the notmuch
mailing list