From c131fdd5a5b8e598b2e3946ba523fac721ee6a66 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 19 Nov 2022 21:46:29 +0200 Subject: [PATCH] Don't error in sweeprolog-analyze-term-at-point --- sweeprolog.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index 8e116e8..76a1a27 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -872,8 +872,9 @@ module name, F is a functor name and N is its arity." `("head" ,_ ,f ,a) `("goal" ,_ ,f ,a)) (setq id-at-point (list f a))))))) - (sweeprolog--query-once "sweep" "sweep_functor_arity_pi" - id-at-point))))) + (when id-at-point + (sweeprolog--query-once "sweep" "sweep_functor_arity_pi" + id-at-point)))))) ;;;; Modules @@ -2633,9 +2634,10 @@ of them signal success by returning non-nil." (not (looking-at-p (rx bol (or "%" "/*")))))) (defun sweeprolog-analyze-term-at-point (cb) - (add-hook 'sweeprolog-analyze-region-fragment-hook cb nil t) - (sweeprolog-analyze-term (point)) - (remove-hook 'sweeprolog-analyze-region-fragment-hook cb t)) + (let ((sweeprolog--analyze-point (point))) + (add-hook 'sweeprolog-analyze-region-fragment-hook cb nil t) + (sweeprolog-analyze-term (point)) + (remove-hook 'sweeprolog-analyze-region-fragment-hook cb t))) (defun sweeprolog-definition-at-point (&optional point) (save-excursion -- 2.39.2