summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2017-11-11 23:44:52 +0000
committerJoão Távora <joaotavora@gmail.com>2017-11-11 23:44:52 +0000
commite286b3381fa1be64174832560da963b1c0191640 (patch)
tree868f64028e662664e8d47d21027213f812f20d68 /lisp
parent9533d76b0b5bfe2df1cccc55a92c2545b1de4e2b (diff)
downloademacs-e286b3381fa1be64174832560da963b1c0191640.tar.gz
Fix more flymake-diag-region eob corner cases and add tests (bug#29201)
* lisp/progmodes/flymake.el (flymake-diag-region): Correct more eob corner cases. * test/lisp/progmodes/flymake-tests.el (eob-region-and-trailing-newline): New test.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/flymake.el16
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index b4ab7f223f2..241ea00d645 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -318,7 +318,11 @@ region is invalid."
(goto-char (point-min))
(forward-line (1- line))
(cl-flet ((fallback-bol
- () (progn (back-to-indentation) (point)))
+ ()
+ (back-to-indentation)
+ (if (eobp)
+ (line-beginning-position 0)
+ (point)))
(fallback-eol
(beg)
(progn
@@ -335,11 +339,11 @@ region is invalid."
(not (= sexp-end beg))
sexp-end)
(and (< (goto-char (1+ beg)) (point-max))
- (point))))
- (safe-end (or end
- (fallback-eol beg))))
- (cons (if end beg (fallback-bol))
- safe-end))
+ (point)))))
+ (if end
+ (cons beg end)
+ (cons (setq beg (fallback-bol))
+ (fallback-eol beg))))
(let* ((beg (fallback-bol))
(end (fallback-eol beg)))
(cons beg end)))))))