You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A small change to org-babel-expand-body:sparql allows for :prologue and :epilogue header arguments on SPARQL blocks in org-mode. With this, the list of query prefixes can kept in a single place, and sparql queries take up less space in the org file.
I find the following works for me -- replacing (insert body) in the current version of org-babel-expand-body:sparql to add the contents of prologue and epilogue header arguments.
(defun org-babel-expand-body:sparql (body params)
"Expand BODY according to PARAMS, returning expanded body.
A variable is marked by the use of '?' or '$'; the marker is not
part of the variable name, thus '?x' and '$x' refer to the same
variable."
(with-temp-buffer
;; from here
(insert (mapconcat 'identity
(list (cdr (assq :prologue params))
body
(cdr (assq :epilogue params)))
"\n"))
;; to here
(let ((case-fold-search nil)
(case-replace nil))
(dolist (pair (org-babel--get-vars params))
(goto-char (point-min))
(let ((regexp (concat "[$?]" (regexp-quote (format "%s" (car pair)))))
(replacement (cdr pair)))
(while (re-search-forward regexp nil t)
(replace-match replacement nil nil)))))
(buffer-string)))
How this can be used:
First, keep prefixes in block of its own. Here, the prefixes are neatly listed in an org table.
No, the + is simply there to allow for the header arguments to be split across different lines in the buffer. I dislike it when the headers get so long that they disappear to the right.
A small change to
org-babel-expand-body:sparql
allows for:prologue
and:epilogue
header arguments on SPARQL blocks in org-mode. With this, the list of query prefixes can kept in a single place, and sparql queries take up less space in the org file.I find the following works for me -- replacing
(insert body)
in the current version oforg-babel-expand-body:sparql
to add the contents of prologue and epilogue header arguments.How this can be used:
First, keep prefixes in block of its own. Here, the prefixes are neatly listed in an org table.
Second, put the
:prologue
header argument in a property drawer for a section.The text was updated successfully, but these errors were encountered: