Visuwesh wrote:
[வியாழன் டிசம்பர் 26, 2024] Spyros Roum wrote:

+(defcustom compilation-read-command-function
+  #'compilation-prompt-read-shell-command
+  "`compilation-read-command' uses this function to get user's input.
+Defaults to `compilation-prompt-read-shell-command',
+but 'compilation-prompt-read-with-history-completion' can be used instead for
+a completing version based on past runs."
+  :version "31.1"
+  :type 'function
+  :options
+  (list
+    #'compilation-prompt-read-shell-command
+    #'compilation-prompt-read-with-history-completion))
It would be nice to say what these options mean in plain English (with
:tag IIRC).
I like this suggestion, and it made me realize that even though I use
`:options`, there is no actual list of
options in the customization interface, which seems weird.

[...]
+(defcustom compilation-read-command-function
+  #'compilation-prompt-read-shell-command
+  "`compilation-read-command' uses this function to get user's input.
+Defaults to `compilation-prompt-read-shell-command',
+but `compilation-prompt-read-with-history-completion' can be used instead for
+a completing version based on past runs."
+  :version "31.1"
+  :type
+  '(choice
+    (function :tag
+      "Read command using read-shell-command"
+      compilation-prompt-read-shell-command)
+    (function :tag
+      "Read command using completing-read, completing on compile-history"
+      compilation-prompt-read-with-history-completion)))
I *think* this prevents adding a custom function from the Customise
interface since we don't have a "any function" choice, and would warn
when you say

    (setopt compilation-read-command-function #'any-other-function-other-than-two)

Unfortunately, I do know how to go about adding it myself since I am
unfamiliar with defcustoms.

I did some more research and I ended up with this, which seems to work great.

`:tag` is not used, but `function-item` displays the docstrings of the functions in the customize interface.
Additionally, the `(function :tag "Other")` entry adds a third entry that can be any other function the user wants.

Seems to play nicely with `setopt`, and the customize interface. After reading some docs
on defcustom and what :type can be, it seems to me like this is the more "correct" version so far.

Worth noting that the earlier revision that used `:options` was normal to not work,
as `:options` does not support `:type function`.