[Top][All Lists]

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

RE: shouldn't `delete-blank-lines' treat form-feed as whitespace?

From: Drew Adams
Subject: RE: shouldn't `delete-blank-lines' treat form-feed as whitespace?
Date: Wed, 3 Mar 2010 14:21:29 -0800

> > `delete-blank-lines' treats SPC, TAB, and newline as whitespace.
> > Shouldn't it also treat form-feed (aka \f, aka ^L) as whitespace?
> While it's logically formally a whitespace class character, I'm quite 
> unconvinced it would "feel right" to me.   formfeed is usually put in 
> much more rarely and with more forethought than space/tab/newline.
> It's also not "blank" in one possibly important sense: in emacs 
> "out-of-box" it shows up as a quite visible "^L", whereas 
> SPC/TAB/newline are invisible unless you turn on whitespace.
> So delete-blank-lines would end up deleting lines, that from a naive 
> viewpoint, look like they "have something on them".
> Imagine you've got a text file with "page breaks" in it 
> (represented as 
> formfeeds as is/was the convention (see "C-x [" / "C-x ]" !)):
> ^L
> alpha
> bravo
> charlie[]
> ^L
> delta
> epsilon
> Say I hit C-x C-o where the point [] is. I wouldn't just delete those 
> stray blank lines on the first page, I'd suddenly merge two pages.
> So I strongly suspect changing it would annoy people who 
> still sprinkle 
> ^L through their code or other files for pagination.  
> Something I guess
> I personally don't do so much anymore (got a laser printer not a dot 
> matrix...), but anyway.

Your point is a good one.

Actually, the place where I ran into this, and where I thought it would be
appropriate for \f to be considered blank lines and be deleted, was somewhat

I use an even more noticeable (much more noticeable) display artifact than a
visible `^L' (see http://www.emacswiki.org/emacs/PrettyControlL). And I do use
^L in my libraries to separate various code and commentary sections (into

I use `finder-commentary' in some of my code, and it leaves such a ^L at the end
(it comes before "Change log"), not considering it to be a blank line. (I also
tweak `finder-commentary' to `delete-blank-lines' at the top and bottom.)
Getting rid of that was the use case that prompted my post.

So while I agree with you for the use case you mention, in that somewhat similar
use case I think it does make sense to remove ^L lines as "blank".

Perhaps the criterion I'm looking for is ^L followed or preceded by only
whitespace lines (including ^L lines). With that as criterion, the only "pages"
that would be dropped (merged, if you like) would be blank ones.

For interactive use (`C-x C-o') I don't see a problem with deleting lines that
contain only ^Ls - we have undo. For programmatic use, it's less clear that we
should always delete ^L lines as being blank. That's why I mentioned possibly
adding an optional arg etc.

Being able to specify via such an arg just what to consider as whitespace
("blank") would give code such as (my tweaked) `finder-commentary' an easy way
to trim off leading and trailing whitespace lines, including lines with ^L.

reply via email to

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