Re: [PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width' madness.
authorAustin Clements <amdragon@MIT.EDU>
Mon, 30 Jan 2012 23:46:55 +0000 (18:46 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:44 +0000 (09:43 -0800)
78/49ae3f6db6fabbf638a5f1caf966918e44b311 [new file with mode: 0644]

diff --git a/78/49ae3f6db6fabbf638a5f1caf966918e44b311 b/78/49ae3f6db6fabbf638a5f1caf966918e44b311
new file mode 100644 (file)
index 0000000..1d387ce
--- /dev/null
@@ -0,0 +1,129 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4031F431E64\r
+       for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 15:47:49 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id B1hpSaMdi2zw for <notmuch@notmuchmail.org>;\r
+       Mon, 30 Jan 2012 15:47:48 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
+       [18.9.25.13])\r
+       by olra.theworths.org (Postfix) with ESMTP id AF52F431FBC\r
+       for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 15:47:48 -0800 (PST)\r
+X-AuditID: 1209190d-b7fbf6d0000008ba-db-4f272c248ad6\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 1E.4B.02234.42C272F4; Mon, 30 Jan 2012 18:47:48 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0UNllpT012559; \r
+       Mon, 30 Jan 2012 18:47:48 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0UNlkDB007614\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Mon, 30 Jan 2012 18:47:47 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Rs0w3-0002V6-OE; Mon, 30 Jan 2012 18:46:55 -0500\r
+Date: Mon, 30 Jan 2012 18:46:55 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: David Edmondson <dme@dme.org>\r
+Subject: Re: [PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width'\r
+ madness.\r
+Message-ID: <20120130234655.GU17991@mit.edu>\r
+References: <1327496913-4946-1-git-send-email-dme@dme.org>\r
+       <1327918561-16245-1-git-send-email-dme@dme.org>\r
+       <1327918561-16245-2-git-send-email-dme@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1327918561-16245-2-git-send-email-dme@dme.org>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1lXRUfc3WD+X12LfnS1MFtdvzmR2\r
+       YPLY9fwvk8ezVbeYA5iiuGxSUnMyy1KL9O0SuDI+37rFXnCAt2JWxz7WBsYNXF2MnBwSAiYS\r
+       a6f8YYGwxSQu3FvP1sXIxSEksI9Ron/+T1YIZwOjxIf2lVDOSSaJLf+3MUE4SxglDv5ZxAbS\r
+       zyKgKjG19x/YLDYBDYlt+5czgtgiAooS/7+tYAexmQWkJb79bmYCsYUFAiWWXn8P1ssroCOx\r
+       9NkPsF4hgXmMEtfnWELEBSVOznzCAtGrJXHj30ugXg6wOcv/cYCYnAI2ElvalUAqRAVUJKac\r
+       3MY2gVFoFpLmWUiaZyE0L2BkXsUom5JbpZubmJlTnJqsW5ycmJeXWqRrpJebWaKXmlK6iREc\r
+       1pK8OxjfHVQ6xCjAwajEwyvwSc1fiDWxrLgy9xCjJAeTkijvEXV1fyG+pPyUyozE4oz4otKc\r
+       1OJDjBIczEoivG9WA5XzpiRWVqUW5cOkpDlYlMR5VbXe+QkJpCeWpGanphakFsFkZTg4lCR4\r
+       j2kDDRUsSk1PrUjLzClBSDNxcIIM5wEavhikhre4IDG3ODMdIn+KUVFKHCIhAJLIKM2D64Wl\r
+       nVeM4kCvCPNuBaniAaYsuO5XQIOZgAY/Z1AFGVySiJCSamBczXB006Pb6y4p9pzbV75nbYfh\r
+       icRvEfPe33p++Lx1uI0eZ0D0nUDe5fU6+/asdrn/M/x3bnHjt7mHtCZN+bpu1r3J1safpu5h\r
+       6OmrElJ72eF8oadqTqdwE98fy8erLRduP3t26YFIxbr1/u8PKN25eMG4b2r5kRJZHY3qloUT\r
+       BVr/7OPfV1dxQomlOCPRUIu5qDgRAEzGpDkWAwAA\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 30 Jan 2012 23:47:49 -0000\r
+\r
+LGTM.  One comment that you can take or leave.\r
+\r
+Quoth David Edmondson on Jan 30 at 10:16 am:\r
+> There's no need to call `truncate-string-to-width' twice in this code\r
+> path.\r
+> ---\r
+>  emacs/notmuch.el |   22 ++++++++++------------\r
+>  1 files changed, 10 insertions(+), 12 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index 72f78ed..d4d6904 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -469,18 +469,16 @@ Complete list of currently available key bindings:\r
+>    (let ((thread-id (notmuch-search-find-thread-id))\r
+>      (subject (notmuch-search-find-subject)))\r
+>      (if (> (length thread-id) 0)\r
+> -    (notmuch-show thread-id\r
+> -                  (current-buffer)\r
+> -                  notmuch-search-query-string\r
+> -                  ;; name the buffer based on notmuch-search-find-subject\r
+> -                  (if (string-match "^[ \t]*$" subject)\r
+> -                      "[No Subject]"\r
+> -                    (truncate-string-to-width\r
+> -                     (concat "*"\r
+> -                             (truncate-string-to-width subject 32 nil nil t)\r
+> -                             "*")\r
+> -                     32 nil nil t))\r
+> -                  crypto-switch)\r
+> +    (progn\r
+> +      (if (string-match "^[ \t]*$" subject)\r
+> +          (setq subject "[No Subject]"))\r
+> +\r
+> +      (notmuch-show thread-id\r
+> +                    (current-buffer)\r
+> +                    notmuch-search-query-string\r
+> +                    ;; Name the buffer based on the subject.\r
+> +                    (concat "*" (truncate-string-to-width subject 30 nil nil t) "*")\r
+> +                    crypto-switch))\r
+>        (message "End of search results."))))\r
+\r
+Should this instead be an `error'?  It that makes sense, it would also\r
+simplify the code, since you could\r
+\r
+(if (= (length thread-id) 0)\r
+    (error "End of search results."))\r
+<current progn body>\r
+\r
+>  \r
+>  (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)\r