unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6412: 23.2; [patch] nXML indentation bug
@ 2010-06-13 13:56 Leo
  2010-06-13 14:27 ` Leo
  0 siblings, 1 reply; 4+ messages in thread
From: Leo @ 2010-06-13 13:56 UTC (permalink / raw)
  To: 6412

The indentation behaviour in nxml is different from most of other modes
in that when current line has correct indentation the point stay still
instead of moving to the first non-blank char. The attached patch fixes
this problem with minor simplification.


diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 8919d92..36b5fe7 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1372,12 +1372,9 @@ of the inserted start-tag or nil if none was inserted."
   "Indent current line as XML."
   (let ((indent (nxml-compute-indent))
 	(from-end (- (point-max) (point))))
-    (when (and indent
-	       (/= indent (current-indentation)))
-      (beginning-of-line)
-      (let ((bol (point)))
-	(skip-chars-forward " \t")
-	(delete-region bol (point)))
+    (skip-chars-forward " \t")
+    (when (and indent (/= indent (current-indentation)))
+      (delete-region (line-beginning-position) (point))
       (indent-to indent)
       (when (> (- (point-max) from-end) (point))
 	(goto-char (- (point-max) from-end))))))

Best wishes,

Leo

GNU Emacs 23.2.7 (x86_64-apple-darwin10.3.0, Carbon Version 1.6.0 AppKit 1038.29)
 of 2010-06-11 on Victoria.local





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

* bug#6412: 23.2; [patch] nXML indentation bug
  2010-06-13 13:56 bug#6412: 23.2; [patch] nXML indentation bug Leo
@ 2010-06-13 14:27 ` Leo
  2010-06-14  1:43   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Leo @ 2010-06-13 14:27 UTC (permalink / raw)
  To: 6412

[-- Attachment #1: Type: text/plain, Size: 88 bytes --]

Please ignore the patch in previous email (sorry for this). Here is the
correct patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-nxml-indent-line-to-be-consistent-with-other-mod.patch --]
[-- Type: text/x-patch, Size: 1486 bytes --]

From 3d8a976a0edad1b8e099a108320f60622d168ffb Mon Sep 17 00:00:00 2001
From: Leo <sdl.web@gmail.com>
Date: Sun, 13 Jun 2010 14:58:47 +0100
Subject: [PATCH] Fix nxml-indent-line to be consistent with other modes (#6412)

Patch sent to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6412.
---
 lisp/nxml/nxml-mode.el |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 8919d92..5e9fd8c 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1371,16 +1371,14 @@ of the inserted start-tag or nil if none was inserted."
 (defun nxml-indent-line ()
   "Indent current line as XML."
   (let ((indent (nxml-compute-indent))
-	(from-end (- (point-max) (point))))
-    (when (and indent
-	       (/= indent (current-indentation)))
-      (beginning-of-line)
-      (let ((bol (point)))
-	(skip-chars-forward " \t")
-	(delete-region bol (point)))
-      (indent-to indent)
-      (when (> (- (point-max) from-end) (point))
-	(goto-char (- (point-max) from-end))))))
+	(from-end (- (point-max) (point)))
+	(beg (progn (forward-line 0) (point))))
+    (skip-chars-forward " \t")
+    (when (and indent (/= indent (current-indentation)))
+      (delete-region beg (point))
+      (indent-to indent))
+    (when (> (- (point-max) from-end) (point))
+      (goto-char (- (point-max) from-end)))))
 
 (defun nxml-compute-indent ()
   "Return the indent for the line containing point."
-- 
1.7.0.4


[-- Attachment #3: Type: text/plain, Size: 5 bytes --]


Leo

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

* bug#6412: 23.2; [patch] nXML indentation bug
  2010-06-13 14:27 ` Leo
@ 2010-06-14  1:43   ` Stefan Monnier
  2010-06-14  8:15     ` Leo
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2010-06-14  1:43 UTC (permalink / raw)
  To: Leo; +Cc: 6412

> Please ignore the patch in previous email (sorry for this). Here is the
> correct patch:

Thanks, and sorry to let you wait.  I just installed a copy of that same
functionality from some other mode.  This should really be moved to
prog-mode so it can be shared by all major-modes.


        Stefan





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

* bug#6412: 23.2; [patch] nXML indentation bug
  2010-06-14  1:43   ` Stefan Monnier
@ 2010-06-14  8:15     ` Leo
  0 siblings, 0 replies; 4+ messages in thread
From: Leo @ 2010-06-14  8:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 6412

On 14 June 2010 02:43, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> Please ignore the patch in previous email (sorry for this). Here is the
>> correct patch:
>
> Thanks, and sorry to let you wait.  I just installed a copy of that same
> functionality from some other mode.  This should really be moved to
> prog-mode so it can be shared by all major-modes.

No wait at all. I think that's pretty quick. I tested the patch with
Emacs 23.2 and it worked. Please close this bug. Thanks.

>        Stefan

Leo





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

end of thread, other threads:[~2010-06-14  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-13 13:56 bug#6412: 23.2; [patch] nXML indentation bug Leo
2010-06-13 14:27 ` Leo
2010-06-14  1:43   ` Stefan Monnier
2010-06-14  8:15     ` Leo

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