johanwk / elot

Emacs Literate Ontology Tool
GNU General Public License v3.0
8 stars 2 forks source link

use a templating mechanism for new ontology &c #4

Closed johanwk closed 7 months ago

johanwk commented 8 months ago

UPDATE. Try to go for tempo templates. One good reason is, they are built in.

The Yasnippet package is suitable. The Yankpad package makes it easier to use with org, and is perhaps preferable for this project.

It should be easy to request "new blank ontology" and be prompted for, e.g., ontology URI, then obtain a new org-mode document to write the ontology.

Similarly, provide snippets for defining OWL class/property with common annotation properties already added to be filled out. Also, for diagrams with rdfpuml.

VladimirAlexiev commented 8 months ago

Agree, templates are very useful! Need to see some examples to figure out useful templates.

I personally use the much simpler org-structure-template-alist mechanism. It expands eg <t at the start of line to:

#+begin_src turtle

#+end_src

Here's my setup:

(setq org-structure-template-alist
      ;; (org-tempo-add-templates)
      '(
        ;; ("I" . "include") ; standard
        ;; standard in org-tempo-keywords-alist:
        ;; ("L" . "latex")
        ;; ("H" . "html")
        ;; ("A" . "ascii")
        ;; ("i" . "index")

        ("ee" . "export")
        ("ea" . "export ascii")
        ("eh" . "export html")
        ("el" . "export latex")

        ("s" . "src")
        ("4" . "src m4")
        ("d" . "src dot :file ./img/TODO.png")
        ("g" . "src graphql")
        ("j" . "src json")
        ("p" . "src perl")
        ("S" . "src sparql")
        ("t" . "src turtle")
        ("u" . "src plantuml :file ./img/TODO.png")
        ("x" . "src shexc")
        ("y" . "src yaml")

        ("a" . "abstract")
        ("c" . "center")
        ("C" . "comment")
        ("e" . "example")
        ("n" . "notes")
        ("q" . "quote")
        ("V" . "verbatim")
        ("v" . "verse")
        ))

It uses tempo templates, eg the plantuml template above generates a function like tempo-template-org-src-plantuml-:file-./img/TODO.png

johanwk commented 8 months ago

EDIT. The note below is actually not applicable to templates, but rather to finding the elot-lob file containing source blocks to be added to "library of babel". For templates, tempo indeed looks like a good choice.

A note. To locate the snippets needed, look at https://github.com/AndreaCrotti/yasnippet-snippets/blob/master/yasnippet-snippets.el

This will be important so we can ensure the Library of Babel file elot-lob.org can be properly found as part of the ELOT package, and ingested from the Local Variables: section.

johanwk commented 7 months ago

Added two important templates in a74af84. They query the user for values.

These should be used in a blank org-mode file.