diff --git a/emacs/tawny-mode.el b/emacs/tawny-mode.el index 591a62f..93c3f36 100644 --- a/emacs/tawny-mode.el +++ b/emacs/tawny-mode.el @@ -34,6 +34,7 @@ (require 'nrepl-client) (require 'clojure-mode) (require 'easymenu) +(require 'cl) ;;; Code: @@ -82,6 +83,32 @@ elk or jfact." (cider-current-ns) ))) +(defun tawny-mode-identitas () + "Prints random prolong (lexical pronounceable string) ID generated +by the Identitaslibrary." + (interactive) + (tawny-mode-check-for-nrepl-buffer) + (cider-nrepl-request:eval + (format + "(do (require 'tawny.emacs)(tawny.emacs/identitas \"%s\"))" + (cider-current-ns)) + (tawny-mode-make-into-buffer-response-handler (point-marker)))) + +(defun tawny-mode-make-into-buffer-response-handler(marker) + "Return a messaging response handler into the current BUFFER." + (lexical-let + ((m marker)) + (nrepl-make-response-handler + (marker-buffer marker) + (lambda (buffer value) + (save-excursion + (set-buffer (marker-buffer m)) + (goto-char m) + (insert (substring value 1 -1)))) + (lambda (buffer value)) + (lambda (buffer value)) + (lambda (buffer))))) + (defun tawny-mode-unsatisfiable () "Prints a message describing unsatisfiability of current ontology." (interactive) diff --git a/project.clj b/project.clj index 2eca613..840bde6 100644 --- a/project.clj +++ b/project.clj @@ -47,7 +47,10 @@ ;; Shut up ELK [log4j/log4j "1.2.17"] ;; Shut up OWL API - [org.slf4j/slf4j-nop "1.7.10"]] + [org.slf4j/slf4j-nop "1.7.10"] + + ;; identitas + [uk.org.russet/identitas-j "0.0.1"]] ;; multiple profiles for testing against different OWL versions. The :base ;; dependency adds dev-resources to the path which I need for testing. diff --git a/src/tawny/emacs.clj b/src/tawny/emacs.clj index 2c2f45d..ece3b56 100644 --- a/src/tawny/emacs.clj +++ b/src/tawny/emacs.clj @@ -72,6 +72,12 @@ NAMESPACE" "Ontology is consistent." "Ontology is not consistent.")))) +(defn identitas + "Return a random prolong ID from the identitas library." + [id] + (let [id (uk.org.russet.identitas.Util/randomProlong)] + id)) + (defn list-classes "Given a set of classes, returns a string representation." [classes]