Subject: 24.4; fixup-whitespace at end of line leaves a trailing space

From: [email-masked] (Niels Möller)
Date: Tue, 21 Oct 2014 11:59:11 +0200

The function fixup-whitespace leaves a trailing space when invoked at
the end of a line (and this bug is a lot older than emacs-24.4).

To reproduce: Run emacs -Q. Type x, to get a line containing "x" and
with point at the end. Type M-x fixup-whitespace RET. A space is added,
so we get a line containing "x ".

I think this is a bug, because it's inconsistent with spacing
conventions I'm aware of, and the space is deleted by emacs' M-x
whitespace-cleanup.

Patch below seems to solve the problem.

Best regards,
/Niels Möller

--- simple.el	2014-08-22 17:52:28.000000000 +0200
+++ simple.el.patched	2014-10-21 11:38:59.000000000 +0200
@@ -787,7 +787,7 @@ Leave one space or none, according to th
   (interactive "*")
   (save-excursion
     (delete-horizontal-space)
-    (if (or (looking-at "^\\|\\s)")
+    (if (or (looking-at "^\\|$\\|\\s)")
 	    (save-excursion (forward-char -1)
 			    (looking-at "$\\|\\s(\\|\\s'")))
 	nil

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.