[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] Re: Insertion of leading new line with C-c C-s
From: |
Ralf Angeli |
Subject: |
Re: [AUCTeX-devel] Re: Insertion of leading new line with C-c C-s |
Date: |
Sun, 03 Apr 2005 15:36:48 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) |
* Christian Schlauer (2005-04-03) writes:
> [This is a follow-up to a thread from last december, see
> <URL:http://article.gmane.org/gmane.emacs.auc-tex/5093>]
[...]
> I attach a patch that does the right thing: it inserts a new line only
> if the previous line is not empty or does not start with `[possible
> whitespace]\begin'. The latter is to avoid things like
>
> \begin{some-environment}
>
> \section{blah}
>
> where a blank line between the beginning of the environment and the
> section is not wanted.
Why isn't it wanted in this case?
> I couldn't use `skip-chars-backward' as suggested by Ralf because that
> didn't work when the section is already indented, for example when the
> section is within a `multicols' environment. Try to insert sections in
> the following document, and you will see that the code `does the right
> thing':
The code fails to insert a newline in the following case:
text text text
text text text-!-
Here is a version using `skip-chars-backward' which dos not fail:
(unless (and (eq (save-excursion
(skip-chars-backward " \t\n\f" (line-end-position -1))
(point))
(line-end-position -1))
(save-excursion
(re-search-backward
(concat "^\\s-*" (regexp-quote TeX-esc) "begin")
(line-beginning-position 0) t)))
(LaTeX-newline))
> (There is one case where the code does not do the right thing: when
> point is placed behind \begin{some-environment}-!-. But point will
> never be there when people use `C-c C-e' and `C-c C-s', so I think
> this case can be ignored.)
This could probably fixed as well but I am not sure if we should cater
for this special case at all.
--
Ralf