defering indent upon newline

stephen at xemacs.org stephen
Tue Oct 31 05:12:31 EST 2006


Tim Connors writes:

 > In perl-mode with font-lock on, when you have whitespace at the end of 
 > line, including when you have just indented, you end up with an ugly 
 > underline.  This is of course intentional, to encourage you to get rid of 
 > wasted whitespace.
 > 
 > But, if you have newline-and-indent turned on, you get whitespace 
 > automatically, and this only gets removed if you put in more newlines.

You mean if I enter

RET "some text" RET RET "more text" RET

I should get ("~" = an ordinary space made visible, the initial
numeral and space would not appear in the buffer)

1 ~~~~some text
2 
3 ~~~~more text
4 ____

with line 2 empty and line 4 ready for more indented text?  That's
what autoindenting normally does.  AIUI, you're satisfied with this
behavior, but you want to be able to insert vertical white space into
an existing block of text.  Is that right?

 > If you want to seperate a block by newlines either side, you have to 
 > juggle the cursor all over the place before you end up with two blank 
 > lines, and a line in the middle indented correctly.

Actually, if you have

1 ~~~~some text-!-
2 ~~~~more text

where -!- marks the position of point, you can use M-x open-line
(normally bound to C-o as well) to open up a line without inserting
space in most modes.  You could also do this at the beginning of the
second line.  Then you have

1 ~~~~some text-!-
a 
2 ~~~~more text

where a indicates the newly opened line.

 > And you can't just kill the whitespace on an otherwise blank line
 > with ctrl-k, because it kills the entire line including the
 > newline.

M-x delete-horizontal-space (usually bound to M-\) is perfect for
this.

 > So, in light of this, does it make sense to defer the indenting of the 
 > current line until a character is actually input on that line?

I think this probably violates POLA, and it's better to learn to use
C-o and M-\.  But if you really want to do it, you'd need to replace
or hook into self-insert-command, I think.  I'm not going to think
about it until you say you're sure. :-)

HTH

Steve



More information about the XEmacs-Beta mailing list