GNU bug report logs - #18783
24.4; fixup-whitespace at end of line leaves a trailing space

Previous Next

Package: emacs;

Reported by: nisse <at> lysator.liu.se (Niels Möller)

Date: Tue, 21 Oct 2014 10:00:03 UTC

Severity: minor

Tags: fixed, patch

Found in version 24.4

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18783 in the body.
You can then email your comments to 18783 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18783; Package emacs. (Tue, 21 Oct 2014 10:00:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to nisse <at> lysator.liu.se (Niels Möller):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 21 Oct 2014 10:00:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: nisse <at> lysator.liu.se (Niels Möller)
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4; fixup-whitespace at end of line leaves a trailing space
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.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18783; Package emacs. (Sat, 25 Mar 2017 21:40:02 GMT) Full text and rfc822 format available.

Message #8 received at 18783 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: nisse <at> lysator.liu.se (Niels Möller)
Cc: 18783 <at> debbugs.gnu.org
Subject: Re: bug#18783: 24.4;
 fixup-whitespace at end of line leaves a trailing space
Date: Sat, 25 Mar 2017 17:41:07 -0400
[Message part 1 (text/plain, inline)]
tags 18783 patch
quit

nisse <at> 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.

[0001-Stop-fixup-whitespace-adding-trailing-whitespace-Bug.patch (text/x-diff, inline)]
From afdf5b6f8bbea6863e82f3890cd7f750741f95b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse <at> 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


Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sat, 25 Mar 2017 21:40:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18783; Package emacs. (Fri, 31 Mar 2017 01:06:02 GMT) Full text and rfc822 format available.

Message #13 received at 18783 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: nisse <at> lysator.liu.se (Niels Möller)
Cc: 18783 <at> debbugs.gnu.org
Subject: Re: bug#18783: 24.4;
 fixup-whitespace at end of line leaves a trailing space
Date: Thu, 30 Mar 2017 21:06:39 -0400
tags 18783 fixed
close 18783 26.1
quit

npostavs <at> users.sourceforge.net writes:

> Looks good to me, I will push to master in a few days.

Pushed [1: d1e113ee60].

1: 2017-03-30 21:05:08 -0400 d1e113ee60a0750acbbc0da569f7cc1bab88f11c
  Stop `fixup-whitespace' adding trailing whitespace (Bug#18783)





Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Fri, 31 Mar 2017 01:06:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 18783 <at> debbugs.gnu.org and nisse <at> lysator.liu.se (Niels Möller) Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Fri, 31 Mar 2017 01:06:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 28 Apr 2017 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 105 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.