💾 Archived View for omg.pebcak.club › ~freezr › gemlog › 2023-03-17-emacs-for-speedata.gmi captured on 2023-04-26 at 13:25:04. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-03-20)
-=-=-=-=-=-=-
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.
On Emacs, "XML Schema/Relax NG" is called "nXML mode":
https://www.gnu.org/software/emacs/manual/html_mono/nxml-mode.html
To assign the Schema to an XML file the procedure is the following one:
C-c C-s C-f
To verify if a XML file is using the right Schema you can use this combination:
C-c C-s C-a
Gnu Emacs goes in nXML mode automatically
IMPORTANT: I tested this method on Debian/Devuan only.
In order to make this setup working on my crapbook:
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
I had to install this package:
elpa-use-package
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: