all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27552: 25.2.50; Indentation problem in rnc-mode
@ 2017-07-01 20:33 Ivan Andrus
  2022-05-17 19:25 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Ivan Andrus @ 2017-07-01 20:33 UTC (permalink / raw)
  To: 27552

The RNC snippet below (from
http://cs.brown.edu/courses/cs196-9/slidestore/relaxng.html) shows an
indentation problem when using multiple opening namespace/datatypes
clauses.

-Ivan

default namespace rng = "http://relaxng.org/ns/structure/1.0"
                            namespace local = ""
                                                  datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"

start = pattern

pattern =
    element element { (nameQName | nameClass), (common & pattern+) }
    | element attribute { (nameQName | nameClass), (common & pattern?) }
    | element group|interleave|choice|optional
              |zeroOrMore|oneOrMore|list|mixed { common & pattern+ }
    | element ref|parentRef { nameNCName, common }
    | element empty|notAllowed|text { common }
    | element data { type, param*, (common & exceptPattern?) }
    | element value { commonAttributes, type?, xsd:string }
    | element externalRef { href, common }
    | element grammar { common & grammarContent* }



In GNU Emacs 25.2.50.5 (x86_64-apple-darwin15.6.0, NS appkit-1404.47 Version 10.11.6 (Build 15G1421))
of 2017-06-28 built on iandrus-osx
Repository revision: efe7a7f79f8eb9c716136561821d350b69456b55
Windowing system distributor 'Apple', version 10.3.1404
Configured using:
'configure --without-makeinfo PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig'

Configured features:
JPEG RSVG DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: RNC

Minor modes in effect:
  achievements-mode: t
  highlight-symbol-mode: t
  which-function-mode: t
  show-paren-mode: t
  global-semantic-stickyfunc-mode: t
  save-place-mode: t
  msb-mode: t
  minibuffer-depth-indicate-mode: t
  gud-tooltip-mode: t
  global-hl-line-mode: t
  delete-selection-mode: t
  guide-key-mode: t
  auto-insert-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  ido-everywhere: t
  beacon-mode: t
  global-page-break-lines-mode: t
  gvol-mode: t
  diff-auto-refine-mode: t
  magit-auto-revert-mode: t
  global-auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  TeX-PDF-mode: t
  global-edit-server-edit-mode: t
  auto-image-file-mode: t
  desktop-save-mode: t
  drag-stuff-global-mode: t
  drag-stuff-mode: t
  recentf-mode: t
  global-anzu-mode: t
  anzu-mode: t
  keyfreq-autosave-mode: t
  keyfreq-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#27552: 25.2.50; Indentation problem in rnc-mode
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-17 19:25 UTC (permalink / raw)
  To: Ivan Andrus; +Cc: 27552, Stefan Monnier

Ivan Andrus <darthandrus@gmail.com> writes:

> The RNC snippet below (from
> http://cs.brown.edu/courses/cs196-9/slidestore/relaxng.html) shows an
> indentation problem when using multiple opening namespace/datatypes
> clauses.
>
> -Ivan
>
> default namespace rng = "http://relaxng.org/ns/structure/1.0"
>                             namespace local = ""
>                                                   datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
>
> start = pattern
>
> pattern =
>     element element { (nameQName | nameClass), (common & pattern+) }
>     | element attribute { (nameQName | nameClass), (common & pattern?) }
>     | element group|interleave|choice|optional


(defun rnc-smie-rules (kind token)
  (pcase (cons kind token)
    (`(:list-intro . "element") t)
    (`(:elem . empty-line-token) " ; ")
    (`(:before . ,(or "include" "default" "namespace" "datatypes")) 0)
[...]
    (`(:after . ,(or "=" "|=" "&=")) smie-indent-basic)

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"

I betcha this is easy to express in smie, but I have no idea how, so
I've added Stefan to the CCs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#27552: 25.2.50; Indentation problem in rnc-mode
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-15 14:25 UTC (permalink / raw)
  To: Ivan Andrus; +Cc: 27552, Stefan Monnier

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"

Or...  is the problem here that we don't end pattern with a newline?
Because the "assignment" ends at the newline in this case.

  (smie-prec2->grammar
   (smie-bnf->prec2
    '((id) (atom) (args)
      (header (header "include" atom))
      (decls (id "=" pattern) (id "|=" pattern) (id "&=" pattern)
             (decls " ; " decls))
      (pattern ("element" args) ("attribute" args)
               ("list" args) ("mixed" args)
               ("parent" id) ("external" id)
               ("grammar" atom)
	       ("{" pattern "}")
	       (pattern "," pattern)
	       (pattern "&" pattern)
	       (pattern "|" pattern)
	       (pattern "?")
	       (pattern "*")
	       (pattern "+")))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#27552: 25.2.50; Indentation problem in rnc-mode
  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
  2022-06-15 15:56       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-06-15 15:15 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Ivan Andrus, 27552

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)))






^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#27552: 25.2.50; Indentation problem in rnc-mode
  2022-06-15 15:15     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-06-15 15:56       ` Lars Ingebrigtsen
  2022-07-02 20:43         ` Ivan Andrus
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-15 15:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Ivan Andrus, 27552

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> 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.

Thanks; I can confirm that that fixes this issue, so I'm closing this
bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#27552: 25.2.50; Indentation problem in rnc-mode
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Ivan Andrus @ 2022-07-02 20:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 27552, Stefan Monnier

First off, thank you very much for fixing this! 

I noticed, however, that it's not updated in ELPA because the version wasn't updated.  Then I was going to check out the GNU ELPA repository and maybe try bumping the version myself, but I failed (tried several times):

$ git clone git://git.sv.gnu.org/emacs/elpaa
Cloning into 'elpa'...
remote: Counting objects: 420700, done.
remote: Compressing objects: 100% (122372/122372), done.
warning: object 40b50e2bcb5b674697e3e2a41627564f810880c4: gitignoreSymlink: .gitignore is a symlink
warning: object da777249505761d5c51406d4a0d268629f146f8e: gitignoreSymlink: .gitignore is a symlink
warning: object fa73f7d32f618bd46247364932cac8aa591ed8b9: gitignoreSymlink: .gitignore is a symlink
warning: object 6bca01e6638f0e92ce277c1497c8f1175236315a: gitignoreSymlink: .gitignore is a symlink
warning: object 4246bb45961f0e8ed4ccb123648d55a2f043524c: gitignoreSymlink: .gitignore is a symlink
error: object 2699d230e3b592ae42506d7b5c969a7ac6a4593c: zeroPaddedFilemode: contains zero-padded file modes
fatal: fsck error in packed object
fatal: fetch-pack: invalid index-pack output

But that's a separate issue, I'll probably bring it up on Emacs devel, but I thought I actually send this email before I forget a second time.  :)

-Ivan

> On Jun 15, 2022, at 09:56, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> 
>> 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.
> 
> Thanks; I can confirm that that fixes this issue, so I'm closing this
> bug report.
> 
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>   bloggy blog: http://lars.ingebrigtsen.no






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#27552: 25.2.50; Indentation problem in rnc-mode
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-07-02 21:37 UTC (permalink / raw)
  To: Ivan Andrus; +Cc: 27552, Lars Ingebrigtsen

> $ git clone git://git.sv.gnu.org/emacs/elpaa

`elpa.git` is fairly large, you don't want to clone all of it just for
`rnc-mode`.  Try something like:

    git clone --single-branch git://git.sv.gnu.org/emacs/elpa
    cd elpa
    make    # Initial setup, only needed once.
    make packages/rnc-mode # Fetches rnc-mode and sets it up.
    make packages/rnc-mode # Generate autoloads, <foo>-pkg,el, and compile.


-- Stefan

> Cloning into 'elpa'...
> remote: Counting objects: 420700, done.
> remote: Compressing objects: 100% (122372/122372), done.
> warning: object 40b50e2bcb5b674697e3e2a41627564f810880c4: gitignoreSymlink: .gitignore is a symlink
> warning: object da777249505761d5c51406d4a0d268629f146f8e: gitignoreSymlink: .gitignore is a symlink
> warning: object fa73f7d32f618bd46247364932cac8aa591ed8b9: gitignoreSymlink: .gitignore is a symlink
> warning: object 6bca01e6638f0e92ce277c1497c8f1175236315a: gitignoreSymlink: .gitignore is a symlink
> warning: object 4246bb45961f0e8ed4ccb123648d55a2f043524c: gitignoreSymlink: .gitignore is a symlink
> error: object 2699d230e3b592ae42506d7b5c969a7ac6a4593c: zeroPaddedFilemode:
> contains zero-padded file modes
> fatal: fsck error in packed object
> fatal: fetch-pack: invalid index-pack output

If you do want to clone it all, then I think you'll need

    [fetch "fsck"]
            zeroPaddedFilemode = warn

in your `~/.gitconfig` because we were unlucky to have some entries in
our Git history (generated by some earlier version of Git) which Git
later decided should use a different format.  IIRC we had that in our
old `master` branch which should be gone now, but since then we
inherited some other occurrence of the problem from the history of
some package.

I bumped the version so a new 0.3 should appear soonish, tho.


        Stefan


> But that's a separate issue, I'll probably bring it up on Emacs devel, but
> I thought I actually send this email before I forget a second time.  :)
>
> -Ivan
>
>> On Jun 15, 2022, at 09:56, Lars Ingebrigtsen <larsi@gnus.org> wrote:
>> 
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 
>>> 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.
>> 
>> Thanks; I can confirm that that fixes this issue, so I'm closing this
>> bug report.
>> 
>> -- 
>> (domestic pets only, the antidote for overdose, milk.)
>>   bloggy blog: http://lars.ingebrigtsen.no






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-02 21:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.