unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: nuxdoors@cegetel.net
To: bug-gnu-emacs@gnu.org
Cc: rms@gnu.org
Subject: Re: reindent-then-newline-and-indent doesn't indent properly in emacs 22.1
Date: Sun, 14 Oct 2007 00:24:58 +0200	[thread overview]
Message-ID: <471145BA.6050600@cegetel.net> (raw)
In-Reply-To: <4710849B.30104@gmx.at>

Ok the problem is not occuring in the official version of emacs 22.1, at
least not in the same obvious way. Sorry about the alarmous report. I
still have found a minor bug related to this in the official version
though, described below.

<my life>
I have found the problem to be much more obvious in the latest testing
emacs version (22.1+1-2) and will thus file a bug report at debian.org

I reported here because i saw the reindent-then-newline-and-indent
function on the Savannah CVS Surfing service (which was the same as the
one found in my emacs) was making the assumption that
indent-according-to-mode was indenting without moving the cursor
position, which i thought could be the source of the problem.

It turns out this is the source of the problem for my debian version,
where i use a develock advised version of lisp-indent-line which leaves
the cursor at the beginning of text, just after the indentation
characters. It doesn't happen in the official version though because it
seems pretty every indentation function included in the various modes
keeps the cursor in place ( i didn't test all the modes though of course ).
</my life>

In respect to the official emacs version, here is the description of a
bug with indent-to-left-margin (which used to be the default indentation
function for the Fundamental Mode so although this isn't even a command
and thus not available to alt-x some people might still use it ) :

Let's create indentation_test.txt like this :

cat > indentation_test.txt <<EOF
    First line. Second line to be indented like the first one.

Local Variables:
left-margin:4
indent-line-function:indent-to-left-margin
End:
EOF

Then i called emacs compiled from source like this :
emacs -Q -nw indentation_test.txt

answer yes at the local variable question.

The "|" character represents the cursor position.
Move you cursor to/on the "S" letter like this :

    First line. |Second line to be indented like the first one.

Then do a reindent-then-newline-and-indent, you will get this :

First line.
    |Second line to be indented like the first one.

This isn't visible but there is still a space at the end of the first
line. I believe we should get this :

    First line.
    |Second line to be indented like the first one.

(no space at the end of the first line and the "S" is on the same column
as "F")

The problem arises because indent-to-left-margin is one of the rare
indentation functions who leaves the cursor at the beginning of the text
after indenting.

So if we think that an indentation function should always leave the
cursor in place, i guess this isn't a bug and we can say
indent-to-left-margin is at fault here ( or the user who doesn't use a
more recent indentation function ).
On the other hand i have been reading the info docs and string docs in
indent.el for example and i can't find a place where it is said that an
indentation function should always preserve the cursor position. The
proper functionning of reindent-then-newline-and-indent is based on that
assumption, or at least that indent-according-to-mode respect that, but
it is not stated in the indent-according-to-mode's doc string that it
should.

I think either that statement should be made somewhere or
reindent-then-newline-and-indent shouldn't make that assumption, it
could for example encapsulate the indent-according-to-mode call itself
in a save-excursion form, which would solve the issue.





  reply	other threads:[~2007-10-13 22:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-12 23:02 reindent-then-newline-and-indent doesn't indent properly in emacs 22.1 nuxdoors
2007-10-13  8:40 ` martin rudalics
2007-10-13 22:24   ` nuxdoors [this message]
2007-10-14 13:23     ` nuxdoors
2007-10-14 18:26       ` martin rudalics
2007-10-15  1:37     ` Richard Stallman
2007-10-16  0:07       ` nuxdoors
2007-10-16 19:09         ` Richard Stallman
2007-10-16 20:39           ` nuxdoors
     [not found]             ` <E1Ii13p-0002HF-Q4@fencepost.gnu.org>
2007-10-19  1:07               ` nuxdoors
     [not found]     ` <mailman.2040.1192368226.18990.bug-gnu-emacs@gnu.org>
2007-10-14 19:48       ` Stefan Monnier
2007-10-16 15:19       ` Stefan Monnier
2007-10-14 12:46 ` nuxdoors
2007-10-15  1:37   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=471145BA.6050600@cegetel.net \
    --to=nuxdoors@cegetel.net \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).