(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 _)