help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: removing white space highlight


From: Emanuel Berg
Subject: Re: removing white space highlight
Date: Sun, 21 Feb 2016 02:48:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Bob Proulx <bob@proulx.com> writes:

>> Of course, there shouldn't be any superfluous
>> whitespace trailing individual text lines *or* the
>> file contents itself.
>> 
>> Here one way to do it ...
>
> That is one way to do it. However I don't think it
> is a good idea to do this automatically every time.
> I would rather see that it needs to be done and the
> do it intentionally.

Why?

> Usually I will do one whitespace only cleanup with
> no other changes and do it first. That way diff -b
> or -w or -B or other combination will show as clean
> with no non-whitespace changes.

If there is nothing to do,
`delete-trailing-whitespace', doesn't do anything.

Also, I have RET `newline-and-indent'. I never thought
about it, but what it does is it removes extra blanks
and breaks the line after the last char instead.

This is also something I can recommend for `C-k':

(defun kill-line-remove-blanks ()
  (interactive)
  (if (looking-at "[[:space:]]*$")
      (let ((end (point-max)))
        (delete-blank-lines)
        (when (= end (point-max))
          (delete-horizontal-space)
          (delete-char 1))
        (when (and (= (point-min) (point))
                   (looking-at "[[:space:]\n]") )
          (kill-line) ))
    (kill-line) ))

It works like this - if we let that the char for full
stop (or "period", i.e. "." ) represent point
position:

    Text line which isn't empty 1...
    .
    Text line which isn't empty 2...

Here, the result of invoking the command will be

    Text line which isn't empty 1...
    Text line which isn't empty 2...

But here -

    Text line which isn't empty 1...
    .

    (add arbitrarily blank lines here)
    Text line which isn't empty 2...

- the result will be:

    Text line which isn't empty 1...
    .
    Text line which isn't empty 2...

Interesting!

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

[Prev in Thread] Current Thread [Next in Thread]