From 952aed2ae8dc7fa873fe4dd256149664e5bc565c Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 18 May 2013 16:14:03 +2000 Subject: [PATCH] [PATCH] emacs: Fix trimming regexp in notmuch-check-exit-status --- 27/dc7d92faf8b67fc3d60408b6780c74314b1999 | 111 ++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 27/dc7d92faf8b67fc3d60408b6780c74314b1999 diff --git a/27/dc7d92faf8b67fc3d60408b6780c74314b1999 b/27/dc7d92faf8b67fc3d60408b6780c74314b1999 new file mode 100644 index 000000000..de3a515b8 --- /dev/null +++ b/27/dc7d92faf8b67fc3d60408b6780c74314b1999 @@ -0,0 +1,111 @@ +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 DFBEE431FC2 + for ; Fri, 17 May 2013 13:14:16 -0700 (PDT) +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 hSZmrlPSBoiC for ; + Fri, 17 May 2013 13:14:11 -0700 (PDT) +Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU + [18.7.68.34]) + by olra.theworths.org (Postfix) with ESMTP id 4E05D431FC9 + for ; Fri, 17 May 2013 13:14:11 -0700 (PDT) +X-AuditID: 12074422-b7f5b6d00000095d-5d-51968f90d952 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP + id 7A.19.02397.09F86915; Fri, 17 May 2013 16:14:08 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4HKE7qJ013932; + Fri, 17 May 2013 16:14:07 -0400 +Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4HKE54o004606 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Fri, 17 May 2013 16:14:06 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1UdR2T-0006Jx-NV; Fri, 17 May 2013 16:14:05 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: Fix trimming regexp in notmuch-check-exit-status +Date: Fri, 17 May 2013 16:14:03 -0400 +Message-Id: <1368821643-24179-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFlrMIsWRmVeSWpSXmKPExsUixCmqrTuhf1qgwfGjmhbXb85kdmD0eLbq + FnMAYxSXTUpqTmZZapG+XQJXxtGFPcwFc/krtt85y9rAOImni5GTQ0LAROLKo++MELaYxIV7 + 69lAbCGBfYwSx5a6djFyAdkbGSX2PfvFBOEcYZK4teMeVNVcRolnTyRAbDYBDYlt+5eDTRIR + kJbYeXc2axcjBwezgJrEny4VEFNYwEPi/HlFEJNFQFVi3sxwkGJeAQeJY+cfskCcoCjR/WwC + 2wRG3gWMDKsYZVNyq3RzEzNzilOTdYuTE/PyUot0TfVyM0v0UlNKNzGC/M/uorSD8edBpUOM + AhyMSjy8M5ynBQqxJpYVV+YeYpTkYFIS5XXoBgrxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4X1e + DJTjTUmsrEotyodJSXOwKInzXku56S8kkJ5YkpqdmlqQWgSTleHgUJLgFQSGuZBgUWp6akVa + Zk4JQpqJgxNkOA/QcNE+kOHFBYm5xZnpEPlTjLocm89PfscoxJKXn5cqJc6rAzJIAKQoozQP + bg4sbl8xigO9JcwrAFLFA4x5uEmvgJYwAS1hvTYVZElJIkJKqoExcX+2bYODw9kjf7TYlTf2 + Ttv3mX+d0K7iec7Hrt7/tHph7KmkzasaZygbi+jVFVh8Uf0/+XTLtx1RvL05LY9WrDa10vv+ + Q60meUZ497SdUe8DpErjD1jkTvrXLCf/WPXv7m133ibcvygZfMrlZuaz6twbvErmuysy+/v9 + 9Sblr5z3YI4hz+49SizFGYmGWsxFxYkAQZ3PirYCAAA= +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: Fri, 17 May 2013 20:14:17 -0000 + +For such a simple regexp, this was broken in a very complicated way. + +The intent was to strip the newline (and potentially other whitespace) +off the end of the error string so there wasn't an extra newline in +the error signal. However, the regexp was deeply dependent on the +active syntax table and the subtleties of $. We didn't notice this +because all notmuch major modes put ?\n in the whitespace class, which +makes this behaved as intended: the "\\s " matches all newlines, but +by matching the newline character, causes the $ *not* to match +*except* where it matched the empty string at the very end of the +string, which was not followed by a newline. + +However, if the syntax table declares ?\n to be non-whitespace +(lisp-mode declares it as endcomment, and is likely to be the mode +you're in when testing functions), then this regexp behaves completely +differently, matching trailing spaces at the end of every line within +the string. + +The solution is to say what we mean for whitespace *and* to switch +from $ to \', which matches only the end of the string, rather than +the end of each line. Both are necessary or this will strip away +interior newlines, which is not what we want. +--- + emacs/notmuch-lib.el | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +index 790136e..59b1ce3 100644 +--- a/emacs/notmuch-lib.el ++++ b/emacs/notmuch-lib.el +@@ -438,7 +438,7 @@ You may need to restart Emacs or upgrade your notmuch package.")) + (if err + ;; We have an error message straight from the CLI. + (notmuch-logged-error +- (replace-regexp-in-string "\\s $" "" err) extra) ++ (replace-regexp-in-string "[ \n\r\t\f]*\\'" "" err) extra) + ;; We only have combined output from the CLI; don't inundate + ;; the user with it. Mimic `process-lines'. + (notmuch-logged-error (format "%s exited with status %s" +-- +1.7.10.4 + -- 2.26.2