From: Eshel Yaron Date: Mon, 17 Oct 2022 16:13:42 +0000 (+0300) Subject: ENHANCED: prompt for sweeprolog-describe-predicate X-Git-Tag: V8.5.19~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3dbc305acbbc099fc0bbacf15fcb3179dc358bc4;p=sweep.git ENHANCED: prompt for sweeprolog-describe-predicate Following feedback from Jan Wielemaker --- 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)