Add nXML/TEI features

master
trémeur 2 years ago
parent 688cf1f105
commit c61d26f465

@ -423,6 +423,52 @@ Show a nice filetree with icons. I use this much less often than I should.
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))))
#+END_SRC
** =nXML-mode=
Attempting to do TEI stuff at work but I cant link directly to the =.rnc= file here; have to list it in a =schemas.xml= file first, which references the =.rnc= file locally (not sure how we would do an absolute filepath for this).
#+BEGIN_SRC emacs-lisp
(unless (string-equal system-type "android")
(setq rng-schema-locating-files
'("schemas.xml" "~/.emacs.d/tei/schemas.xml" "c:/Program Files/Emacs/x86_64/share/emacs/27.1/etc/schema/schemas.xml"))
(defun indent-the-file ()
(interactive)
(indent-region (point-min) (point-max)))
(add-hook 'nxml-mode-hook
(lambda () (local-set-key (kbd "C-c C-i") 'indent-the-file)))
(add-hook 'nxml-mode-hook
(lambda () (local-set-key (kbd "<tab>") 'completion-at-point))))
#+END_SRC
Show path of current element (from [[https://emacs.stackexchange.com/questions/28606/how-to-show-xpath-for-current-location-in-an-xml-hierarchy-in-the-modeline][here]]).
#+BEGIN_SRC emacs-lisp
(unless (string-equal system-type "android")
(defun nxml-where ()
"Display the hierarchy of XML elements the point is on as a path."
(interactive)
(let ((path nil))
(save-excursion
(save-restriction
(widen)
(while (and (< (point-min) (point)) ;; Doesn't error if point is at beginning of buffer
(condition-case nil
(progn
(nxml-backward-up-element) ; always returns nil
t)
(error nil)))
(setq path (cons (xmltok-start-tag-local-name) path)))
(if (called-interactively-p t)
(message "/%s" (mapconcat 'identity path "/"))
(format "/%s" (mapconcat 'identity path "/")))))))
(defun xml-find-file-hook ()
(when (derived-mode-p 'nxml-mode)
(which-function-mode t)
(setq which-func-mode t)
(add-hook 'which-func-functions 'nxml-where t t)))
(add-hook 'find-file-hook 'xml-find-file-hook t))
#+END_SRC
** =nov=
For reading ebooks. Only on Linux because I (supposedly) use it with my calibre library.

@ -0,0 +1,7 @@
# name: teicorpus-skeleton
# key: teicorpusskel
# --
<?xml version="1.0" encoding="UTF-8"?>
<teiCorpus xmlns="http://www.tei-c.org/ns/1.0">
$0
</teiCorpus>

@ -0,0 +1,7 @@
# name: tei-skeleton
# key: teiskel
# --
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
$0
</TEI>

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
<namespace ns="http://www.tei-c.org/ns/1.0" uri="tei_all.rnc"/>
</locatingRules>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save