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 14:46:03 +0000 Message-ID: <0a433f95-62cb-4941-a1fb-0a5266a3c9b2@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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------tVX3dPP3FRr0fAbMDtx30xiz" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12765"; 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 15:46:55 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 1tQp8Z-0003Ae-B9 for ged-emacs-devel@m.gmane-mx.org; Thu, 26 Dec 2024 15:46:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQp7q-0005a7-Ts; Thu, 26 Dec 2024 09:46:10 -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 1tQp7m-0005ZW-Tx for emacs-devel@gnu.org; Thu, 26 Dec 2024 09:46:09 -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 1tQp7h-0003Ef-Cm for emacs-devel@gnu.org; Thu, 26 Dec 2024 09:46:06 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2C234240101 for ; Thu, 26 Dec 2024 15:45:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1735224355; bh=mx5Qk1tJNy8Ov7cxgA8IwHNaLSAzJ0sA9qSr5oH9CjY=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:Cc:From: From; b=GadNPOQjbXuFEonn86wQ7dkTbvA5aeqfY1BmtYPBwqXIPbQTJ2KNXfWyLrKVIpFGR 6A7FxGeN2EqX570jTZg+40x6uYBo0JmDD3WJxlrXdK+xMuehzdbc+F8PJL6PqiYl66 0GbBDFZykZhwkfGk4EKzvCxjde+S6L649znk9FTnRLJhvbwoGfSgvAGsHMCP1z/H2Z PAt107ooB3hrgfYzACtFBP9koxweWPZ7zc4D2hNlfYimAH7WX/F+OKua9EvPuRFyQI Bo2IEPzffdC5BNwHB3B4H7fdrpnNIE+D6iU3/fWKHKkT6wF/dCuNce70HlBgyaFKaj SL1doz2Aqe4Gw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YJrz512mxz9rxB; Thu, 26 Dec 2024 15:45:53 +0100 (CET) Content-Language: en-US, el, el-en In-Reply-To: <87ldw2d1m2.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:327150 Archived-At: This is a multi-part message in MIME format. --------------tVX3dPP3FRr0fAbMDtx30xiz Content-Type: multipart/alternative; boundary="------------VKM0r0zKBz1nkoqZhPLgJcJG" --------------VKM0r0zKBz1nkoqZhPLgJcJG Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Visuwesh wrote: > [வியாழன் டிசம்பர் 26, 2024] Spyros Roum wrote: > > I don't really have much to say about the change but: > >> [...] >> I based the entry on a similar entry from a few lines up: >> >>   > *** New user option 'completion-pcm-leading-wildcard'. >>   > This option configures how the partial-completion style does >> completion. >>   > It defaults to nil, which preserves the existing behavior. When it >> is set >>   > to t, the partial-completion style behaves more like the substring >>   > style, in that a string being completed can match against a candidate >>   > anywhere in the candidate string. >> >> If you think however that the options are not necessary, I can keep >> the first sentence only. >> >> Patch attached has the corrected `:version` and ChangeLog, no other >> changes (also rebased to master). >> From fa17714fcb12079bc37e5be54fe6b2a68bcd34ff 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 >> [...] >> diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el >> index 6784a12fd63..d0da96069af 100644 >> --- a/lisp/progmodes/compile.el >> +++ b/lisp/progmodes/compile.el >> @@ -1797,12 +1797,38 @@ 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-with-history-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 >> + "`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. This is what I ended up with after looking at other `defcustom`s. Itworks as expected, showing a values menu and using the `:tag`s for descriptions. However, I do not know what the technical differences are between this and the previous versions and if one is more correct than the other. I am inclined to keep this though since it provides the Values Menu, which is nice. --------------VKM0r0zKBz1nkoqZhPLgJcJG Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Visuwesh wrote:
[வியாழன் டிசம்பர் 26, 2024] Spyros Roum wrote:

I don't really have much to say about the change but:

[...]
I based the entry on a similar entry from a few lines up:

  > *** New user option 'completion-pcm-leading-wildcard'.
  > This option configures how the partial-completion style does
completion.
  > It defaults to nil, which preserves the existing behavior. When it
is set
  > to t, the partial-completion style behaves more like the substring
  > style, in that a string being completed can match against a candidate
  > anywhere in the candidate string.

If you think however that the options are not necessary, I can keep
the first sentence only.

Patch attached has the corrected `:version` and ChangeLog, no other
changes (also rebased to master).
>From fa17714fcb12079bc37e5be54fe6b2a68bcd34ff Mon Sep 17 00:00:00 2001
From: Spyros Roum <spyros.roum@posteo.net>
Date: Wed, 25 Dec 2024 17:32:31 +0200
Subject: [PATCH] Add option for making compilation-read-command use
 completing-read
[...]
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 6784a12fd63..d0da96069af 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1797,12 +1797,38 @@ 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-with-history-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
+  "`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.

This is what I ended up with after looking at other `defcustom`s.
It works as expected, showing a values menu and using the `:tag`s for descriptions.

However, I do not know what the technical differences are between this and the previous versions and if one is more correct than the other. I am inclined to keep this though since it provides the Values Menu, which is nice.

--------------VKM0r0zKBz1nkoqZhPLgJcJG-- --------------tVX3dPP3FRr0fAbMDtx30xiz 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 RnJvbSBmMjE0NWQ5YWNmMzZkM2M4YWIwYzM4YjhmYThlZWI3MmMxODA2Zjg1IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBTcHlyb3MgUm91bSA8c3B5cm9zLnJvdW1AcG9zdGVv Lm5ldD4KRGF0ZTogVGh1LCAyNiBEZWMgMjAyNCAxNjo0Mjo1NiArMDIwMApTdWJqZWN0OiBb UEFUQ0hdIEFkZCBvcHRpb24gZm9yIG1ha2luZyBjb21waWxhdGlvbi1yZWFkLWNvbW1hbmQg dXNlCiBjb21wbGV0aW5nLXJlYWQKCiogZXRjL05FV1M6IEFkZCB0byBORVdTCgoqIGxpc3Av cHJvZ21vZGVzL2NvbXBpbGUuZWwgKGNvbXBpbGF0aW9uLXJlYWQtY29tbWFuZCk6CkNhbGwg ZnVuY3Rpb24gYmFzZWQgb24gYGNvbXBpbGF0aW9uLXJlYWQtY29tbWFuZC1mdW5jdGlvbmAu Cihjb21waWxhdGlvbi1wcm9tcHQtcmVhZC1zaGVsbC1jb21tYW5kKTogVGhlIGV4aXN0aW5n CmZ1bmN0aW9uYWxpdHkgZnJvbSBjb21waWxhdGlvbi1yZWFkLWNvbW1hbmQgZXh0cmFjdGVk IHRvCmEgZnVuY3Rpb24uCihjb21waWxhdGlvbi1wcm9tcHQtcmVhZC13aXRoLWhpc3Rvcnkt Y29tcGxldGlvbik6IEEKZnVuY3Rpb24gdGhhdCB1c2VzIGNvbXBsZXRpbmctcmVhZCB0byBy ZWFkIHRoZSBjb21tYW5kLgooY29tcGlsYXRpb24tcmVhZC1jb21tYW5kLWZ1bmN0aW9uKTog VGhlIG5ldyBvcHRpb24gdGhhdApjb250cm9sbHMgd2hpY2ggZnVuY3Rpb24gaXM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mVhZCcgaXMgdXNl ZCBhbGxvd2luZyBhdXRvY29tcGxldGUgYmFzZWQgb24gcGFzdCBydW5zIG9mICdjb21waWxl Jy4KKwogKiogV2luZG93cwogCiArKysKZGlmZiAtLWdpdCBhL2xpc3AvcHJvZ21vZGVzL2Nv bXBpbGUuZWwgYi9saXNwL3Byb2dtb2Rlcy9jb21waWxlLmVsCmluZGV4IDY3ODRhMTJmZDYz Li43NjM4ZTViNGRmMSAxMDA2NDQKLS0tIGEvbGlzcC9wcm9nbW9kZXMvY29tcGlsZS5lbAor KysgYi9saXNwL3Byb2dtb2Rlcy9jb21waWxlLmVsCkBAIC0xNzk3LDEyICsxNzk3LDQxIEBA IGNvbXBpbGF0aW9uLW1vZGUtZm9udC1sb2NrLWtleXdvcmRzCiAgICAnKChjb21waWxhdGlv bi0tZW5zdXJlLXBhcnNlKSkKICAgIGNvbXBpbGF0aW9uLW1vZGUtZm9udC1sb2NrLWtleXdv cmRzKSkKIAotKGRlZnVuIGNvbXBpbGF0aW9uLXJlYWQtY29tbWFuZCAoY29tbWFuZCkKKyhk ZWZ1biBjb21waWxhdGlvbi1wcm9tcHQtcmVhZC1zaGVsbC1jb21tYW5kIChjb21tYW5kKQog ICAocmVhZC1zaGVsbC1jb21tYW5kICJDb21waWxlIGNvbW1hbmQ6ICIgY29tbWFuZAogICAg ICAgICAgICAgICAgICAgICAgIChpZiAoZXF1YWwgKGNhciBjb21waWxlLWhpc3RvcnkpIGNv bW1hbmQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICcoY29tcGlsZS1oaXN0b3J5IC4g MSkKICAgICAgICAgICAgICAgICAgICAgICAgICdjb21waWxlLWhpc3RvcnkpKSkKIAorKGRl ZnVuIGNvbXBpbGF0aW9uLXByb21wdC1yZWFkLXdpdGgtaGlzdG9yeS1jb21wbGV0aW9uIChj b21tYW5kKQorICAoY29tcGxldGluZy1yZWFkICJDb21waWxlIGNvbW1hbmQ6ICIgY29tcGls ZS1oaXN0b3J5CisgICAg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