From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#27552: 25.2.50; Indentation problem in rnc-mode Date: Wed, 15 Jun 2022 11:15:28 -0400 Message-ID: References: <87k0akhshb.fsf@gnus.org> <87sfo6gg12.fsf@gnus.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28493"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Ivan Andrus , 27552@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 15 17:43:05 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o1VAe-00079H-RG for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Jun 2022 17:43:05 +0200 Original-Received: from localhost ([::1]:49484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1VAd-0007te-D2 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Jun 2022 11:43:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1UkU-0006ne-En for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 11:16:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1UkU-0008HU-6Q for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 11:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o1UkT-0001Qt-SL for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2022 11:16:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Jun 2022 15:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27552 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 27552-submit@debbugs.gnu.org id=B27552.16553061404068 (code B ref 27552); Wed, 15 Jun 2022 15:16:01 +0000 Original-Received: (at 27552) by debbugs.gnu.org; 15 Jun 2022 15:15:40 +0000 Original-Received: from localhost ([127.0.0.1]:39452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o1Uk7-000134-Ew for submit@debbugs.gnu.org; Wed, 15 Jun 2022 11:15:40 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:17123) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o1Uk5-0000v0-12 for 27552@debbugs.gnu.org; Wed, 15 Jun 2022 11:15:38 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6CF37100479; Wed, 15 Jun 2022 11:15:31 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AA4A1100173; Wed, 15 Jun 2022 11:15:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1655306129; bh=VaV3FkwdTC+XXnLaZnlv1IhEEkXc+1fg60sitrQrEjM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=WlGjkQbiOwUdTbTcqARp22kXS2NeAT1ECmO8t1M2cUtnFFd5O9JLA5NEANgIai8AK TehfzyMfLbr49NURyrwQXV4d3ymMXfU+nRpQTWoJ9AuXw/lH9GrFROgglJBq62KBB1 cv4HPsLb3Ln7gZ7p4MmpTLta0K/5c7SjpqFMHQfg6zAeW8oRU/T2afg59NQdrbrRCG DNrSxKxqsEMg7Z2Biyrup8/Tp+IVgPagl0H+j677l+OCkOeEBh8xy8hf6XIXtD2keM iJZF4yD6aicLZcPrBGT7e1BLFfXCc9vVCQUA5zweEaiNO36TqidnTJ27TDS6rAKnxt pCpGbM2TRLd4Q== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8AA9F1202DD; Wed, 15 Jun 2022 11:15:29 -0400 (EDT) In-Reply-To: <87sfo6gg12.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 15 Jun 2022 16:25:29 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:234588 Archived-At: Lars Ingebrigtsen [2022-06-15 16:25:29] wrote: > Lars Ingebrigtsen 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 ;; 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)))