Improved the search to catch warnings from the build subprocess.
The build subprocess' output is buffered (but not line buffered).
As a result partial lines are inserted. If the previous insert ended
in the middle of the pattern we are looking for, the search will fail (end missing).
When the second part is inserted, the search will also fail because this
time we start looking from the middle of the pattern (beginning missing).
To work around that, we always match from the beginning of the line.
diff --git a/ide/emacs/android-compile.el b/ide/emacs/android-compile.el
index 1b5092f..ef7bc88 100644
@@ -86,9 +86,13 @@
;; called when new data has been inserted in the compile buffer. Don't
;; assume that only one line has been inserted, typically more than
;; one has changed since the last call due to stdout buffering.
-;; We store in a buffer local variable the process to detect a new
-;; compilation. We also store the point position to limit our
-;; search. On entry (point) is at the end of the last block inserted.
+;; We store in a buffer local variable `android-compile-context' a
+;; list with 2 elements, the process and point position at the end of
+;; the last invocation. The process is used to detect a new
+;; compilation. The point position is used to limit our search.
+;; On entry (point) is at the end of the last block inserted.
(defun android-compile-filter ()
"Filter to discard unwanted lines from the compilation buffer.
@@ -114,6 +118,14 @@
+ ;; Need to go back at the beginning of the line before we
+ ;; start the search: because of the buffering, the previous
+ ;; block inserted may have ended in the middle of the
+ ;; expression we are trying to match. As result we missed it
+ ;; last time and we would miss it again if we started just
+ ;; where we left of. By processing the line from the start we
+ ;; are catching that case.
+ (forward-line 0)
(while (search-forward-regexp android-compile-ignore-re end t)
;; Nuke the line
(let ((bol (point-at-bol)))