💾 Archived View for warp.geminispace.club › ~freezr › gemlog › 2023-03-17-emacs-for-speedata.gmi captured on 2024-08-24 at 23:44:07. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-06-14)
-=-=-=-=-=-=-
Updated at 2023-06-06
If you follow my "Pebcak's diary" you already knew that I am trying to learn these high-level TeX implementations, such as ConTeXt and Speedata Publisher.
The latter is especially challenging since works exclusively with "XML Schema" and I found very few native opensource editors able to work with this XML variation.
Speedata is pretty Linux and opensource friendly but, unfortunately, it provides exclusively documentation for my least favorite editors; however it recommends Emacs as a potential alternative.
Speedata manual — How to write the layout: XML Editor
I surely prefer using GNU Emacs rather than the applications suggested, however Emacs has its learning curve and some caveats that must be addressed if you want use it in combination with XML Schema.
My dear friend OP — yes, always him — author of GMID (my capsule's server) and Telescope (my favorite TUI client) is also a BIG fan of Emacs.
He encouraged myself to use Emacs, and to facilitate this adoption he prepared for me a special setup to make my life easier!
The set up is straightforward and doesn't require any special expertise, a simple plain text file — called "init.el" — must be create inside your ~/.emacs.d/ directory (if it doesn't exist just make it) with the following content:
IMPORTANT: Emacs will create auto-comments in your custom edit, do not worry if eventually it will look a little bit more verbose than my code block.
;; Actives the following standard control-c/v/x/z (cua-mode +1) ;; Automatic closes brackets and quotation marks (electric-pair-mode +1) ;; Automatic close XML tags (setq nxml-slash-auto-complete-flag t) ;; Makes the font size bigger (let ((font "Monospace 14")) (set-frame-font font nil t) (add-to-list 'default-frame-alist `(font . ,font))) ;; Enables control-s to save (define-key global-map (kbd "C-s") #'save-buffer) ;; Enables control-f to search (define-key global-map (kbd "C-f") #'isearch-forward) (define-key isearch-mode-map (kbd "C-f") #'isearch-repeat-forward) ;; Enables control-q to close (define-key global-map (kbd "C-q") #'save-buffers-kill-terminal) ;; XML Schema (unless (package-installed-p 'rnc-mode) (package-install 'rnc-mode)) ;; CORFU autocompletion (unless (package-installed-p 'corfu) (package-install 'corfu)) (global-corfu-mode +1) (setq tab-always-indent 'complete corfu-auto t corfu-quit-no-match 'separator)
For the ones that didn't understand anything — like myself — these settings do the following:
GNU Emacs supports "XML Schema" through a different dialect called "Relax NG".
The Schema provided by Speedata has the extension RNG while the "Relax NG" supported by Emacs supports instead Schema that uses the RNC extension. This tiny difference had driven me crazy until OP found the pebcak and thus the solution.
The solution was using a (java) package called "Trang" — available on Debian/Devuan repository, the can convert .RNG files into .RNC files. The utilization is pretty intuitive:
trang layoutschema-en.rng layoutschema-en.rnc
Based on your personal preferences you can convert it by yourself or download the one I converted by myself.
I don't know the reason but I couldn't find a method to let Emacs remembering to use the associated schema, this means that everytime you open the `layout.xml` file you must do this procedure again and again. It is strongly recommended to have the `layoutschema-en.rnc` inside your working folder.
On Emacs, "XML Schema/Relax NG" is called "nXML mode":
Emacs Manual: 6 Locating a schema
Emacs Manual: 6.1 Commands for locating a schema
💡 Gnu Emacs goes in nXML mode automatically
⚠️ I re-edit this sequence of commands since the one I made before was unreliable
⚠️ This method is still unreliable, the procedure must be done everytime you reopen any Speedata XML file.
C-c C-s C-w
C-c C-s C-f
C-c C-s C-w
The command C-c C-s C-l adds a rule to a schema locating file that persistently associates the document with the schema that is currently being used.
C-c C-s C-l
C-c C-s C-a
IMPORTANT: I tested this method on Debian/Devuan only.
lsb_release -a No LSB modules are available. Distributor ID: Devuan Description: Devuan GNU/Linux 5 (daedalus/ceres) Release: 5 Codename: daedalus ceres emacs --version GNU Emacs 28.2
You may try installing this package:
elpa-use-package
Unfortunately the first iteration of this guide didn't really work out. Schema was frequently forgotten, Emacs showed the xml was correct while was actually incorrect when matched with the right schema. Without the right schema it is almost impossible write correct XML. I was almost to the point to give up with Emacs (which I don't really like) to go with the Empire of Evil. As a matter of fact, looks like the first time I missed to make the association persintent. I'll test this method for a while, if you can read this gemlog it means it eventually has worked! 🤞
⚠️ Sadly the association must be made every time you open or reopen the layout.xml file, otherwise it will forget the association. ⚠️
🕒 [OLD VERSION] Thanks to OP, automagically tags are suggested and closed, key combinations work as expected! This spares to me a lot of headache and the shame to use nefarious editors, with the additional value that my workflow can be still the same on any OS that support Emacs.
I am very happy! 😬
For comments or suggestion write me at: