[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nXML mode indentation
From: |
N. Raghavendra |
Subject: |
Re: nXML mode indentation |
Date: |
Tue, 08 May 2018 13:39:08 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
At 2018-05-08T10:03:33+05:30, N. Raghavendra wrote:
> It looks like `nxml-compute-indent-from-previous-line' in nxml-mode.el
> is relevant, but I can't see how to modify or advise it.
I have made some progress, with this function. I tried changing the
definition of `nxml-compute-indent-from-previous-line' as follows:
----------
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index e2b51bc..f2e185e 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1377,10 +1377,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'.
----------
This almost gives me the indentation that I want, 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 only thing is that the last line in the para, the one starting with
"analytic", is not indented as I want it. It should be indented to the
same column as the previous line, the one starting with "not".
I have put
(message "bc=%s ac=%s" before-context after-context)
to give me some idea of what is happening. However, it does not produce
any message when I go to the troublesome last line of the para, and
press tab.
I'd appreciate if someone can help with this problem. If it is better
off on emacs-devel, I'll move it there.
Thanks,
Raghu.
--
N. Raghavendra <raghu@hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/