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 7CDE7431FBD for ; Sun, 9 Jun 2013 21:57:39 -0700 (PDT) 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=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 TDntXN-XA0Mx for ; Sun, 9 Jun 2013 21:57:33 -0700 (PDT) Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 830D7431FAE for ; Sun, 9 Jun 2013 21:57:28 -0700 (PDT) Received: by mail-ea0-f181.google.com with SMTP id a15so2677002eae.40 for ; Sun, 09 Jun 2013 21:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=wBG1+1pCLZMzHDVDNynoav9nTrCQGJm1HWvowPQcPRM=; b=MqLHFBXw/d7lt6KnuOu6CAeix1oGpHoJLJP5wjeoumD4zT4w/O3HvjvW6U8gJ+o3Dr DIOtnu36FpGjaqatSkBm9dJQqXISofHJlxJq/rNI4d8PT86MbtkiG8pJl88d8C62TkQn s47LluvNgNCiYdeOXOCDQyJI5kttG1uLlT53s448VfgBCb0Fcz0jiLuF8zc6GbC99hW8 sP75A7kEe6s1r8fTkFC57ayNJS4DQDk29LAWuuIeJ/RhSb/skRw6y5bzK6uBhjS10lpX zAGOB5nLWVkm1N9yIwt/oQaQUibnm6BdVmGEVrSfZ12lW4TedOIcW2gVNuLzCXWiYIOF I3uQ== X-Received: by 10.15.23.194 with SMTP id h42mr8823594eeu.123.1370840247451; Sun, 09 Jun 2013 21:57:27 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id bk1sm20281322eeb.5.2013.06.09.21.57.26 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 09 Jun 2013 21:57:27 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org, Austin Clements Subject: [PATCH v5 5/6] emacs: show move addition of :notmuch-part to separate function Date: Mon, 10 Jun 2013 05:57:12 +0100 Message-Id: <1370840233-23258-6-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com> References: <1370840233-23258-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: Mon, 10 Jun 2013 04:57:39 -0000 This separates out the adding of the :notmuch-part text property to a separate function to simplify calling from the lazy part insertion code. --- emacs/notmuch-show.el | 39 ++++++++++++++++++++++----------------- 1 files changed, 22 insertions(+), 17 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 43aa88b..6ec70c9 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -807,6 +807,27 @@ message at DEPTH in the current thread." ;; Return true if we created an overlay. t)) +(defun notmuch-show-record-part-information (part beg end) + "Store PART as a text property from BEG to END" + + ;; Record part information. Since we already inserted subparts, + ;; don't override existing :notmuch-part properties. + (notmuch-map-text-property beg end :notmuch-part + (lambda (v) (or v part))) + ;; Make :notmuch-part front sticky and rear non-sticky so it stays + ;; applied to the beginning of each line when we indent the + ;; message. Since we're operating on arbitrary renderer output, + ;; watch out for sticky specs of t, which means all properties are + ;; front-sticky/rear-nonsticky. + (notmuch-map-text-property beg end 'front-sticky + (lambda (v) (if (listp v) + (pushnew :notmuch-part v) + v))) + (notmuch-map-text-property beg end 'rear-nonsticky + (lambda (v) (if (listp v) + (pushnew :notmuch-part v) + v)))) + (defun notmuch-show-insert-bodypart (msg part depth &optional hide) "Insert the body part PART at depth DEPTH in the current thread. @@ -836,23 +857,7 @@ If HIDE is non-nil then initially hide this part." (when hide (save-excursion (notmuch-show-toggle-part-invisibility button))) - ;; Record part information. Since we already inserted subparts, - ;; don't override existing :notmuch-part properties. - (notmuch-map-text-property beg (point) :notmuch-part - (lambda (v) (or v part))) - ;; Make :notmuch-part front sticky and rear non-sticky so it stays - ;; applied to the beginning of each line when we indent the - ;; message. Since we're operating on arbitrary renderer output, - ;; watch out for sticky specs of t, which means all properties are - ;; front-sticky/rear-nonsticky. - (notmuch-map-text-property beg (point) 'front-sticky - (lambda (v) (if (listp v) - (pushnew :notmuch-part v) - v))) - (notmuch-map-text-property beg (point) 'rear-nonsticky - (lambda (v) (if (listp v) - (pushnew :notmuch-part v) - v))))) + (notmuch-show-record-part-information part beg (point)))) (defun notmuch-show-insert-body (msg body depth) "Insert the body BODY at depth DEPTH in the current thread." -- 1.7.9.1