]> git.cworth.org Git - obsolete/notmuch-old/commitdiff
emacs: Fix trimming regexp in notmuch-check-exit-status
authorAustin Clements <amdragon@MIT.EDU>
Fri, 17 May 2013 20:14:03 +0000 (16:14 -0400)
committerDavid Bremner <bremner@debian.org>
Mon, 27 May 2013 21:19:03 +0000 (18:19 -0300)
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

index 790136e035594c30aedc77f3e8d4a430b2f9d47d..59b1ce3ffecfaf1e310ac3667446e93cc260d39f 100644 (file)
@@ -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"