Skip to content

Commit a5f8163

Browse files
committed
paren!
1 parent 8b76e1b commit a5f8163

File tree

2 files changed

+116
-116
lines changed

2 files changed

+116
-116
lines changed

elot-defs.org

+57-57
Original file line numberDiff line numberDiff line change
@@ -305,63 +305,63 @@ the ID string.
305305
*** puri expansion
306306
#+name: defun-puri
307307
#+BEGIN_SRC emacs-lisp :results silent
308-
(defconst puri-re "^\\([-a-z_A-Z0-9]*\\):\\([a-z_A-Z0-9-.]*\\)$")
309-
310-
(defun unprefix-uri (puri abbrev-alist)
311-
"Replace prefix in puri with full form from abbrev-alist, if there's a match."
312-
(if (eq abbrev-alist nil) puri
313-
(if (string-match puri-re puri)
314-
(let* ((this-prefix (match-string-no-properties 1 puri))
315-
(this-localname (match-string-no-properties 2 puri))
316-
(this-ns (cdr (assoc this-prefix abbrev-alist))))
317-
(if this-ns
318-
(concat "<" this-ns this-localname ">")
319-
puri))
320-
puri)))
321-
322-
(defun annotation-string-or-uri (str)
323-
"str is wanted as an annotation value in Manchester Syntax. Expand uri, or return number, or wrap in quotes."
324-
; maybe this entry contains string representation of meta-annotations, remove them
325-
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
326-
;; maybe there's macros in the string, expand them
327-
(if (string-match "{{{.+}}}" str)
328-
(let ((omt org-macro-templates))
329-
(with-temp-buffer (org-mode)
330-
(insert str) (org-macro-replace-all omt)
331-
(setq str (buffer-string)))))
332-
(cond (; a number -- return the string
333-
(string-match "^[[:digit:]]+[.]?[[:digit:]]*$" str)
334-
(concat " " str))
335-
(; a bare URI, which org-mode wraps in double brackets -- wrap in angles
336-
(string-match "^[[][[]\\(https?[^ ]*\\)[]][]]$" str)
337-
(concat " <" (match-string 1 str) ">"))
338-
(; a bare URI, but no double brackets -- wrap in angles
339-
(string-match "^\\(https?[^ ]*\\)$" str)
340-
(concat " <" (match-string 1 str) ">"))
341-
(; a bare URI, in angles
342-
(string-match "^\\(<https?[^ ]*>\\)$" str)
343-
(concat " " (match-string 1 str)))
344-
(; true -- make it an explicit boolean
345-
(string-match "true" str) " \"true\"^^xsd:boolean")
346-
(; false -- make it an explicit boolean
347-
(string-match "false" str) " \"false\"^^xsd:boolean")
348-
(; string with datatype -- return unchanged
349-
(string-match "^\".*\"^^[-_[:alnum:]]*:[-_[:alnum:]]+$" str)
350-
(concat " " str))
351-
(; not a puri -- normal string, wrap in quotes
352-
(equal str (unprefix-uri str org-link-abbrev-alist-local))
353-
;; if a language tag @en is present, return unchanged
354-
(if (string-match "\"\\(.*\n\\)*.*\"@[a-z]+" str)
355-
(concat " " str)
356-
;; escape all quotes with \", note this gives invalid results if some are already escaped
357-
(concat " \"" (replace-regexp-in-string "\"" "\\\\\"" str) "\"")))
358-
(; else, a puri -- wrap in angles
359-
t (concat " " (unprefix-uri str org-link-abbrev-alist-local))))
360-
361-
(defun omn-restriction-string (str)
362-
"str is wanted as OMN value. Strip any meta-annotations. Otherwise return unchanged."
363-
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
364-
str)
308+
(defconst puri-re "^\\([-a-z_A-Z0-9]*\\):\\([a-z_A-Z0-9-.]*\\)$")
309+
310+
(defun unprefix-uri (puri abbrev-alist)
311+
"Replace prefix in puri with full form from abbrev-alist, if there's a match."
312+
(if (eq abbrev-alist nil) puri
313+
(if (string-match puri-re puri)
314+
(let* ((this-prefix (match-string-no-properties 1 puri))
315+
(this-localname (match-string-no-properties 2 puri))
316+
(this-ns (cdr (assoc this-prefix abbrev-alist))))
317+
(if this-ns
318+
(concat "<" this-ns this-localname ">")
319+
puri))
320+
puri)))
321+
322+
(defun annotation-string-or-uri (str)
323+
"str is wanted as an annotation value in Manchester Syntax. Expand uri, or return number, or wrap in quotes."
324+
; maybe this entry contains string representation of meta-annotations, remove them
325+
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
326+
;; maybe there's macros in the string, expand them
327+
(if (string-match "{{{.+}}}" str)
328+
(let ((omt org-macro-templates))
329+
(with-temp-buffer (org-mode)
330+
(insert str) (org-macro-replace-all omt)
331+
(setq str (buffer-string)))))
332+
(cond (; a number -- return the string
333+
(string-match "^[[:digit:]]+[.]?[[:digit:]]*$" str)
334+
(concat " " str))
335+
(; a bare URI, which org-mode wraps in double brackets -- wrap in angles
336+
(string-match "^[[][[]\\(https?[^ ]*\\)[]][]]$" str)
337+
(concat " <" (match-string 1 str) ">"))
338+
(; a bare URI, but no double brackets -- wrap in angles
339+
(string-match "^\\(https?[^ ]*\\)$" str)
340+
(concat " <" (match-string 1 str) ">"))
341+
(; a bare URI, in angles
342+
(string-match "^\\(<https?[^ ]*>\\)$" str)
343+
(concat " " (match-string 1 str)))
344+
(; true -- make it an explicit boolean
345+
(string-match "true" str) " \"true\"^^xsd:boolean")
346+
(; false -- make it an explicit boolean
347+
(string-match "false" str) " \"false\"^^xsd:boolean")
348+
(; string with datatype -- return unchanged
349+
(string-match "^\".*\"^^[-_[:alnum:]]*:[-_[:alnum:]]+$" str)
350+
(concat " " str))
351+
(; not a puri -- normal string, wrap in quotes
352+
(equal str (unprefix-uri str org-link-abbrev-alist-local))
353+
;; if a language tag @en is present, return unchanged
354+
(if (string-match "\"\\(.*\n\\)*.*\"@[a-z]+" str)
355+
(concat " " str)
356+
;; escape all quotes with \", note this gives invalid results if some are already escaped
357+
(concat " \"" (replace-regexp-in-string "\"" "\\\\\"" str) "\"")))
358+
(; else, a puri -- wrap in angles
359+
t (concat " " (unprefix-uri str org-link-abbrev-alist-local)))))
360+
361+
(defun omn-restriction-string (str)
362+
"str is wanted as OMN value. Strip any meta-annotations. Otherwise return unchanged."
363+
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
364+
str)
365365
#+END_SRC
366366
*** Use section headings as ontology resources
367367
=org-list-siblings= returns a tree of headline strings that matches the

elot-package/elot.el

+59-59
Original file line numberDiff line numberDiff line change
@@ -270,58 +270,58 @@ resources if point is under a heading that declares an ontology."
270270
(defun unprefix-uri (puri abbrev-alist)
271271
"Replace prefix in puri with full form from abbrev-alist, if there's a match."
272272
(if (eq abbrev-alist nil) puri
273-
(if (string-match puri-re puri)
274-
(let* ((this-prefix (match-string-no-properties 1 puri))
275-
(this-localname (match-string-no-properties 2 puri))
276-
(this-ns (cdr (assoc this-prefix abbrev-alist))))
277-
(if this-ns
278-
(concat "<" this-ns this-localname ">")
279-
puri))
280-
puri)))
273+
(if (string-match puri-re puri)
274+
(let* ((this-prefix (match-string-no-properties 1 puri))
275+
(this-localname (match-string-no-properties 2 puri))
276+
(this-ns (cdr (assoc this-prefix abbrev-alist))))
277+
(if this-ns
278+
(concat "<" this-ns this-localname ">")
279+
puri))
280+
puri)))
281281

282282
(defun annotation-string-or-uri (str)
283-
"str is wanted as an annotation value in Manchester Syntax. Expand uri, or return number, or wrap in quotes."
284-
; maybe this entry contains string representation of meta-annotations, remove them
285-
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
286-
;; maybe there's macros in the string, expand them
287-
(if (string-match "{{{.+}}}" str)
288-
(let ((omt org-macro-templates))
289-
(with-temp-buffer (org-mode)
290-
(insert str) (org-macro-replace-all omt)
291-
(setq str (buffer-string)))))
292-
(cond (; a number -- return the string
293-
(string-match "^[[:digit:]]+[.]?[[:digit:]]*$" str)
294-
(concat " " str))
295-
(; a bare URI, which org-mode wraps in double brackets -- wrap in angles
296-
(string-match "^[[][[]\\(https?[^ ]*\\)[]][]]$" str)
297-
(concat " <" (match-string 1 str) ">"))
298-
(; a bare URI, but no double brackets -- wrap in angles
299-
(string-match "^\\(https?[^ ]*\\)$" str)
300-
(concat " <" (match-string 1 str) ">"))
301-
(; a bare URI, in angles
302-
(string-match "^\\(<https?[^ ]*>\\)$" str)
303-
(concat " " (match-string 1 str)))
304-
(; true -- make it an explicit boolean
305-
(string-match "true" str) " \"true\"^^xsd:boolean")
306-
(; false -- make it an explicit boolean
307-
(string-match "false" str) " \"false\"^^xsd:boolean")
308-
(; string with datatype -- return unchanged
309-
(string-match "^\".*\"^^[-_[:alnum:]]*:[-_[:alnum:]]+$" str)
310-
(concat " " str))
311-
(; not a puri -- normal string, wrap in quotes
312-
(equal str (unprefix-uri str org-link-abbrev-alist-local))
313-
;; if a language tag @en is present, return unchanged
314-
(if (string-match "\"\\(.*\n\\)*.*\"@[a-z]+" str)
315-
(concat " " str)
316-
;; escape all quotes with \", note this gives invalid results if some are already escaped
317-
(concat " \"" (replace-regexp-in-string "\"" "\\\\\"" str) "\"")))
318-
(; else, a puri -- wrap in angles
319-
t (concat " " (unprefix-uri str org-link-abbrev-alist-local))))
283+
"str is wanted as an annotation value in Manchester Syntax. Expand uri, or return number, or wrap in quotes."
284+
; maybe this entry contains string representation of meta-annotations, remove them
285+
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
286+
;; maybe there's macros in the string, expand them
287+
(if (string-match "{{{.+}}}" str)
288+
(let ((omt org-macro-templates))
289+
(with-temp-buffer (org-mode)
290+
(insert str) (org-macro-replace-all omt)
291+
(setq str (buffer-string)))))
292+
(cond (; a number -- return the string
293+
(string-match "^[[:digit:]]+[.]?[[:digit:]]*$" str)
294+
(concat " " str))
295+
(; a bare URI, which org-mode wraps in double brackets -- wrap in angles
296+
(string-match "^[[][[]\\(https?[^ ]*\\)[]][]]$" str)
297+
(concat " <" (match-string 1 str) ">"))
298+
(; a bare URI, but no double brackets -- wrap in angles
299+
(string-match "^\\(https?[^ ]*\\)$" str)
300+
(concat " <" (match-string 1 str) ">"))
301+
(; a bare URI, in angles
302+
(string-match "^\\(<https?[^ ]*>\\)$" str)
303+
(concat " " (match-string 1 str)))
304+
(; true -- make it an explicit boolean
305+
(string-match "true" str) " \"true\"^^xsd:boolean")
306+
(; false -- make it an explicit boolean
307+
(string-match "false" str) " \"false\"^^xsd:boolean")
308+
(; string with datatype -- return unchanged
309+
(string-match "^\".*\"^^[-_[:alnum:]]*:[-_[:alnum:]]+$" str)
310+
(concat " " str))
311+
(; not a puri -- normal string, wrap in quotes
312+
(equal str (unprefix-uri str org-link-abbrev-alist-local))
313+
;; if a language tag @en is present, return unchanged
314+
(if (string-match "\"\\(.*\n\\)*.*\"@[a-z]+" str)
315+
(concat " " str)
316+
;; escape all quotes with \", note this gives invalid results if some are already escaped
317+
(concat " \"" (replace-regexp-in-string "\"" "\\\\\"" str) "\"")))
318+
(; else, a puri -- wrap in angles
319+
t (concat " " (unprefix-uri str org-link-abbrev-alist-local)))))
320320

321321
(defun omn-restriction-string (str)
322-
"str is wanted as OMN value. Strip any meta-annotations. Otherwise return unchanged."
323-
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
324-
str)
322+
"str is wanted as OMN value. Strip any meta-annotations. Otherwise return unchanged."
323+
(setq str (replace-regexp-in-string " - [^ ]+ ::.*$" "" str))
324+
str)
325325
;; defun-puri ends here
326326

327327
;; [[file:../elot-defs.org::defun-resource-headings][defun-resource-headings]]
@@ -742,17 +742,17 @@ to ELOT default image (sub)directory. Return output file name."
742742

743743
;; [[file:../elot-defs.org::*ELOT document header][ELOT document header:1]]
744744
(tempo-define-template "elot-doc-header"
745-
'("# -*- eval: (load-library \"elot-defaults\") -*-" > n
746-
"#+title: " (p "Document title: " doctitle) > n
747-
"#+subtitle: An OWL ontology" > n
748-
"#+author: " (p "Author name: " authname) > n
749-
"#+date: WIP (version of " (format-time-string "%Y-%m-%d %H:%M") ")" > n
750-
"#+call: theme-readtheorg()" n n
751-
(progn (load-library "elot-defaults") (message "Loaded ELOT") "")
752-
)
753-
"<odh"
754-
"ELOT document header"
755-
'org-tempo-tags)
745+
'("# -*- eval: (load-library \"elot-defaults\") -*-" > n
746+
"#+title: " (p "Document title: " doctitle) > n
747+
"#+subtitle: An OWL ontology" > n
748+
"#+author: " (p "Author name: " authname) > n
749+
"#+date: WIP (version of " (format-time-string "%Y-%m-%d %H:%M") ")" > n
750+
"#+call: theme-readtheorg()" n n
751+
(progn (load-library "elot-defaults") (message "Loaded ELOT") "")
752+
)
753+
"<odh"
754+
"ELOT document header"
755+
'org-tempo-tags)
756756
;; ELOT document header:1 ends here
757757

758758
;; [[file:../elot-defs.org::*ELOT ontology skeleton][ELOT ontology skeleton:1]]

0 commit comments

Comments
 (0)