From 3dbc305acbbc099fc0bbacf15fcb3179dc358bc4 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Mon, 17 Oct 2022 19:13:42 +0300 Subject: [PATCH] ENHANCED: prompt for sweeprolog-describe-predicate Following feedback from Jan Wielemaker --- sweeprolog.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index 6162a38..f2d87f3 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -482,8 +482,10 @@ When non-nil, only predicates whose name contains PREFIX are returned." (defvar sweeprolog-read-predicate-history nil) -(defun sweeprolog-read-predicate () - "Read a Prolog predicate (M:F/N) from the minibuffer, with completion." +(defun sweeprolog-read-predicate (&optional prompt) + "Read a Prolog predicate from the minibuffer with prompt PROMPT. +If PROMPT is nil, `sweeprolog-read-predicate-prompt' is used by +default." (let* ((col (sweeprolog-predicates-collection)) (completion-extra-properties (list :annotation-function @@ -492,7 +494,8 @@ When non-nil, only predicates whose name contains PREFIX are returned." (if val (concat (make-string (- 64 (length key)) ? ) (car val)) nil)))))) - (completing-read sweeprolog-read-predicate-prompt col nil nil nil + (completing-read (or prompt sweeprolog-read-predicate-prompt) + col nil nil nil 'sweeprolog-read-predicate-history (sweeprolog-identifier-at-point)))) @@ -3081,7 +3084,11 @@ if-then-else constructs in SWI-Prolog." ;;;###autoload (defun sweeprolog-describe-predicate (pred) "Display the full documentation for PRED (a Prolog predicate)." - (interactive (list (sweeprolog-read-predicate))) + (interactive (list (sweeprolog-read-predicate + (concat "Describe predicate" + (when-let ((def (sweeprolog-identifier-at-point))) + (concat " (default " def ")")) + ": ")))) (sweeprolog--describe-predicate pred)) (defvar sweeprolog-module-documentation-regexp (rx bol (zero-or-more whitespace) -- 2.39.2