From a6b7339c881b62a3dac56adbf456120bd3ebad34 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 16 Oct 2022 18:20:33 +0300 Subject: [PATCH] ENHANCED: update xref data for buffer after exporting predicate --- sweeprolog.el | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index d1131d3..dd906df 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -2682,30 +2682,31 @@ non-exported predicates defined in the current buffer." (save-excursion (goto-char mend) (let ((pos (- (point-max) (point)))) - (if (search-backward "]" (car sweeprolog--module-term) t) - (combine-after-change-calls - (pcase (sweeprolog-last-token-boundaries) - (`(open ,_ ,_) - (insert pred) - (when (and comm (not (string-empty-p comm))) - (insert " % " comm)) - (insert "\n") - (indent-region mbeg (1+ (point)))) - (`(symbol ,_ ,oend) - (let ((point (point))) - (goto-char oend) - (insert ",") - (goto-char (1+ point)) - (insert "\n") - (backward-char) - (insert pred) - (when (and comm (not (string-empty-p comm))) - (insert " % " comm)) - (indent-region mbeg (- (point-max) pos)) - (align-regexp mbeg (- (point-max) pos) (rx (group (zero-or-more blank)) "%")) - )) - (_ (user-error "Unexpected token while looking for export list")))) - (user-error "Cannot find export list")))) + (unless (search-backward "]" (car sweeprolog--module-term) t) + (user-error "Cannot find export list")) + (combine-after-change-calls + (pcase (sweeprolog-last-token-boundaries) + (`(open ,_ ,_) + (insert pred) + (when (and comm (not (string-empty-p comm))) + (insert " % " comm)) + (insert "\n") + (indent-region mbeg (1+ (point)))) + (`(symbol ,_ ,oend) + (let ((point (point))) + (goto-char oend) + (insert ",") + (goto-char (1+ point)) + (insert "\n") + (backward-char) + (insert pred) + (when (and comm (not (string-empty-p comm))) + (insert " % " comm)) + (indent-region mbeg (- (point-max) pos)) + (align-regexp mbeg (- (point-max) pos) (rx (group (zero-or-more blank)) "%")))) + (_ (user-error "Unexpected token while looking for export list"))))) + (sweeprolog-colourise-buffer) + (message "Exported %s:%s" sweeprolog-buffer-module pred)) (user-error "Buffer is not a module"))) (defun sweeprolog-align-spaces (&optional _) -- 2.39.2