johanwk / elot

Emacs Literate Ontology Tool
GNU General Public License v3.0
7 stars 3 forks source link

(load-library elot-defaults) fails with missing prefixes on Doom Emacs #55

Open weavermarquez opened 3 months ago

weavermarquez commented 3 months ago

Summary

After executing (load-library "elot-defaults"), e.g. in loading pizza.org, the call fails with message

Reference ‘sparql-prefixes’ not found in this buffer

System Details

Emacs 29.3 Doom v3.0.0-pre Doom modules 24.04.0 HEAD -> master 517daa4e

Debug Log

Debugger entered--Lisp error: (error "Reference ‘sparql-prefixes’ not found in this buffer")
  error("Reference `%s' not found in this buffer" "sparql-prefixes")
  org-babel-ref-resolve("sparql-prefixes()")
  #f(compiled-function (m) #<bytecode 0x22c36a29c4d0cc6>)("            (concat \"<<sparql-prefixes()>>")
  replace-regexp-in-string("\\(.*?\\)\\(<<\\([^ \11\n]\\(?:.*?[^ \11\n]\\)?\\)>>\\)" #f(compiled-function (m) #<bytecode 0x22c36a29c4d0cc6>) "  (let* ((query-file\n          (concat (org-babel-temp-directory) \"/\"\n                  query\n                  \".sparql\"))\n         (result-file (con..." t t 2)
  org-babel-expand-noweb-references(("emacs-lisp" "  (let* ((query-file\n          (concat (org-babel-..." ((:results . "replace vector value") (:exports . "both") (:var . "omnfile=\"pizza.omn\"") (:var . "query=\"myquery\"") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:cache . "no") (:session . "none") (:noweb . "yes")) "" "robot-sparql-select" 1801 "(ref:%s)"))
  org-babel-lob-ingest("/var/home/kwalerie/.config/emacs/.local/straight/b...")
  load-with-code-conversion("/var/home/kwalerie/.config/emacs/.local/straight/b..." "/var/home/kwalerie/.config/emacs/.local/straight/b..." nil nil)
  load-library("elot-defaults")
  funcall-interactively(load-library "elot-defaults")
  command-execute(load-library record)
  execute-extended-command(nil "load-library" nil)
  funcall-interactively(execute-extended-command nil "load-library" nil)
  command-execute(execute-extended-command)

Investigation

elob.el (default prefix blocks?) -> elot-defaults.el -> ingest elot-lob.org -> expand <<sparql-prefixes()>>

https://github.com/johanwk/elot/blob/f6a64c5362becb32001af1193503119e9e0934e8/elot-package/elot-defaults.el#L54

I have no clue why this occurs with Doom specifically, presuming this works for vanilla Emacs. I have not tried this with other configurations. Is this some sort of race condition in getting the prefix table / blocks assigned into the menu before noweb expands <<sparql-prefixes()>>?

Workaround

I have no clue how this prefix stuff is supposed to work, but I simply added it to the org file.

  1. Switch to a local version of the elot package, as in #53
  2. Paste this section at the bottom of elot-lob.org
* Prefix Workaround
The ontology document in OWL employs the namespace prefixes of table [[prefix-table]].

#+name: prefix-table
#+attr_latex: :align lp{.8\\textwidth} :font \small
#+caption: OWL ontology prefixes
| prefix    | uri                                                                            |
|-----------+--------------------------------------------------------------------------------|
| owl:      | http://www.w3.org/2002/07/owl#                                                 |
| rdf:      | http://www.w3.org/1999/02/22-rdf-syntax-ns#                                    |
| xml:      | http://www.w3.org/XML/1998/namespace                                           |
| xsd:      | http://www.w3.org/2001/XMLSchema#                                              |
| rdfs:     | http://www.w3.org/2000/01/rdf-schema#                                          |
| skos:     | http://www.w3.org/2004/02/skos/core#                                           |
| pav:      | http://purl.org/pav/                                                           |
| foaf:     | http://xmlns.com/foaf/0.1/                                                     |
| dc:       | http://purl.org/dc/elements/1.1/                                               |
| dcterms:  | http://purl.org/dc/terms/                                                      |
| prov:     | http://www.w3.org/ns/prov#                                                     |
| iof-av:   | https://spec.industrialontologies.org/ontology/core/meta/AnnotationVocabulary/ |

#+name: sparql-prefixes
#+begin_src emacs-lisp :var prefixes=prefix-table :exports none
  (elot-prefix-block-from-alist prefixes 'sparql)
#+end_src
#+name: omn-prefixes
#+begin_src emacs-lisp :var prefixes=prefix-table :exports none
  (elot-prefix-block-from-alist prefixes 'omn)
#+end_src
#+name: ttl-prefixes
#+begin_src emacs-lisp :var prefixes=prefix-table :exports none
  (elot-prefix-block-from-alist prefixes 'ttl)
#+end_src

Which results in these Messages, so... yay? Hopefully I can actually try this package out soon.

18 source blocks added to Library of Babel
Loading /var/home/kwalerie/.config/emacs/.local/straight/build-29.3/elot/elot-label-display.el (source)...done
Mark set
Loading /var/home/kwalerie/.config/emacs/.local/straight/build-29.3/elot/elot-defaults.el (source)...done
johanwk commented 3 weeks ago

I wonder how this went (again, sorry for the long delay on my side). The blocks sparql-prefixes, etc. should be contained in pizza.org itself. This makes sense, as each ontology has different prefixes. So it's not great to have these in elot-lob.org, which contains shared content. Maybe lob names local to an org file will override those ingested from elsewhere, but I'm not sure.