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

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

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


From: Xah
Subject: Re: Requested function: just-one-empty-line()
Date: Mon, 6 Oct 2008 19:53:22 -0700 (PDT)
User-agent: G2/1.0

On Oct 6, 8:24 am, Andreas Politz <poli...@fh-trier.de> wrote:
> > 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."
> >   (interactive)
> >   (let (p1 p2 mytext)
> >     (save-excursion
> >       (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))
> >       )
> >     )
> >   )
>
> >http://xahlee.org/emacs/ergonomic_emacs_keybinding.html
>
> >   Xah
> > ∑http://xahlee.org/
>
> > ☄
>
> Is the parenstyle part of your 'Modernization of emacs' program or
> are you just trying to offend 'tech-geekers' ? ;O)

The quick answer is that i'm just lazy.

The full answer is that i think programers should never spend time to
manually format his code. In fact this is one of my big gribe, and has
wrote several articles about it, several of which are results of
newsgroup flamewars.

See

• A Simple Lisp Code Formatter
http://xahlee.org/emacs/lisp_formatter.html

• The Harm of Hard-wrapping Lines
http://xahlee.org/UnixResource_dir/writ/hard-wrap.html

• Fundamental Problems of Lisp
http://xahlee.org/UnixResource_dir/writ/lisp_problems.html
(see the section “Automatic, Uniform, Universal, Source Code Display”
about the relation of fully regular syntax and code formatting)

In emacs, in just about any language mode, despite elisp power and 3
decades of code, programers basically still manually format each line
of code. It would be much better, if programer can press a button, and
emacs will call pretty-reformat-current-block similar to fill-
paragraph or unfill-paragraph.

A algorithm for formatting of source code is a trivial problem in the
theoretical sense, it's just tedious to code it. The formatting of
mostly regular syntax such as lisp is more trivial. I do hope down the
road i'll write such a function for at least lisp.

  Xah
∑ http://xahlee.org/

reply via email to

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