Subject: bug#25767: [PATCH] 25.1.91; abbrev-prefix-mark expansion inserts newline

From: Allen Li <[email-masked]>
Date: Thu, 23 Feb 2017 21:34:59 -0800

Here's the quick fix.  I will opt out of doing more invasive refactoring.

I tried running abbrev-tests.el, but they don't seem to pass, even
without my change.  I am running these tests by: (eval-buffer)
followed by (ert).

I am getting undefined variable errors that I can fix with (require
'obarray).  Am I running these tests incorrectly or should I add a
(require 'obarray) to abbrev-tests.el?

I am also getting a type error for abbrev-table-p-test unrelated to my change.

There appear to be no tests for the actual abbrev expansion.

---
 lisp/abbrev.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index cbc604c23d..01ad3d478f 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -720,9 +720,10 @@ then ABBREV is looked up in that table only."
           (setq start abbrev-start-location)
           (setq abbrev-start-location nil)
           ;; Remove the hyphen inserted by `abbrev-prefix-mark'.
-          (if (and (< start (point-max))
-                   (eq (char-after start) ?-))
-              (delete-region start (1+ start)))
+          (when (and (< start (point-max))
+                     (eq (char-after start) ?-))
+            (delete-region start (1+ start))
+            (setq pos (1- pos)))
           (skip-syntax-backward " ")
           (setq end (point))
           (when (> end start)
-- 
2.11.1