GNU bug report logs -
#27552
25.2.50; Indentation problem in rnc-mode
Previous Next
Reported by: Ivan Andrus <darthandrus <at> gmail.com>
Date: Sat, 1 Jul 2017 20:35:01 UTC
Severity: minor
Tags: moreinfo
Found in version 25.2.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #16 received at 27552 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen [2022-06-15 16:25:29] wrote:
> Lars Ingebrigtsen <larsi <at> 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 <at> 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)))
This bug report was last modified 3 years and 20 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.