unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* reindent-then-newline-and-indent doesn't indent properly in emacs 22.1
@ 2007-10-12 23:02 nuxdoors
  2007-10-13  8:40 ` martin rudalics
  2007-10-14 12:46 ` nuxdoors
  0 siblings, 2 replies; 14+ messages in thread
From: nuxdoors @ 2007-10-12 23:02 UTC (permalink / raw)
  To: bug-gnu-emacs

Hi, In GNU Emacs 22.1:

reindent-then-newline-and-indent doesn't indent properly.

The command currently calls delete-horizontal-space after indenting the
line, which in effect deletes the re-indentation since at that very
moment the point is at the beginning of the text. If you swap the order
of the delete-horizontal-space and indent-according-to-mode functions it
then works as intended, like this :

(defun reindent-then-newline-and-indent ()
  "Reindent current line, insert newline, then indent the new line.
Indentation of both lines is done according to the current major mode,
which means calling the current value of `indent-line-function'.
In programming language modes, this is the same as TAB.
In some text modes, where TAB inserts a tab, this indents to the
column specified by the function `current-left-margin'."
  (interactive "*")
  (let ((pos (point)))
    ;; Be careful to insert the newline before indenting the line.
    ;; Otherwise, the indentation might be wrong.
    (newline)
    (save-excursion
      (goto-char pos)
      (delete-horizontal-space t)
      (indent-according-to-mode))
    (indent-according-to-mode)))

Regards,
Fabrice.





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-10-19  1:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2007-10-14 13:23     ` nuxdoors
2007-10-14 18:26       ` martin rudalics
     [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-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
2007-10-14 12:46 ` nuxdoors
2007-10-15  1:37   ` Richard Stallman

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).