[Top][All Lists]

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

Re: Requested function: just-one-empty-line()

From: Andreas Politz
Subject: Re: Requested function: just-one-empty-line()
Date: Mon, 06 Oct 2008 17:24:33 +0200
User-agent: Mozilla-Thunderbird (X11/20080724)

Xah wrote:
On Oct 6, 5:14 am, Nordlöw <address@hidden> wrote:
On 6 Okt, 13:50, Andreas Politz <address@hidden> wrote:

Nordlöw wrote:
I'm looking for a function just-one-empty-line(), or empty-lines() for
the multi-line-variant, that does kind of what just-one-space() does
but instead works on empty lines. Any suggestions?
is converted to
Thanks in advance,
,----[ C-h f delete-blank-lines RET ]
| delete-blank-lines is an interactive compiled Lisp function in `simple.el'.
| It is bound to C-x C-o.
| (delete-blank-lines)
| On blank line, delete all surrounding blank lines, leaving just one.
| On isolated blank line, delete that one.
| On nonblank line, delete any immediately following blank lines.

Since delete-blank-lines and just-one-space are similar in function
from user point of view, i combined them into one single function,
that calls each depending on the context. So, a single key is assigned
to this command, saving up shortcut spaces.

(defun shrink-whitespaces ()
  "Collapse all white spaces around point, depending on context.
White space here includes space, tabs, and any end of line char.
This commands either calls just-one-space or delete-blank-lines."
  (let (p1 p2 mytext)
      (skip-chars-backward "\t \n")
      (setq p1 (point))
      (skip-chars-forward "\t \n")
      (setq p2 (point))
      (setq mytext (buffer-substring-no-properties p1 p2))
    (if (string-match "[\t ]*\n[\t ]*\n" mytext)
        (progn (delete-blank-lines))
      (progn (just-one-space))


Is the parenstyle part of your 'Modernization of emacs' program or
are you just trying to offend 'tech-geekers' ? ;O)


reply via email to

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