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 5E4C5429E5F for ; Tue, 17 Jan 2012 17:25:57 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 6A4jHd0Gcg-9 for ; Tue, 17 Jan 2012 17:25:57 -0800 (PST) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id D1820429E27 for ; Tue, 17 Jan 2012 17:25:56 -0800 (PST) X-AuditID: 12074424-b7fae6d000000906-f0-4f161fa2aee1 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id 8D.59.02310.2AF161F4; Tue, 17 Jan 2012 20:25:54 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q0I1PrG7001243; Tue, 17 Jan 2012 20:25:54 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0I1Pqva012791 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 17 Jan 2012 20:25:52 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RnKHU-0008P3-0z; Tue, 17 Jan 2012 20:25:40 -0500 Date: Tue, 17 Jan 2012 20:25:39 -0500 From: Austin Clements To: Mark Walters Subject: Re: [PATCH v3] Make buttons for attachments allow viewing as well as saving Message-ID: <20120118012539.GA16740@mit.edu> References: <87lip5rj43.fsf@qmul.ac.uk> <1326843886-18387-1-git-send-email-markwalters1009@gmail.com> <20120117235318.GZ16740@mit.edu> <87ipk9rgg9.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ipk9rgg9.fsf@qmul.ac.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IR4hRV1l0kL+Zv8H+vosXquTwW12/OZHZg 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4MjbubGcrOMlbcbHvKFsD4zGuLkZODgkBE4mJ x2czQthiEhfurWfrYuTiEBLYxyhx8VwXI4SzgVHi5cEPzBDOSSaJdYdWQWWWMEqsbTvBDNLP IqAqsWjCMzYQm01AQ2Lb/uVgc0UEdCRuH1rADmIzC0hLfPvdzARiCwuESXxt3g7WywtUc2zi IjBbSGAFo8TC7WIQcUGJkzOfsED0aknc+PcSqJcDbM7yfxwgJifQqkfnMkAqRAVUJKac3MY2 gVFoFpLmWUiaZyE0L2BkXsUom5JbpZubmJlTnJqsW5ycmJeXWqRrrpebWaKXmlK6iREU1Owu KjsYmw8pHWIU4GBU4uGV2CDqL8SaWFZcmXuIUZKDSUmUlx8YE0J8SfkplRmJxRnxRaU5qcWH GCU4mJVEeFmZgXK8KYmVValF+TApaQ4WJXFeDa13fkIC6YklqdmpqQWpRTBZGQ4OJQlef5Ch gkWp6akVaZk5JQhpJg5OkOE8QMMZQWp4iwsSc4sz0yHypxgVpcR5jUASAiCJjNI8uF5Y0nnF KA70ijCvI0gVDzBhwXW/AhrMBDQ4p1UIZHBJIkJKqoExe0Lzv8ffnQs3hcytj3riNi/rwceJ Fy+d4V+4s+5wtHO1wrd3k7TXsz9yOsDqxGnCxmCz8PLTq6zLNNe4sy3PTRZXbb+6mMu3KoL7 Tt6JDtY5L6w0zncm27YKeId1iRlzbegzlZFPuVlfdHv6mqshr9m6bP7slOSWYah7/1Pcz2rl 3CxBqSYlluKMREMt5qLiRACzgEv7FQMAAA== Cc: notmuch@notmuchmail.org 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: Wed, 18 Jan 2012 01:25:57 -0000 Quoth Mark Walters on Jan 18 at 12:40 am: > > > Oof, sorry. Two more tweaks that I really should have caught in the > > previous version. After that this gets my automatic +1. > > Both fixed. I have also fixed the bug I mentioned (missing filename when > "view" falls back on save); I couldn't make it work with the > "no-default" option. However overriding mm-save-part with flet seems to > do the trick. Oh, indeed. I'd foolishly assumed that when mm-display-part passed the function mailcap-save-binary-file as the method to mm-display-external that it would actually *use* that function, but you're right that it uses mm-save-part. > +(defun notmuch-show-view-part (message-id nth &optional filename content-type ) > + (notmuch-with-temp-part-buffer message-id nth > + ;; set mm-inlined-types to nil to force an external viewer > + (let ((handle (mm-make-handle (current-buffer) (list content-type))) > + (mm-inlined-types nil)) > + ;; We override mm-save-part as notmuch-show-save-part is better > + ;; since it offers the filename > + (flet ((mm-save-part (&rest args) (ignore))) > + (or (mm-display-part handle) > + (notmuch-show-save-part message-id nth filename content-type)))))) > > Is that a reasonable solution? It's *probably* safe to depend on the result of mm-display-part, but you can avoid the question altogether by simply calling notmuch-show-save-part from your flet mm-save-part. E.g., (flet ((mm-save-part (&rest args) (notmuch-show-save-part message-id nth filename content-type))) (mm-display-part handle)) (Yeah, flet indentation is lame.) > Best wishes > > Mark