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 52AAC431FBD for ; Mon, 12 May 2014 15:16:38 -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 0INoLzRKDcVw for ; Mon, 12 May 2014 15:16:32 -0700 (PDT) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 63049431FAF for ; Mon, 12 May 2014 15:16:32 -0700 (PDT) Received: by mail-wi0-f175.google.com with SMTP id f8so5304879wiw.2 for ; Mon, 12 May 2014 15:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=5nysejPNH/ejsl168bRP1peAljKUmhzPa4ucnb9p/K4=; b=NT5rZAbz0w0Aj6XFYR486lQGFSnRw3mSQpdroddo2HUV5mLxkoXbmZa/CnA0Y7sGfX mfIF709+XVsDlTxd5M3C+qR6Kh6PbITWQ8cYEC2je0c1rs8MnnFElGY13xDMn1tZLvS8 M7f8oZZHugiQ3FrbPLEK7JT/CiSJLdxfSP0FN+i5uOT5rpmyhfr0q9e+U4RuRnHDXvzO zxbAiiNIkIJyBbs/NGdpdTfD9XqdUAk0zCZ4Abxg1xnXxDSlon8FhPjmabDZmm4qoUii nWTozkrIVsuUmNSvVSjTmdvwILRJisRog7RhwjYxU9glz+SkN1ZZ5+UC9TVS70vEq3Gp WweA== X-Received: by 10.180.107.97 with SMTP id hb1mr17841660wib.20.1399932991337; Mon, 12 May 2014 15:16:31 -0700 (PDT) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by mx.google.com with ESMTPSA id ek4sm18392049wib.9.2014.05.12.15.16.30 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 12 May 2014 15:16:30 -0700 (PDT) From: Mark Walters To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v3 3/9] emacs/show: Accommodate the lack of part header buttons In-Reply-To: <1399897769-26809-4-git-send-email-dme@dme.org> References: <87sixdujkv.fsf@qmul.ac.uk> <1399897769-26809-1-git-send-email-dme@dme.org> <1399897769-26809-4-git-send-email-dme@dme.org> User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Mon, 12 May 2014 23:16:28 +0100 Message-ID: <87mwemk5hf.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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, 12 May 2014 22:16:38 -0000 On Mon, 12 May 2014, David Edmondson wrote: > Various pieces of code assumed (reasonably) that part header buttons > are present. Modify them to avoid problems if no part headers were > inserted. Despite your reservations on irc this looks fine to me. MW > --- > emacs/notmuch-show.el | 88 ++++++++++++++++++++++++++++----------------------- > 1 file changed, 48 insertions(+), 40 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index f78a0ab..e511655 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -494,36 +494,37 @@ message at DEPTH in the current thread." > > (defun notmuch-show-toggle-part-invisibility (&optional button) > (interactive) > - (let* ((button (or button (button-at (point)))) > - (overlay (button-get button 'overlay)) > - (lazy-part (button-get button :notmuch-lazy-part))) > - ;; We have a part to toggle if there is an overlay or if there is a lazy part. > - ;; If neither is present we cannot toggle the part so we just return nil. > - (when (or overlay lazy-part) > - (let* ((show (button-get button :notmuch-part-hidden)) > - (new-start (button-start button)) > - (button-label (button-get button :base-label)) > - (old-point (point)) > - (properties (text-properties-at (button-start button))) > - (inhibit-read-only t)) > - ;; Toggle the button itself. > - (button-put button :notmuch-part-hidden (not show)) > - (goto-char new-start) > - (insert "[ " button-label (if show " ]" " (hidden) ]")) > - (set-text-properties new-start (point) properties) > - (let ((old-end (button-end button))) > - (move-overlay button new-start (point)) > - (delete-region (point) old-end)) > - (goto-char (min old-point (1- (button-end button)))) > - ;; Return nil if there is a lazy-part, it is empty, and we are > - ;; trying to show it. In all other cases return t. > - (if lazy-part > - (when show > - (button-put button :notmuch-lazy-part nil) > - (notmuch-show-lazy-part lazy-part button)) > - ;; else there must be an overlay. > - (overlay-put overlay 'invisible (not show)) > - t))))) > + (let ((button (or button (button-at (point))))) > + (when button > + (let ((overlay (button-get button 'overlay)) > + (lazy-part (button-get button :notmuch-lazy-part))) > + ;; We have a part to toggle if there is an overlay or if there is a lazy part. > + ;; If neither is present we cannot toggle the part so we just return nil. > + (when (or overlay lazy-part) > + (let* ((show (button-get button :notmuch-part-hidden)) > + (new-start (button-start button)) > + (button-label (button-get button :base-label)) > + (old-point (point)) > + (properties (text-properties-at (button-start button))) > + (inhibit-read-only t)) > + ;; Toggle the button itself. > + (button-put button :notmuch-part-hidden (not show)) > + (goto-char new-start) > + (insert "[ " button-label (if show " ]" " (hidden) ]")) > + (set-text-properties new-start (point) properties) > + (let ((old-end (button-end button))) > + (move-overlay button new-start (point)) > + (delete-region (point) old-end)) > + (goto-char (min old-point (1- (button-end button)))) > + ;; Return nil if there is a lazy-part, it is empty, and we are > + ;; trying to show it. In all other cases return t. > + (if lazy-part > + (when show > + (button-put button :notmuch-lazy-part nil) > + (notmuch-show-lazy-part lazy-part button)) > + ;; else there must be an overlay. > + (overlay-put overlay 'invisible (not show)) > + t))))))) > > ;; MIME part renderers > > @@ -632,14 +633,17 @@ message at DEPTH in the current thread." > t) > > (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth button) > - (button-put button 'face 'notmuch-crypto-part-header) > - ;; add signature status button if sigstatus provided > + (when button > + (button-put button 'face 'notmuch-crypto-part-header)) > + ;; Add signature status button if sigstatus provided. > (if (plist-member part :sigstatus) > (let* ((from (notmuch-show-get-header :From msg)) > (sigstatus (car (plist-get part :sigstatus)))) > (notmuch-crypto-insert-sigstatus-button sigstatus from)) > - ;; if we're not adding sigstatus, tell the user how they can get it > - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")) > + ;; If we're not adding the signature status, tell the user how > + ;; they can get it. > + (when button > + (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))) > > (let ((inner-parts (plist-get part :content)) > (start (point))) > @@ -653,17 +657,20 @@ message at DEPTH in the current thread." > t) > > (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth button) > - (button-put button 'face 'notmuch-crypto-part-header) > - ;; add encryption status button if encstatus specified > + (when button > + (button-put button 'face 'notmuch-crypto-part-header)) > + ;; Add encryption status button if encryption status is specified. > (if (plist-member part :encstatus) > (let ((encstatus (car (plist-get part :encstatus)))) > (notmuch-crypto-insert-encstatus-button encstatus) > - ;; add signature status button if sigstatus specified > + ;; Add signature status button if signature status is > + ;; specified. > (if (plist-member part :sigstatus) > (let* ((from (notmuch-show-get-header :From msg)) > (sigstatus (car (plist-get part :sigstatus)))) > (notmuch-crypto-insert-sigstatus-button sigstatus from)))) > - ;; if we're not adding encstatus, tell the user how they can get it > + ;; If we're not adding the encryption status, tell the user how > + ;; they can get it. > (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")) > > (let ((inner-parts (plist-get part :content)) > @@ -930,8 +937,9 @@ useful for quoting in replies)." > > (if show-part > (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button) > - (button-put button :notmuch-lazy-part > - (list msg part mime-type nth depth button))) > + (when button > + (button-put button :notmuch-lazy-part > + (list msg part mime-type nth depth button)))) > > ;; Some of the body part handlers leave point somewhere up in the > ;; part, so we make sure that we're down at the end. > -- > 2.0.0.rc0 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch