From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Ivan Andrus <darthandrus@gmail.com>, 27552@debbugs.gnu.org
Subject: bug#27552: 25.2.50; Indentation problem in rnc-mode
Date: Wed, 15 Jun 2022 11:15:28 -0400 [thread overview]
Message-ID: <jwvv8t2ugy1.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87sfo6gg12.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 15 Jun 2022 16:25:29 +0200")
Lars Ingebrigtsen [2022-06-15 16:25:29] wrote:
> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> I guess this "=" rule is for stuff like the "pattern =" etc. But it
>> leads to things like this being indented more for each line:
>>
>> default namesace rng = "http://relaxng.org/ns/structure/1.0"
>> namespace local = ""
>> datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
Part of the problem is that the grammar we use is incorrect, so we
parse incorrectly, and we have to patch things up in the indentation
rules :-(
> Or... is the problem here that we don't end pattern with a newline?
Kind of, yes. There are various places where we could try and fix
this problem, but this might be the simplest, indeed.
I pushed the patch below which does that.
Stefan
diff --git a/rnc-mode.el b/rnc-mode.el
index 30f3c39970..33363d2057 100644
--- a/rnc-mode.el
+++ b/rnc-mode.el
@@ -1,6 +1,6 @@
;;; rnc-mode.el --- Emacs mode to edit Relax-NG Compact files -*- lexical-binding:t -*-
-;; Copyright (C) 1994-1998, 2001-2016 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1998, 2001-2022 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: xml relaxng
@@ -96,11 +96,18 @@
'((assoc "," "&" "|") (nonassoc "?" "*" "+"))
)))
+(defconst rnc-smie--def-regexp
+ (concat "\\(?:\\(?:namespace\\|datatypes\\)[ \t\n]+\\)?"
+ "\\(?:\\s_\\|\\sw\\)+[ \t\n]*[|&]?=")
+ "Regexp matching a \"definition\".
+Any line that starts with this is presumed to start a new definition,
+so the preceding newline is turned into an implicit \" ; \" token.")
+
(defun rnc-smie-forward-token ()
(let ((start (point)))
(forward-comment (point-max))
(if (and (> (point) start)
- (looking-at "\\(?:\\s_\\|\\sw\\)+[ \t\n]*[|&]?=")
+ (looking-at rnc-smie--def-regexp)
(save-excursion
(goto-char start)
(forward-comment -1)
@@ -120,7 +127,7 @@
(let ((pos (point)))
(goto-char start)
(prog1
- (looking-at "\\(?:\\s_\\|\\sw\\)+[ \t\n]*[|&]?=")
+ (looking-at rnc-smie--def-regexp)
(goto-char pos))))
" ; "
(if (looking-back "\\s." (1- (point)))
next prev parent reply other threads:[~2022-06-15 15:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-01 20:33 bug#27552: 25.2.50; Indentation problem in rnc-mode Ivan Andrus
2022-05-17 19:25 ` Lars Ingebrigtsen
2022-06-15 14:25 ` Lars Ingebrigtsen
2022-06-15 15:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-06-15 15:56 ` Lars Ingebrigtsen
2022-07-02 20:43 ` Ivan Andrus
2022-07-02 21:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=jwvv8t2ugy1.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=27552@debbugs.gnu.org \
--cc=darthandrus@gmail.com \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
/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.
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).