]> git.eshelyaron.com Git - emacs.git/commit
Simplify ‘delete-trailing-whitespace’ by not treating \n as whitespace
authorMichal Nazarewicz <mina86@mina86.com>
Tue, 21 Jun 2016 14:46:52 +0000 (16:46 +0200)
committerMichal Nazarewicz <mina86@mina86.com>
Mon, 4 Jul 2016 21:44:06 +0000 (23:44 +0200)
commit7c6317a0498b6690ea668909ac012cb45e6f809b
treeaddc7968bfe0759b83b35dc95acb2d35d835f576
parentdc294483af221066724f1007a595016b47fb5814
Simplify ‘delete-trailing-whitespace’ by not treating \n as whitespace

* lisp/simple.el (delete-trailing-whitespace): Set newline’s character
syntax to non-whitespace so that ‘\s-’ regular expression does not match
it.

This simplifies the loop slightly since a simple ‘\s-+$’ can be used and
as a consequence ‘line-beginning-position’ function does not need to be
called any longer.

Furthermore, when newline has whitespace syntax, ‘\s-$’ regular
expression ends up matching empty lins since ‘\s-’ matches newline
characetr of proceeding line.  This leads to needless loop iterations.

Since previous change to ‘delete-trailing-whitespace’ already introduced
‘with-syntax-table’, take advantage of it and also overwrite newline’s
character syntax.
lisp/simple.el
test/lisp/simple-tests.el