unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space
@ 2014-10-21  9:59 Niels Möller
  2017-03-25 21:41 ` npostavs
  0 siblings, 1 reply; 3+ messages in thread
From: Niels Möller @ 2014-10-21  9:59 UTC (permalink / raw)
  To: 18783

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.






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space
  2014-10-21  9:59 bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space Niels Möller
@ 2017-03-25 21:41 ` npostavs
  2017-03-31  1:06   ` npostavs
  0 siblings, 1 reply; 3+ messages in thread
From: npostavs @ 2017-03-25 21:41 UTC (permalink / raw)
  To: Niels Möller; +Cc: 18783

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 887 bytes --]

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space
  2017-03-25 21:41 ` npostavs
@ 2017-03-31  1:06   ` npostavs
  0 siblings, 0 replies; 3+ messages in thread
From: npostavs @ 2017-03-31  1:06 UTC (permalink / raw)
  To: Niels Möller; +Cc: 18783

tags 18783 fixed
close 18783 26.1
quit

npostavs@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)






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-31  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21  9:59 bug#18783: 24.4; fixup-whitespace at end of line leaves a trailing space Niels Möller
2017-03-25 21:41 ` npostavs
2017-03-31  1:06   ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).