From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "N. Raghavendra" Newsgroups: gmane.emacs.help Subject: Re: nXML mode indentation Date: Tue, 08 May 2018 21:00:14 +0530 Message-ID: <87muxaupvd.fsf@gmail.com> References: <87a7tedxyb.fsf@gmail.com> <8736z2ydeq.fsf@gmail.com> <878t8uwouz.fsf@gmail.com> Reply-To: "N. Raghavendra" NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1525793478 17011 195.159.176.226 (8 May 2018 15:31:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 8 May 2018 15:31:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 08 17:31:14 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fG4a6-0004Ft-Ht for geh-help-gnu-emacs@m.gmane.org; Tue, 08 May 2018 17:31:10 +0200 Original-Received: from localhost ([::1]:51923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4cD-0005Tq-Gu for geh-help-gnu-emacs@m.gmane.org; Tue, 08 May 2018 11:33:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4ZM-0004AD-Ar for help-gnu-emacs@gnu.org; Tue, 08 May 2018 11:30:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4ZJ-0002h5-4G for help-gnu-emacs@gnu.org; Tue, 08 May 2018 11:30:24 -0400 Original-Received: from mail-pl0-x233.google.com ([2607:f8b0:400e:c01::233]:39163) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4ZI-0002gi-LS for help-gnu-emacs@gnu.org; Tue, 08 May 2018 11:30:20 -0400 Original-Received: by mail-pl0-x233.google.com with SMTP id q18-v6so2446127plr.6 for ; Tue, 08 May 2018 08:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:user-agent:reply-to :mail-followup-to:date:message-id:mime-version :content-transfer-encoding; bh=GeNNa922tC6GYBWK0jY8DnEt/Gq6nQhWt4ySzeKK3/c=; b=qENoQ7OmtTgwEARZeETjcY3hMarLFGPlbVbUAxokbX4TmwyXtSm8WTmu1WO4wTVdvA bcuQWDB+yysINK9LugtGTFPjor2pv6JTpq/i1rcYvRxqvLCcMsyc4As+jB059BBTSVdX bRBPc9C8E6dlv9n9hJzPINje4IGkb7V30eL/FRBbDCFRSenDeHhIX04elytqZKHcvLUw J7dEGO+5S9Yg34OXQp18dtYbZVVXZjP5d92I/d+sPLZq5oIoy/+ulg/H37pQjU7seF6R x700PAO5qMnbb0L1Qn4I/elD/4Nry+1RGFReen9omW/oJHkZFMhWGKoA9dMMeeHnP0eV DyoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:reply-to:mail-followup-to:date:message-id:mime-version :content-transfer-encoding; bh=GeNNa922tC6GYBWK0jY8DnEt/Gq6nQhWt4ySzeKK3/c=; b=GK6VR5PE+lI/JNt720dk/tgN6aOK7oZAgNYry02dSZHTfxVapbuArtJd45SFWY3om3 QgG6CkYHzh6Nd+kJ3tfxxzVTZmUe4YQ5jJIuXosR6HlG2gm/L2oE/41YmnRNhg+fuN7m IYHlcy/OrlhKkqjoInSY3wdp8eTpVJ//q/2nUw89XkVarsyRIH5wHv+shWw+bRqKpmIQ oX4modWAT7xmFIxrzFStfk2CmHt7OsVkhQH/d9TUr5NHmpfzBrVtRk2tWcpIgRuwc1+a wVVs+thMaxutbOyfWWIUj9Ua/ma/u81QzGsX0QOjVfilvHocJI7rA5v/bRbZjxbkVCyk 0tJg== X-Gm-Message-State: ALQs6tBqP0Abp8hZXVFxklZhzFeVXXSo6j2tHebTlzdAfHi0e7X5QUNW mF7bqBHTAeShLFzrvAFRSPzwqQ== X-Google-Smtp-Source: AB8JxZprxmOqmhY0utkYServLu2+rK+Lcyu3HduP9VJrohc5KSO/LdNn5HhwJKmRw1DSHc7DFuDHkg== X-Received: by 2002:a17:902:108a:: with SMTP id c10-v6mr43125471pla.111.1525793419273; Tue, 08 May 2018 08:30:19 -0700 (PDT) Original-Received: from ailuros ([14.139.59.140]) by smtp.gmail.com with ESMTPSA id z83sm19824066pfd.103.2018.05.08.08.30.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 08:30:18 -0700 (PDT) In-Reply-To: (Yuri Khan's message of "Tue, 08 May 2018 08:19:45 +0000") Mail-Followup-To: help-gnu-emacs@gnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::233 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116696 Archived-At: At 2018-05-08T08:19:45Z, Yuri Khan wrote: > On Tue, May 8, 2018 at 3:09 PM N. Raghavendra > wrote: > > That probably means the indentation for that line is computed in > =E2=80=98nxml-compute-indent-from-matching-start-tag=E2=80=99. 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 ----------
Kant lipsum 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.
---------- 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 (=3D (nxml-token-before) (point)) (memq xmltok-type '(end-tag partial-end-tag)) ;; start of line must not be inside a token - (or (=3D xmltok-start bol) + (or (and (=3D 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=3D%s ac=3D%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 , http://www.retrotexts.net/ Harish-Chandra Research Institute, http://www.hri.res.in/