www.delorie.com/gnu/docs/elisp-manual-21/elisp_500.html   search  
 
Buy the book!


GNU Emacs Lisp Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

32.7 User-Level Deletion Commands

This section describes higher-level commands for deleting text, commands intended primarily for the user but useful also in Lisp programs.

Command: delete-horizontal-space
This function deletes all spaces and tabs around point. It returns nil.

In the following examples, we call delete-horizontal-space four times, once on each line, with point between the second and third characters on the line each time.

 
---------- Buffer: foo ----------
I -!-thought
I -!-     thought
We-!- thought
Yo-!-u thought
---------- Buffer: foo ----------

(delete-horizontal-space)   ; Four times.
     => nil

---------- Buffer: foo ----------
Ithought
Ithought
Wethought
You thought
---------- Buffer: foo ----------

Command: delete-indentation &optional join-following-p
This function joins the line point is on to the previous line, deleting any whitespace at the join and in some cases replacing it with one space. If join-following-p is non-nil, delete-indentation joins this line to the following line instead. The function returns nil.

If there is a fill prefix, and the second of the lines being joined starts with the prefix, then delete-indentation deletes the fill prefix before joining the lines. See section 32.12 Margins for Filling.

In the example below, point is located on the line starting `events', and it makes no difference if there are trailing spaces in the preceding line.

 
---------- Buffer: foo ----------
When in the course of human
-!-    events, it becomes necessary
---------- Buffer: foo ----------

(delete-indentation)
     => nil

---------- Buffer: foo ----------
When in the course of human-!- events, it becomes necessary
---------- Buffer: foo ----------

After the lines are joined, the function fixup-whitespace is responsible for deciding whether to leave a space at the junction.

Function: fixup-whitespace
This function replaces all the whitespace surrounding point with either one space or no space, according to the context. It returns nil.

At the beginning or end of a line, the appropriate amount of space is none. Before a character with close parenthesis syntax, or after a character with open parenthesis or expression-prefix syntax, no space is also appropriate. Otherwise, one space is appropriate. See section 35.2.1 Table of Syntax Classes.

In the example below, fixup-whitespace is called the first time with point before the word `spaces' in the first line. For the second invocation, point is directly after the `('.

 
---------- Buffer: foo ----------
This has too many     -!-spaces
This has too many spaces at the start of (-!-   this list)
---------- Buffer: foo ----------

(fixup-whitespace)
     => nil
(fixup-whitespace)
     => nil

---------- Buffer: foo ----------
This has too many spaces
This has too many spaces at the start of (this list)
---------- Buffer: foo ----------

Command: just-one-space
This command replaces any spaces and tabs around point with a single space. It returns nil.

Command: delete-blank-lines
This function deletes blank lines surrounding point. If point is on a blank line with one or more blank lines before or after it, then all but one of them are deleted. If point is on an isolated blank line, then it is deleted. If point is on a nonblank line, the command deletes all blank lines following it.

A blank line is defined as a line containing only tabs and spaces.

delete-blank-lines returns nil.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003