From: Austin Clements Date: Mon, 30 Jan 2012 23:46:55 +0000 (+1900) Subject: Re: [PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width' madness. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=f30c45b791faa7650e0c534635ae872f6830fb72;p=notmuch-archives.git Re: [PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width' madness. --- diff --git a/78/49ae3f6db6fabbf638a5f1caf966918e44b311 b/78/49ae3f6db6fabbf638a5f1caf966918e44b311 new file mode 100644 index 000000000..1d387cefb --- /dev/null +++ b/78/49ae3f6db6fabbf638a5f1caf966918e44b311 @@ -0,0 +1,129 @@ +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 4031F431E64 + for ; Mon, 30 Jan 2012 15:47:49 -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 B1hpSaMdi2zw for ; + Mon, 30 Jan 2012 15:47:48 -0800 (PST) +Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU + [18.9.25.13]) + by olra.theworths.org (Postfix) with ESMTP id AF52F431FBC + for ; Mon, 30 Jan 2012 15:47:48 -0800 (PST) +X-AuditID: 1209190d-b7fbf6d0000008ba-db-4f272c248ad6 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id 1E.4B.02234.42C272F4; Mon, 30 Jan 2012 18:47:48 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0UNllpT012559; + Mon, 30 Jan 2012 18:47:48 -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 q0UNlkDB007614 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 30 Jan 2012 18:47:47 -0500 (EST) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1Rs0w3-0002V6-OE; Mon, 30 Jan 2012 18:46:55 -0500 +Date: Mon, 30 Jan 2012 18:46:55 -0500 +From: Austin Clements +To: David Edmondson +Subject: Re: [PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width' + madness. +Message-ID: <20120130234655.GU17991@mit.edu> +References: <1327496913-4946-1-git-send-email-dme@dme.org> + <1327918561-16245-1-git-send-email-dme@dme.org> + <1327918561-16245-2-git-send-email-dme@dme.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1327918561-16245-2-git-send-email-dme@dme.org> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1lXRUfc3WD+X12LfnS1MFtdvzmR2 + YPLY9fwvk8ezVbeYA5iiuGxSUnMyy1KL9O0SuDI+37rFXnCAt2JWxz7WBsYNXF2MnBwSAiYS + a6f8YYGwxSQu3FvP1sXIxSEksI9Ron/+T1YIZwOjxIf2lVDOSSaJLf+3MUE4SxglDv5ZxAbS + zyKgKjG19x/YLDYBDYlt+5czgtgiAooS/7+tYAexmQWkJb79bmYCsYUFAiWWXn8P1ssroCOx + 9NkPsF4hgXmMEtfnWELEBSVOznzCAtGrJXHj30ugXg6wOcv/cYCYnAI2ElvalUAqRAVUJKac + 3MY2gVFoFpLmWUiaZyE0L2BkXsUom5JbpZubmJlTnJqsW5ycmJeXWqRrpJebWaKXmlK6iREc + 1pK8OxjfHVQ6xCjAwajEwyvwSc1fiDWxrLgy9xCjJAeTkijvEXV1fyG+pPyUyozE4oz4otKc + 1OJDjBIczEoivG9WA5XzpiRWVqUW5cOkpDlYlMR5VbXe+QkJpCeWpGanphakFsFkZTg4lCR4 + j2kDDRUsSk1PrUjLzClBSDNxcIIM5wEavhikhre4IDG3ODMdIn+KUVFKHCIhAJLIKM2D64Wl + nVeM4kCvCPNuBaniAaYsuO5XQIOZgAY/Z1AFGVySiJCSamBczXB006Pb6y4p9pzbV75nbYfh + icRvEfPe33p++Lx1uI0eZ0D0nUDe5fU6+/asdrn/M/x3bnHjt7mHtCZN+bpu1r3J1safpu5h + 6OmrElJ72eF8oadqTqdwE98fy8erLRduP3t26YFIxbr1/u8PKN25eMG4b2r5kRJZHY3qloUT + BVr/7OPfV1dxQomlOCPRUIu5qDgRAEzGpDkWAwAA +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: Mon, 30 Jan 2012 23:47:49 -0000 + +LGTM. One comment that you can take or leave. + +Quoth David Edmondson on Jan 30 at 10:16 am: +> There's no need to call `truncate-string-to-width' twice in this code +> path. +> --- +> emacs/notmuch.el | 22 ++++++++++------------ +> 1 files changed, 10 insertions(+), 12 deletions(-) +> +> diff --git a/emacs/notmuch.el b/emacs/notmuch.el +> index 72f78ed..d4d6904 100644 +> --- a/emacs/notmuch.el +> +++ b/emacs/notmuch.el +> @@ -469,18 +469,16 @@ Complete list of currently available key bindings: +> (let ((thread-id (notmuch-search-find-thread-id)) +> (subject (notmuch-search-find-subject))) +> (if (> (length thread-id) 0) +> - (notmuch-show thread-id +> - (current-buffer) +> - notmuch-search-query-string +> - ;; name the buffer based on notmuch-search-find-subject +> - (if (string-match "^[ \t]*$" subject) +> - "[No Subject]" +> - (truncate-string-to-width +> - (concat "*" +> - (truncate-string-to-width subject 32 nil nil t) +> - "*") +> - 32 nil nil t)) +> - crypto-switch) +> + (progn +> + (if (string-match "^[ \t]*$" subject) +> + (setq subject "[No Subject]")) +> + +> + (notmuch-show thread-id +> + (current-buffer) +> + notmuch-search-query-string +> + ;; Name the buffer based on the subject. +> + (concat "*" (truncate-string-to-width subject 30 nil nil t) "*") +> + crypto-switch)) +> (message "End of search results.")))) + +Should this instead be an `error'? It that makes sense, it would also +simplify the code, since you could + +(if (= (length thread-id) 0) + (error "End of search results.")) + + +> +> (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)