From 0f1ad2e1f55725f31324108320dae16e69fba34b Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 19 Nov 2022 18:35:28 +0200 Subject: [PATCH] * sweeprolog.el (sweeprolog-identifier-at-point): check major-mode --- sweeprolog.el | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index 36523e5..f98e947 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -862,21 +862,22 @@ module name, F is a functor name and N is its arity." (user-error "Unable to locate predicate %s" mfn))) (defun sweeprolog-identifier-at-point (&optional point) - (setq point (or point (point))) - (save-excursion - (goto-char point) - (let ((id-at-point nil)) - (sweeprolog-analyze-term-at-point - (lambda (beg end arg) - (when (<= beg point end) - (pcase arg - ((or `("head_term" ,_ ,f ,a) - `("goal_term" ,_ ,f ,a) - `("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 (derived-mode-p 'sweeprolog-mode 'sweeprolog-top-level-mode) + (setq point (or point (point))) + (save-excursion + (goto-char point) + (let ((id-at-point nil)) + (sweeprolog-analyze-term-at-point + (lambda (beg end arg) + (when (<= beg point end) + (pcase arg + ((or `("head_term" ,_ ,f ,a) + `("goal_term" ,_ ,f ,a) + `("head" ,_ ,f ,a) + `("goal" ,_ ,f ,a)) + (setq id-at-point (list f a))))))) + (sweeprolog--query-once "sweep" "sweep_functor_arity_pi" + id-at-point))))) ;;;; Modules -- 2.39.2