treerex / rnc-mode Goto Github PK
View Code? Open in Web Editor NEWEmacs major mode for editing RELAX-NG Compact syntax
Emacs major mode for editing RELAX-NG Compact syntax
Flycheck is a replacement for flymake. Would be good to include this setup:
;; flycheck is a replacement of flymake & smart-compile
;; https://www.masteringemacs.org/article/spotlight-flycheck-a-flymake-replacement
(require 'flycheck)
(flycheck-define-checker rnc-jing
"RNC syntax checker using jing.
Home: https://github.com/relaxng/jing-trang (was https://jing-trang.googlecode.com).
Binary: https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jing-trang/jing-20091111.zip.
Manual: https://relaxng.org/jclark/jing.html"
:command ("java"
"-Xss8M" ; increase stack size to 8M, else get
;; Exception in thread "main" java.lang.StackOverflowError
;; at com.thaiopensource.relaxng.pattern.BinaryPattern.checkRecursion(BinaryPattern.java:16)
"-jar" "c:/prog/jing-20091111/bin/jing.jar"
"-c" ; RelaxNG Compact
"-i" ; else any xsd:ID element returns error
;; `a "data" or "value" pattern with non-null ID-type must occur as the child of an "attribute" pattern`,
;; see http://blog.jclark.com/2009/01/relax-ng-and-xmlid.html
source)
:error-patterns
((error line-start (file-name) ":" line ":" column ": " (or "error" "fatal") ": " (message) line-end)
(error "fatal" ":" (message) line-end)
(info line-start (file-name) ":" line ":" column ": " (message) line-end))
:modes rnc-mode)
(add-to-list 'flycheck-checkers 'rnc-jing)
And then disable flymake, see next issue
If you use flycheck (#9) then you should disable flymake:
(setq rnc-enable-flymake nil ; now do it with flycheck
However, rnc-configure-flymake doesn't respect this option and is called unconditionally.
Until this is fixed, one can use the following:
(defadvice rnc-configure-flymake (around rnc-enable-flymake activate)
"Don't run rnc-configure-flymake unless rnc-enable-flymake is set.
Else the function produces a distracting error message"
(if rnc-enable-flymake ad-do-it))
Consider adding an `imenu' menu that lists the patterns in the current file along the lines of http://inasmuch.as/2012/01/13/imenu-generic-expression/
Consider adding the running of Jing on files using `flymake' along the lines of http://inasmuch.as/2012/02/22/flymake-for-relax-ng-compact-syntax/
To do it properly for a multi-file schema, however, would require running Jing on the file containing the 'start' pattern, which might not be the current file.
Consider this fragment (incomplete):
Vocabulary =
element Vocabulary {
element Subject {(
element Ancestors {(
element Preferred_Ancestor_Branch {
element Ancestor {
element Immediate {ParentType},
element Other {ParentType}*}}
& element Non-Preferred_Ancestor_Branches {
element Non-Preferred_Ancestor_Branch {
element Ancestor {
element Immediate {ParentType},
element Other {ParentType}*}}+}?),
[ a:defaultValue = "300000000" ]
attribute Broad_Parent_ID {VP_Subject_ID}?}
& element Associative_Relationships {
element Associative_Relationship {
element Description {xsd:string}?
& element AR_Date {
element Display_Date {xsd:string}
& element Start_Date {Geog_Date}
& element End_Date {Geog_Date}}?
& element Historic_Flag {associative_rels_historic_flag}?
& element Relationship_Type {ar_code}
& element Related_Subject_ID {
element VP_Subject_ID {VP_Subject_ID}
| element Contrib_Subject_ID {xsd:string}}}*}?
& element Descriptive_Notes {
element Descriptive_Note {
element Note_Text {xsd:string}
& element Note_Language {language_code}
& element Note_Sources {
element Note_Source {
element Source {SourceType}
& element Page {xsd:string}?}+}}*}?
I think the indentation is wrong. It puts these two at the same level, but the second is nested:
& element AR_Date {
& element Start_Date {Geog_Date}
I'd prefer if the words "element/attribute" are aligned properly, and the punctuation &|(< is ignored (visually it doesn't have a lot of weight. But even if that's not possible and it aligns the punctuation, it should indent consistently,
A rnc-mode
is now also available from GNU Elpa: https://elpa.gnu.org/packages/rnc-mode.html. Could you please look into getting whatever additional features your implementations has merged into the Elpa version? Thanks.
There are 2 other similar modes in github:
I haven't compared them but the signature is the same.
I don't know whether those are the same as this code, or whether they are better in any way. Perhaps it's worth comparing and/or merging.
On deeply nested "matroska" rnc schemas, I get this error from jing:
Exception in thread "main" java.lang.StackOverflowError
at com.thaiopensource.relaxng.pattern.BinaryPattern.checkRecursion(BinaryPattern.java:16)
We need a new option rnc-jing-java-options. Setting it to "-Xss8M" avoids the problem
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.