From 3eedcc534aa5189b8b110b204beecef4c773fcfa Mon Sep 17 00:00:00 2001 From: Samuel Ortion Date: Thu, 30 Nov 2023 07:25:04 +0100 Subject: [PATCH] Add example of installation on Doomemacs and fix the stringp nil in error handling --- LICENSE | 0 README.org | 24 +++++++++++++++++++++++- ob-pasp.el | 14 +++++++------- 3 files changed, 30 insertions(+), 8 deletions(-) mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.org mode change 100644 => 100755 ob-pasp.el diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.org b/README.org old mode 100644 new mode 100755 index 79f8da5..ba29485 --- a/README.org +++ b/README.org @@ -1,5 +1,5 @@ * ob-pasp -Org-Babel mode to execute Clingo Potassco code within Org-mode +Org-Babel mode to execute Potassco Answer Set Programming code within Org-mode with =clingo=. #+begin_src pasp child(C, P) :- parent(P, C). @@ -21,3 +21,25 @@ Calls : 1 Time : 0.000s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s) CPU Time : 0.000s #+end_example + +** Installation + +The package is not (yet) available on MELPA, so the package should be installed from github directly. + +*** Dependencies + +To be able to use =ob-pasp= you will need to install =clingo= cli. + + +*** Doomemacs + +In your =$DOOMDIR/package.el= file, you might want to set up the following: +#+begin_src emacs-lisp +(package! pasp-mode) ;; Add syntax highlighting for Potassco ASP +(package! ob-pasp + :recipe (:host github :repo "UncleSamulus/ob-pasp")) +#+end_src + + +** TODO Spacemacs +** TODO =use-package= / =straight= diff --git a/ob-pasp.el b/ob-pasp.el old mode 100644 new mode 100755 index de8a3dc..63db8cd --- a/ob-pasp.el +++ b/ob-pasp.el @@ -129,16 +129,16 @@ This function is called by `org-babel-execute-src-block'" (let* ((processed-params (org-babel-process-params params)) ;; set the session if the value of the session keyword is not the ;; string `none' - ;(session (unless (string= value "none") - ; (org-babel-pasp-initiate-session - ; (cdr (assq :session processed-params))))) + ;(session (unless (string= value "none") + ; (org-babel-pasp-initiate-session + ; (cdr (assq :session processed-params))))) ;; set the -n option to ask for more models (models (cdr (assoc :n processed-params))) ;; variables assigned for use in the block (vars (org-babel--get-vars processed-params)) (result-params (assq :result-params processed-params)) ;; either OUTPUT or VALUE which should behave as described above - (result-type (assq :result-type processed-params)) + (result-type "output"); (assq :result-type processed-params)) ;; expand the body with `org-babel-expand-body:pasp' (full-body (org-babel-expand-body:pasp body params processed-params)) @@ -146,8 +146,8 @@ This function is called by `org-babel-execute-src-block'" (clingo (executable-find "clingo")) (cmd (concat (shell-quote-argument (expand-file-name clingo)) (when models - (concat " -n " models)) - " " (org-babel-process-file-name temp-file)))) + (concat " -n " (int-to-string models))) + " " (org-babel-process-file-name temp-file)))) ;; actually execute the source-code block either in a session or ;; possibly by dropping it to a temporary file and evaluating the ;; file. @@ -165,7 +165,7 @@ This function is called by `org-babel-execute-src-block'" ;; ref. https://github.com/arnm/ob-mermaid (unless (file-executable-p clingo) - (error "Cannot find or execute %s, please check `clingo`" clingo)) + (error "Cannot find or execute `clingo', please check it is installed and in PATH")) (with-temp-file temp-file (insert full-body)) (message "%s" cmd) (org-babel-eval cmd "")