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 EFE07431FC9 for ; Sat, 18 May 2013 06:45:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 xNRq5UVkHoJL for ; Sat, 18 May 2013 06:45:37 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 90271431FC2 for ; Sat, 18 May 2013 06:45:37 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 4D954100094; Sat, 18 May 2013 16:45:31 +0300 (EEST) From: Tomi Ollila To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs: Fix trimming regexp in notmuch-check-exit-status In-Reply-To: <1368821643-24179-1-git-send-email-amdragon@mit.edu> References: <1368821643-24179-1-git-send-email-amdragon@mit.edu> User-Agent: Notmuch/0.15.2+99~g7e455bc (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain 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: Sat, 18 May 2013 13:45:42 -0000 On Fri, May 17 2013, Austin Clements wrote: > 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. LGTM. Tomi > --- > 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 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch