From: "N. Raghavendra" <nyraghu27132@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: nXML mode indentation
Date: Tue, 08 May 2018 21:00:14 +0530 [thread overview]
Message-ID: <87muxaupvd.fsf@gmail.com> (raw)
In-Reply-To: <CAP_d_8WK6o7-LnXEEkM0GnHxWVxqs8BTWt2C5FLWLQfhrygB7w@mail.gmail.com> (Yuri Khan's message of "Tue, 08 May 2018 08:19:45 +0000")
At 2018-05-08T08:19:45Z, Yuri Khan wrote:
> On Tue, May 8, 2018 at 3:09 PM N. Raghavendra <nyraghu27132@gmail.com>
> wrote:
>
> That probably means the indentation for that line is computed in
> ‘nxml-compute-indent-from-matching-start-tag’.
Thank you, that's absolutely correct, as I confirmed by putting a
`message' form at the end of that function. I have now changed
nxml-mode.el as in the diff below. With that, I get the required
indentation, as in
----------
<article>
<section>
<title>Kant lipsum</title>
<para>Let us suppose that the noumena have nothing to do with
necessity, since knowledge of the Categories is a posteriori.
Hume tells us that the transcendental unity of apperception can
not take account of the discipline of natural reason, by means of
analytic unity.</para>
</section>
</article>
----------
The change to `nxml-compute-indent-from-matching-start-tag' introduces a
local variable `only-end-tag' to distinguish between the line starting
with "analytic", and the last two lines.
Now, the next thing I see is that if, after this indentation, I do
`fill-paragraph', it goes back to the old indentation. Anyway, I'll
deal with that later. For now, I'll make do with these changes, which
at least give me the indentation I want.
Thanks very much for your help.
Best regards,
Raghu.
----------
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index e2b51bc..a2e92f4 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1297,14 +1297,16 @@ nxml-compute-indent-from-matching-start-tag
its line. Otherwise return nil."
(save-excursion
(back-to-indentation)
- (let ((bol (point)))
+ (let ((bol (point))
+ (only-end-tag nil))
(let ((inhibit-field-text-motion t))
(end-of-line))
(skip-chars-backward " \t")
(and (= (nxml-token-before) (point))
(memq xmltok-type '(end-tag partial-end-tag))
;; start of line must not be inside a token
- (or (= xmltok-start bol)
+ (or (and (= xmltok-start bol)
+ (setq only-end-tag t))
(save-excursion
(goto-char bol)
(nxml-token-after)
@@ -1322,7 +1324,9 @@ nxml-compute-indent-from-matching-start-tag
(goto-char xmltok-start)
(skip-chars-backward " \t")
(bolp))
- (current-indentation)))))
+ (if only-end-tag
+ (current-indentation)
+ (+ (current-indentation) nxml-child-indent))))))
(defun nxml-compute-indent-from-previous-line ()
"Compute the indent for a line using the indentation of a previous line."
@@ -1377,10 +1381,17 @@ nxml-compute-indent-from-previous-line
(nxml-compute-indent-in-token bol))))
(skip-chars-forward " \t\r\n"))
(goto-char ref)
- (+ (current-column)
- (* nxml-child-indent
- (+ (if (eq before-context 'start-tag) 1 0)
- (if (eq after-context 'end-tag) -1 0))))))))
+ (message "bc=%s ac=%s" before-context after-context)
+ (cond ((and (eq before-context 'mixed)
+ (eq after-context 'markup))
+ (+ (current-column) nxml-child-indent))
+ ((and (eq before-context 'markup)
+ (eq after-context 'markup))
+ (current-column))
+ (t (+ (current-column)
+ (* nxml-child-indent
+ (+ (if (eq before-context 'start-tag) 1 0)
+ (if (eq after-context 'end-tag) -1 0))))))))))
(defun nxml-merge-indent-context-type (context)
"Merge the indent context type CONTEXT with the token in `xmltok-type'.
----------
--
N. Raghavendra <raghu@hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/
next prev parent reply other threads:[~2018-05-08 15:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-05 13:38 nXML mode indentation N. Raghavendra
2018-05-08 4:33 ` N. Raghavendra
2018-05-08 4:55 ` Yuri Khan
2018-05-08 5:16 ` N. Raghavendra
2018-05-08 8:09 ` N. Raghavendra
2018-05-08 8:19 ` Yuri Khan
2018-05-08 15:30 ` N. Raghavendra [this message]
2018-05-09 3:22 ` N. Raghavendra
2018-05-12 4:36 ` N. Raghavendra
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=87muxaupvd.fsf@gmail.com \
--to=nyraghu27132@gmail.com \
--cc=help-gnu-emacs@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.
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).