From: Eshel Yaron Date: Tue, 25 Oct 2022 14:38:47 +0000 (+0300) Subject: Use term_string/2 to parse M:F/N terms encoded in strings X-Git-Tag: V8.5.20-sweep-0.8.1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=24b5e1637e4e07049c437372f4f1f7818320cc27;p=sweep.git Use term_string/2 to parse M:F/N terms encoded in strings --- 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