* bug#73359: 30.0.91; editorconfig does not work on xml files
@ 2024-09-19 7:29 Nguyễn Quốc Minh
2024-09-19 16:10 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Nguyễn Quốc Minh @ 2024-09-19 7:29 UTC (permalink / raw)
To: 73359
[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]
Hello,
I have encountered an issue when opening an xml file from emacs 30, here is
how to reproduce:
1. start emacs with 'emacs -Q -mm'
2. enable editorconfig-mode with 'M-x editorconfig-mode'
3. open an xml file, e.g., pom.xml from a Java project.
4. observe the minibuffer:
For information about GNU Emacs and the GNU system, type C-h C-a.
funcall-interactively: Text is read-only [10 times]
Quit
Editorconfig mode enabled
Quit
pom.xml has auto save data; consider M-x recover-this-file
Using vacuous schema
Unsupported element in ‘editorconfig-indentation-alist’:
((nxml-attribute-indent . 2) . 2)
Directory-local variables error: (wrong-type-argument listp Unsupported
element in ‘editorconfig-indentation-alist’: ((nxml-attribute-indent . 2) .
2))
My '.editorconfig' content:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
[*.{java,proto}]
indent_size = 4
Best regards,
minh
[-- Attachment #2: Type: text/html, Size: 1558 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#73359: 30.0.91; editorconfig does not work on xml files
2024-09-19 7:29 bug#73359: 30.0.91; editorconfig does not work on xml files Nguyễn Quốc Minh
@ 2024-09-19 16:10 ` Eli Zaretskii
2024-09-20 18:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2024-09-19 16:10 UTC (permalink / raw)
To: Nguyễn Quốc Minh, Stefan Monnier; +Cc: 73359
> From: Nguyễn Quốc Minh
> <nqminhuit@gmail.com>
> Date: Thu, 19 Sep 2024 14:29:48 +0700
>
> 1. start emacs with 'emacs -Q -mm'
> 2. enable editorconfig-mode with 'M-x editorconfig-mode'
> 3. open an xml file, e.g., pom.xml from a Java project.
> 4. observe the minibuffer:
>
> For information about GNU Emacs and the GNU system, type C-h C-a.
> funcall-interactively: Text is read-only [10 times]
> Quit
> Editorconfig mode enabled
> Quit
> pom.xml has auto save data; consider M-x recover-this-file
> Using vacuous schema
> Unsupported element in ‘editorconfig-indentation-alist’: ((nxml-attribute-indent . 2) . 2)
> Directory-local variables error: (wrong-type-argument listp Unsupported element in
> ‘editorconfig-indentation-alist’: ((nxml-attribute-indent . 2) . 2))
Stefan, this element of editorconfig-indentation-alist:
(nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
seems to violate the expected form of the elements, which is
(MODE . SETTING). It was added as part of commit 8e143a2f300, whose
log says "Sync with upstream", so I suppose this form of the element
is supported by upstream, but not by Emacs? I guess we need to
replace it with a function or something?
Btw, can we clarify the doc string of editorconfig-indentation-alist,
where it says "where SETTING should obey the same rules as
`editorconfig-indent-size-vars'"? Because if one looks at the doc
string of editorconfig-indent-size-vars, the "rules" are either
trivial or unclear. If SETTING above should be one or more symbols
("list of variables that need to be set to SIZE") or a function that
returns a list of (VAR . VAL) pairs, then why not say that in the doc
string of editorconfig-indentation-alist?
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#73359: 30.0.91; editorconfig does not work on xml files
2024-09-19 16:10 ` Eli Zaretskii
@ 2024-09-20 18:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-21 10:36 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-20 18:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 73359, Nguyễn Quốc Minh
> Stefan, this element of editorconfig-indentation-alist:
>
> (nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
>
> seems to violate the expected form of the elements, which is
> (MODE . SETTING). It was added as part of commit 8e143a2f300, whose
> log says "Sync with upstream", so I suppose this form of the element
> is supported by upstream, but not by Emacs? I guess we need to
> replace it with a function or something?
Yup. I pushed the patch below to `emacs-30` for it.
> Btw, can we clarify the doc string of editorconfig-indentation-alist,
> where it says "where SETTING should obey the same rules as
> `editorconfig-indent-size-vars'"? Because if one looks at the doc
> string of editorconfig-indent-size-vars, the "rules" are either
> trivial or unclear. If SETTING above should be one or more symbols
> ("list of variables that need to be set to SIZE") or a function that
> returns a list of (VAR . VAL) pairs, then why not say that in the doc
> string of editorconfig-indentation-alist?
I didn't want to do it because it's redundant with the docstring of
`editorconfig-indent-size-vars`, but see the patch where I tried to
address your request.
Stefan
diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el
index 931781007d9..870f6d32162 100644
--- a/lisp/editorconfig.el
+++ b/lisp/editorconfig.el
@@ -211,7 +211,7 @@ editorconfig-indentation-alist
(mustache-mode mustache-basic-offset)
(nasm-mode nasm-basic-offset)
(nginx-mode nginx-indent-level)
- (nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
+ (nxml-mode . editorconfig--get-indentation-nxml-mode)
(objc-mode c-basic-offset)
(octave-mode octave-block-offset)
(perl-mode perl-indent-level)
@@ -266,7 +266,9 @@ editorconfig-indentation-alist
`editorconfig-indent-size-vars'.
Each element should look like (MODE . SETTING) where SETTING
-should obey the same rules as `editorconfig-indent-size-vars'."
+should obey the same rules as `editorconfig-indent-size-vars',
+i.e. either a list of variable names or a function returning a list of (VAR . VAL)
+settings."
:type '(alist :key-type symbol
:value-type (choice function
(repeat
@@ -341,6 +343,11 @@ editorconfig--get-indentation-latex-mode
(LaTeX-indent-level . ,size)
(LaTeX-item-indent . ,(- size))))
+(defun editorconfig--get-indentation-nxml-mode (size)
+ "Vars to set `nxml-mode' indent size to SIZE."
+ `((nxml-child-indent . ,size)
+ (nxml-attribute-indent . ,(* 2 size))))
+
(defun editorconfig--get-indentation-lisp-mode (size)
"Set indent size to SIZE for Lisp mode(s)."
(when (cond ((null editorconfig-lisp-use-default-indent) t)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#73359: 30.0.91; editorconfig does not work on xml files
2024-09-20 18:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-09-21 10:36 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-09-21 10:36 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 73359-done, nqminhuit
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Nguyễn Quốc Minh <nqminhuit@gmail.com>,
> 73359@debbugs.gnu.org
> Date: Fri, 20 Sep 2024 14:58:54 -0400
>
> > Stefan, this element of editorconfig-indentation-alist:
> >
> > (nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
> >
> > seems to violate the expected form of the elements, which is
> > (MODE . SETTING). It was added as part of commit 8e143a2f300, whose
> > log says "Sync with upstream", so I suppose this form of the element
> > is supported by upstream, but not by Emacs? I guess we need to
> > replace it with a function or something?
>
> Yup. I pushed the patch below to `emacs-30` for it.
Thanks, I'm therefore closing this bug.
> > Btw, can we clarify the doc string of editorconfig-indentation-alist,
> > where it says "where SETTING should obey the same rules as
> > `editorconfig-indent-size-vars'"? Because if one looks at the doc
> > string of editorconfig-indent-size-vars, the "rules" are either
> > trivial or unclear. If SETTING above should be one or more symbols
> > ("list of variables that need to be set to SIZE") or a function that
> > returns a list of (VAR . VAL) pairs, then why not say that in the doc
> > string of editorconfig-indentation-alist?
>
> I didn't want to do it because it's redundant with the docstring of
> `editorconfig-indent-size-vars`, but see the patch where I tried to
> address your request.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-21 10:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19 7:29 bug#73359: 30.0.91; editorconfig does not work on xml files Nguyễn Quốc Minh
2024-09-19 16:10 ` Eli Zaretskii
2024-09-20 18:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-21 10:36 ` Eli Zaretskii
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.