From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spyros Roum Newsgroups: gmane.emacs.devel Subject: Re: Add completion to compilation-read-command Date: Thu, 26 Dec 2024 16:00:37 +0000 Message-ID: <232066b2-e13c-4b5b-a38e-c3b4d5934d04@posteo.net> References: <87ttatb9g0.fsf@posteo.net> <87a5clm3p5.fsf@mail.linkov.net> <8734icaegs.fsf@posteo.net> <9a4bb215-561c-468f-97de-7d84fe7adc43@posteo.net> <87ttas80au.fsf@posteo.net> <962064f8-fab7-4867-af04-135e48a9dd15@posteo.net> <87ldw390ql.fsf@posteo.net> <4a27c5d7-b207-4bf1-a01b-552bf88a6347@posteo.net> <877c7m8ygh.fsf@posteo.net> <25958644-5b99-4611-b6ae-ce8448fb662f@posteo.net> <87ldw2d1m2.fsf@gmail.com> <0a433f95-62cb-4941-a1fb-0a5266a3c9b2@posteo.net> <87cyhecwp6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------ewPYnmkG2NeRLAma5g02ZUFm" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2082"; mail-complaints-to="usenet@ciao.gmane.io" Cc: philipk@posteo.net, juri@linkov.net, emacs-devel@gnu.org To: visuweshm@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 26 17:01:02 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tQqII-0000MD-AV for ged-emacs-devel@m.gmane-mx.org; Thu, 26 Dec 2024 17:01:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQqHv-0004bb-SP; Thu, 26 Dec 2024 11:00:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQqHt-0004b9-5e for emacs-devel@gnu.org; Thu, 26 Dec 2024 11:00:37 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQqHq-00032V-KU for emacs-devel@gnu.org; Thu, 26 Dec 2024 11:00:36 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id F153B240103 for ; Thu, 26 Dec 2024 17:00:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1735228827; bh=xwd8vt9UUitmXcAEWCiJ0gaYQKaakQ5SHmOa1u3jqNA=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:Cc:From: From; b=J7pYwV+H97Atp6weFuTRXM/oxe/jDTwZFT0CXVIj9Fkvzvgc1WiBuaNd8xMKemjMV 6QW0JNGiZJY4M+r21qgGVxhFJXc/nhlpeZ51a6+AZxugjDRrhbDwV6Sp1x5Kkx8wWP Ajsfji2mVsLSh2tjdvX9cJdaRauKbylja3LtwWw+N6Z9L2ByLlGkOc3Z3RYKRJK7jQ PCOrC+DY4ENYRk6G9f7vmFqaHcitwb8tAP8q1WKgVurlVFcoraitKybYhkI2v2RT0E qZs/Mq9uGTgB2cMD4HPSU2VDRq4O0+Ia1hZUHyglCsT102Ia1QhQCrDPjH+oJIWLjC 0Fz+l1190jeNg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YJtd70pPpz9rxF; Thu, 26 Dec 2024 17:00:27 +0100 (CET) Content-Language: en-US, el, el-en In-Reply-To: <87cyhecwp6.fsf@gmail.com> Received-SPF: pass client-ip=185.67.36.66; envelope-from=spyros.roum@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:327159 Archived-At: This is a multi-part message in MIME format. --------------ewPYnmkG2NeRLAma5g02ZUFm Content-Type: multipart/alternative; boundary="------------SfiYZkdJGoiQXHDbwiw5SfAi" --------------SfiYZkdJGoiQXHDbwiw5SfAi Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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`. --------------SfiYZkdJGoiQXHDbwiw5SfAi Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
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`.

--------------SfiYZkdJGoiQXHDbwiw5SfAi-- --------------ewPYnmkG2NeRLAma5g02ZUFm Content-Type: text/x-patch; charset=UTF-8; name="0001-Add-option-for-making-compilation-read-command-use-c.patch" Content-Disposition: attachment; filename*0="0001-Add-option-for-making-compilation-read-command-use-c.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSBhOTJjM2Q2OTE4MzZlYjc2MmY1NGFlYjkzY2RlYjNlMzA1YjA2MTg1IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBTcHlyb3MgUm91bSA8c3B5cm9zLnJvdW1AcG9zdGVv Lm5ldD4KRGF0ZTogVGh1LCAyNiBEZWMgMjAyNCAxNzo1Nzo1NCArMDIwMApTdWJqZWN0OiBb UEFUQ0hdIEFkZCBvcHRpb24gZm9yIG1ha2luZyBjb21waWxhdGlvbi1yZWFkLWNvbW1hbmQg dXNlCiBjb21wbGV0aW5nLXJlYWQKCiogZXRjL05FV1M6IEFkZCB0byBORVdTCgoqIGxpc3Av cHJvZ21vZGVzL2NvbXB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NvbXBpbGF0aW9uLXJlYWQtY29tbWFuZCAoY29tbWFuZCkKKyhkZWZ1 biBjb21waWxhdGlvbi1wcm9tcHQtcmVhZC1zaGVsbC1jb21tYW5kIChjb21tYW5kKQorICAi UmVhZCBjb21tYW5kIHVzaW5nIHJlYWQtc2hlbGwtY29tbWFuZCIKICAgKHJlYWQtc2hlbGwt Y29tbWFuZCAiQ29tcGlsZSBjb21tYW5kOiAiIGNvbW1hbmQKICAgICAgICAgICAgICAgICAg ICAgICAoaWYgKGVxdWFsIChjYXIgY29tcGlsZS1oaXN0b3J5KSBjb21tYW5kKQogICAgICAg ICAgICAgICAgICAgICAgICAgICAnKGNvbXBpbGUtaGlzdG9yeSAuIDEpCiAgICAgICAgICAg ICAgICAgICAgICAgICAnY29tcGlsZS1oaXN0b3J5KSkpCiAKKyhkZWZ1biBjb21waWxhdGlv bi1wcm9tcHQtcmVhZC13aXRoLWhpc3RvcnktY29tcGxldGlvbiAoY29tbWFuZCkKKyAgIlJl YWQgY29tbWFuZCB1c2luZyBjb21wbGV0aW5nLXJlYWQsIGNvbXBsZXRpbmcgb24gY29tcGls ZS1oaXN0b3J5IgorICAoY29tcGxldGluZy1yZWFkICJDb21waWxlIGNvbW1hbmQ6ICIgY29t cGlsZS1oaXN0b3J5CisgICAgICAgICAgICAgICAgICAgbmlsIG5pbCBjb21tYW5kCisgICAg ICAgICAgICAgICAgICAgKGlmIChlcXVhbCAoY2FyIGNvbXBpbGUtaGlzdG9yeSkgY29tbWFu ZCkKKyAgICAgICAgICAgICAgICAgICAgICAgJyhjb21waWxlLWhpc3RvcnkgLiAxKQorICAg ICAgICAgICAgICAgICAgICAgJ2NvbXBpbGUtaGlzdG9yeSkpKQorCisoZGVmY3VzdG9tIGNv bXBpbGF0aW9uLXJlYWQtY29tbWFuZC1mdW5jdGlvbgorICAjJ2NvbXBpbGF0aW9uLXByb21w dC1yZWFkLXNoZWxsLWNvbW1hbmQKKyAgImBjb21waWxhdGlvbi1yZWFkLWNv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