From 69f767c4858cc97093e952319c7e92f1d605c8ea Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 14 Dec 2013 23:53:17 +0000 Subject: [PATCH] [PATCH v2 5/5] emacs: show: make `seen' mean user viewed whole message --- c0/a79889c18574a990f9540d7aa6717f7225824a | 171 ++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 c0/a79889c18574a990f9540d7aa6717f7225824a diff --git a/c0/a79889c18574a990f9540d7aa6717f7225824a b/c0/a79889c18574a990f9540d7aa6717f7225824a new file mode 100644 index 000000000..33612e075 --- /dev/null +++ b/c0/a79889c18574a990f9540d7aa6717f7225824a @@ -0,0 +1,171 @@ +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 A4038431FDF + for ; Sat, 14 Dec 2013 15:53:48 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=unavailable +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 mwxu-y9V4QWd for ; + Sat, 14 Dec 2013 15:53:48 -0800 (PST) +Received: from mail-wg0-f67.google.com (mail-wg0-f67.google.com + [74.125.82.67]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 7BA6E431FDD for ; Sat, 14 Dec 2013 15:53:43 -0800 + (PST) +Received: by mail-wg0-f67.google.com with SMTP id n12so896952wgh.6 + for ; Sat, 14 Dec 2013 15:53:42 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=VKppVlhkumcYb6e3h/MgHQaeYzWWMYjKK63rruOZ0LQ=; + b=YnYiqiM8W8D/iJX9TysrkioD3GAj/+GqljDXN4sG4pgqV2K9m0eKb+jDk67pAYeFj4 + UQZBoHmId/cQKAeSw5dW431TG2M3xAAGT6j692nNrrIgZqw6C37wwTgdCIyJKGA1O6lO + Vv3mYLrSTbDOhCJEH/y+mXWXmphUJdIy5wAwlmyZXpoHRxNRluEDIs4mrUKyz8y3Aqky + AtC/1lfPc0xHAmz0hU9wxjTNOMZhK2YP8n06O/kuBc+AFLI/uHb0y2mF4CjwHLkNBV1L + oIvgLgXoFELfgpVijA/z3SdUaOSeChqK70hYnsBDqL8JSszxWmGa9PunwsYiAWEdJyNO + lbAw== +X-Received: by 10.194.93.3 with SMTP id cq3mr7978330wjb.26.1387065222395; + Sat, 14 Dec 2013 15:53:42 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id q8sm11134599wiy.8.2013.12.14.15.53.41 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 14 Dec 2013 15:53:41 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v2 5/5] emacs: show: make `seen' mean user viewed whole + message +Date: Sat, 14 Dec 2013 23:53:17 +0000 +Message-Id: <1387065197-15776-6-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1387065197-15776-1-git-send-email-markwalters1009@gmail.com> +References: <1387065197-15776-1-git-send-email-markwalters1009@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: Sat, 14 Dec 2013 23:53:49 -0000 + +This changes `seen' to mean that the user viewed `enough' of the whole +message: more precisely, a message is deemed seen if the top of the +message and either the bottom of the message or a point at least some +customisable number of lines into the message have each been visible +in the buffer at some point. + +This is placed into the post-command-hook infrastructure introudced in +the previous patch. +--- + emacs/notmuch-show.el | 73 +++++++++++++++++++++++++++++++++++++++++++++++- + 1 files changed, 71 insertions(+), 2 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 51366e9..4850bd0 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -211,6 +211,19 @@ For example, if you wanted to remove an \"unread\" tag and add a + :type '(repeat string) + :group 'notmuch-show) + ++(defcustom notmuch-show-seen-lines-needed 0.75 ++ "Control which messages get marked seen. ++ ++A message is marked seen if both the top of the message and a ++point far \"enough\" down in the message have each been visible ++in the buffer at some point. This parameter controls the ++definition of enough. Seeing the bottom of message is always ++deemed enough, but additionally...it an integer n then at least n ++lines of message must be visible in the window. If it is a float ++x then at least that proportion of the window must contain the ++message." ++ :type 'number ++ :group 'notmuch-show) + + (defmacro with-current-notmuch-show-message (&rest body) + "Evaluate body with current buffer set to the text of current message" +@@ -1541,9 +1554,65 @@ marked as unread, i.e. the tag changes in + (apply 'notmuch-show-tag-message + (notmuch-tag-change-list notmuch-show-mark-read-tags unread)))) + ++(defun notmuch-show-update-seen (top-or-bottom) ++ "Update seen status of current message ++ ++Mark that we have seen the TOP-OR-BOTTOM of current message." ++ (let* ((current (notmuch-show-get-prop :seen-local)) ++ new) ++ (unless (eq current 'both) ++ (if (eq top-or-bottom 'top) ++ (if (eq current 'bottom) ++ (setq new 'both) ++ (setq new 'top)) ++ (if (eq current 'top) ++ (setq new 'both) ++ (setq new 'bottom))) ++ (unless (eq current new) ++ (notmuch-show-set-prop :seen-local new)) ++ (when (eq new 'both) ++ (notmuch-show-mark-read))))) ++ ++(defun notmuch-show-do-message-seen (start end) ++ "Update seen status for the current message. ++ ++A message is seen if both the top and enough of the rest of the ++message have been visible in the buffer. Enough means either the ++bottom of the message or a point in the message more than ++LINES-NEEDED lines into the message. LINES-NEEDED is ++`notmuch-show-seen-lines-needed` if that is an integer and that ++times the current window height if it is a float." ++ (let* ((lines-needed (if (integerp notmuch-show-seen-lines-needed) ++ notmuch-show-seen-lines-needed ++ (truncate (* notmuch-show-seen-lines-needed (window-body-height))))) ++ (top (notmuch-show-message-top)) ++ (bottom (notmuch-show-message-bottom))) ++ (when (notmuch-show-message-visible-p) ++ (when (>= top start) ++ (notmuch-show-update-seen 'top)) ++ (when (or (<= bottom end) ++ (> (count-screen-lines top end) lines-needed)) ++ (notmuch-show-update-seen 'bottom))))) ++ + (defun notmuch-show-do-seen (start end) +- "Update seen status for all messages between start and end." +- ) ++ "Update seen status for all messages between start and end. ++ ++A message is seen if both the top and enough of the rest of the ++message have been visible in the buffer. See ++`notmuch-show-do-message-seen` for the definition of enough. Seen ++is a buffer local property. The unread status is removed from all ++seen messages when the user quits the show buffer." ++ (save-excursion ++ (goto-char start) ++ (while (and (or (notmuch-show-do-message-seen start end) t) ++ (< (notmuch-show-message-bottom) end) ++ (notmuch-show-goto-message-next))) ++ ++ ;; This is a work around because emacs gives weird answers for ++ ;; window-end if the buffer ends with invisible text. ++ (when (and (pos-visible-in-window-p (point-max)) ++ (notmuch-show-message-visible-p)) ++ (notmuch-show-update-seen 'bottom)))) + + (defun notmuch-show-command-hook () + (when (eq major-mode 'notmuch-show-mode) +-- +1.7.9.1 + -- 2.26.2