From: Eshel Yaron Date: Sat, 19 Nov 2022 16:35:28 +0000 (+0200) Subject: * sweeprolog.el (sweeprolog-identifier-at-point): check major-mode X-Git-Tag: V8.5.20-sweep-0.8.9~10 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0f1ad2e1f55725f31324108320dae16e69fba34b;p=sweep.git * sweeprolog.el (sweeprolog-identifier-at-point): check major-mode --- 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