From 24b5e1637e4e07049c437372f4f1f7818320cc27 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 25 Oct 2022 17:38:47 +0300 Subject: [PATCH] Use term_string/2 to parse M:F/N terms encoded in strings --- sweeprolog.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index 1b64376..389cef1 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -6,7 +6,7 @@ ;; Maintainer: Eshel Yaron <~eshel/dev@lists.sr.ht> ;; Keywords: prolog languages extensions ;; URL: https://git.sr.ht/~eshel/sweep -;; Package-Version: 0.8.0 +;; Package-Version: 0.8.1 ;; Package-Requires: ((emacs "28.1")) ;; This file is NOT part of GNU Emacs. @@ -696,9 +696,21 @@ FLAG and VALUE are specified as strings and read as Prolog terms." (cdr sol)))) (defun sweeprolog--mfn-to-functor-arity (mfn) - (let ((functor-arity (split-string (car (reverse (split-string mfn ":"))) "/"))) - (cons (car functor-arity) - (string-to-number (cadr functor-arity))))) + (sweeprolog--open-query "user" "system" "term_string" mfn t) + (let ((sol (sweeprolog-next-solution))) + (sweeprolog-close-query) + (when (sweeprolog-true-p sol) + (pcase (cdr sol) + (`(compound ":" + (atom . ,_) + (compound "/" + (atom . ,functor) + ,arity)) + (cons functor arity)) + (`(compound "/" + (atom . ,functor) + ,arity) + (cons functor arity)))))) (defun sweeprolog--swipl-source-directory () (when sweeprolog-swipl-sources -- 2.39.2