[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space
From: |
npostavs |
Subject: |
bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space |
Date: |
Sat, 25 Mar 2017 17:41:07 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
tags 18783 patch
quit
nisse@lysator.liu.se (Niels Möller) writes:
> 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).
Seems to have been present since the beginning, 1991-12-21 "Initial
revision" shows the same code.
> 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.
Looks good to me, I will push to master in a few days.
>From afdf5b6f8bbea6863e82f3890cd7f750741f95b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Tue, 21 Oct 2014 11:59:11 +0200
Subject: [PATCH] Stop `fixup-whitespace' adding trailing whitespace
(Bug#18783)
* lisp/simple.el (fixup-whitespace): Insert no spaces if point is at
end of line after deleting horizontal whitespace.
Copyright-paperwork-exempt: yes
---
lisp/simple.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index 7360e456e4..681cf83807 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -833,7 +833,7 @@ fixup-whitespace
(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
--
2.11.1
- bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space,
npostavs <=