From e1068206662913978d541f924205a0615f8d2d95 Mon Sep 17 00:00:00 2001 From: Spyros Roum Date: Wed, 25 Dec 2024 17:32:31 +0200 Subject: [PATCH] Add option for making compilation-read-command use completing-read --- lisp/progmodes/compile.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 6784a12fd63..a318937e96d 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1797,12 +1797,34 @@ compilation-mode-font-lock-keywords '((compilation--ensure-parse)) compilation-mode-font-lock-keywords)) -(defun compilation-read-command (command) +(defun compilation-prompt-read-shell-command (command) (read-shell-command "Compile command: " command (if (equal (car compile-history) command) '(compile-history . 1) 'compile-history))) +(defun compilation-prompt-read-command-with-completion (command) + (completing-read "Compile command: " compile-history + nil nil command + (if (equal (car compile-history) command) + '(compile-history . 1) + 'compile-history))) + +(defcustom compilation-read-command-function + 'compilation-prompt-read-shell-command + "Function used by `compilation-read-command' to get user's input. +Defaults to `compilation-prompt-read-shell-command', +but `compilation-prompt-read-command-with-completion' can be used instead for +a completing version based on past runs." + :version "31.0" + :type 'function + :options '(compilation-prompt-read-command-with-completion)) + +(defun compilation-read-command (command) + "Prompt user for command to run. +`compilation-read-command-function' controls the way input is read from the minibuffer." + (funcall compilation-read-command-function command)) + ;;;###autoload (defun compile (command &optional comint) -- 2.47.1