From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Completion preview common Date: Mon, 08 Apr 2024 01:39:01 +0200 Message-ID: <75CFBF4C-EA88-4985-A967-BCC896A60EDE@aol.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18480"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org, Eshel Yaron Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Apr 08 01:40:19 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 1rtc7X-0004aP-78 for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Apr 2024 01:40:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtc6d-0006b3-PC; Sun, 07 Apr 2024 19:39:23 -0400 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 1rtc6a-0006am-Ej for emacs-devel@gnu.org; Sun, 07 Apr 2024 19:39:20 -0400 Original-Received: from sonic317-27.consmr.mail.bf2.yahoo.com ([74.6.129.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rtc6Y-00086j-8M for emacs-devel@gnu.org; Sun, 07 Apr 2024 19:39:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1712533154; bh=wzgZf8D3Ig3ht4xbWwNGxmiOOKMKvmEbC4mjtijs4n8=; h=Date:From:To:Subject:In-Reply-To:References:From:Subject:Reply-To; b=PbNX9Yo92IJDPhqA6CJLcRbR8qhKGml7z+yjx1pH6zLZnPH/PnzsK3hxPyAcT+TZJRoAw7Z5kdfh8m0gsAU9LH0rIqkqnmXuaBbroGhDxSfSHV5osuTJPvfrS6xmFymYkkK4P9QD/Mz9GO1Mg44T5rSunbRpJz6VpuTcOnBW8H5fEiyMXc9XwHs/9sH85y0dzGhJXA1jPAq25hN/FZGW7rCtcJwpQVRV4bqN8A1wH/7/9OHW2PUaJCxu3PdQANUUBHBdAS0ErATAbXdWhPDa4nr9DRXR3pIDMFXjQmu5tMEk5YxBM0RN+x8wuYG863QB2fJLrjQKIkcUdjkmy8EoUg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1712533154; bh=BHd5PsIKvQu6FdiW5FaHEzzKgcVc0jTQYotqQRVbwL/=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=Ti0lAtDdHjZP8vaA+JSEtbZ6CYgNSUKqUh/XSjt1lzZ4wg/cUXrCOJz67yF3DVXVV7M6bXCFa7cqbZ+Lw9uPtiudJMpsD8fDNYYBQ31U/kOwpJC10nUzicwxrZaOfwkUi1tsxOjE6x4UyPGnHvJw3UZnoekv7PXmaAgeB5+mbXA1bQIalg1bejJvDGL9A7U+RzOiNYbO/6C2pozHTa+HjgYFPDwKUcUXQ3SDVaT9tiwhc2h3h3ozVLCZTQixr7i5JFpqRu7LKtl1Q3AEeP/wtCM7GsXV6ebYDWzyXWhakD16cDkbalXq9H9AOb+FEfuYgGL1O8jIma8CICNO0+ijrQ== X-YMail-OSG: 8vDR2iwVM1l5nmAPupf2sNURAamEVMyrAFs7xj0__GM8MHN3rEDXuaNIUn3mm_e fr4HfYE2E9zauUyNe_HYxVaLEqi.DJ2bdzq95C2yM3w0fXhlS7ES.Xzr.7_8gBN1CFuL6bIlEDZD uTjxOPNFOwrOvUt3VaHBBVQpCiiPRQQo6s1JEGVOn9N_YflX2_7QbPlKiAzi1c1yvvGEb_ToG3N1 El.8unmaKzs1sw4dSAp1Yu5prJGUzojINQwwkqtBiBBMJEllcGDuM_xdhFyC8EZyjih0qL__x6Y5 CRIQlBmCnk8jC.iBuUTO4I3Z908aHLyp9jQ4hVyx5AkVjUa3R6SHmZ4JFe.ek4K2AjiOzdcEm.fC aE8tZATEnXh_R0IA8O9SeHX7NuOIWrU5dQzi_oYqYUg.DEq0Pxt8pOL4W9o3LVKhioWL0efDbVc7 MqmsGGGg00Zf8.vad4WALpyYQIC0BRrgiubFCcn.2DT1cPAFyCvDzyHOCac7c4_PF_sXwYkVWAtQ U0QyGhaSh8D9nDIPJybcaONxxVSXf1YHLk2VPTC935KM5MciL8Hy4zlBWjqYOdYrxli7uASTC2OJ vkvQNwGD9uWGFLmlsVjwF3tTxZU9CHUA6FCMsUjtlMXBmeId7x3lqcHsw7FtiYKei0vN3N5UO3tz 4c_B4m9QR06CP8m6_Ju4d8v_K2zmRgkiZdmOMLrQlN.0CsMYO9tQElGlc7CyPhouxSRrdrQOgxL5 pHjw2NGCR0828RjGHqkbUxhSsrcHI3AF4xAoaluYNsyeLKPHybO4R0K89rUH0nBgsrr1LgD1fABV L6RNgJbTkL0tCTqV4fapjRY49qBDvpeu8X.Zku64dY X-Sonic-MF: X-Sonic-ID: ae282bd1-dd5d-45a0-acdf-8463ba80f9b6 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.bf2.yahoo.com with HTTP; Sun, 7 Apr 2024 23:39:14 +0000 Original-Received: by hermes--production-ir2-7bc88bfc75-7f2jw (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 35c329cfd2b3dc995890a2907ae9fd50; Sun, 07 Apr 2024 23:39:10 +0000 (UTC) In-Reply-To: X-Mailer: WebService/1.1.22205 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.129.82; envelope-from=spacibba@aol.com; helo=sonic317-27.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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:317596 Archived-At: Hi: Your idea sounds very sensible=2E But I don't want to add unneeded complex= ity to the package=2E To get a complete candidates list I prefer to rely o= n other tools like company or Corfu=2E And getting the first entry in my us= e case is not very useful=2E Certainly we can add many other features, properties, bindings and colors,= but every feature implies complexity I'll like to avoid (specially in a co= mpletion feature code)=2E The current package is simple, with few bindings = and a predictable behavior=2E Please keep that=2E I added this change because it didn't imply more than 10 extra lines of ex= ecution code (ignoring comments); otherwise I would prefer to live with it = as is=2E I made some small changes a while ago in the mini buffer completion (the o= ptions completion first-tab and so on ) and tracking that prefix, insert on= e tab and then the other is a code that sounds simple BUT becomes terrible = to follow very easily=2E And C-M-i is something that I cannot remember in t= he moment I need it (indeed, for completion I don't find usefully anything = beyond tabs and arrows) Best, Ergus On April 7, 2024 11:12:18 PM GMT+02:00, Eshel Yaron = wrote: >Hi there, > >Ergus writes: > >> Recently I have been playing with the new completion-preview mode and >> I'm very happy to see something like this finally added to emacs with a >> simple and clean code=2E >> >> However, there is a missing detail that I find useful when typing: >> common preview completion=2E >> >> The goal is to preview a common prefix when available and longer than >> the prefix already inserted=2E This is a point in between 1) exact matc= h >> with one candidate only and 2) getting the first candidate in the whole >> list=2E >> >> I tried to avoid adding complexity to the code (because the thing I lik= e >> the most in the package is actually its simplicity and predictability); >> but the extra functionality I think worth the few new lines=2E >> >> I attach the patch for a first review=2E > >Thank you for your feedback and for the patch! Completing only up the >longest common prefix instead of inserting the full candidate sounds >like a useful option, but I'm not sure that we should also restrict the >completion preview to only showing that common prefix=2E How about if we >add a command that completes up to the longest common prefix, but still >show the full candidate in the preview as we do now? That way you can >choose on a case-by-case basis whether you want to complete all the way >or just up to the longest common prefix=2E > >To some degree, this is already possible: if your completion-styles are >set to prefix (e=2Eg=2E "basic") completion, then hitting C-M-i completes= to >the longest common prefix in many cases=2E But we can also add a >dedicated command to completion-preview-active-mode-map that would use >the completion data that's already stored in the preview to complete up >to the longest common prefix, so something like the following: > >--8<---------------cut here---------------start------------->8--- >(defun completion-preview-insert-common-prefix () > "Complete text at point to the common prefix of all completion candidat= es=2E" > (interactive) > (let* ((beg (completion-preview--get 'completion-preview-beg)) > (end (completion-preview--get 'completion-preview-end)) > (all (completion-preview--get 'completion-preview-cands)) > (com (substring (try-completion "" all) (- end beg)))) > (if (string-empty-p com) > (message "Next char not unique") > (goto-char end) > (insert com)))) >--8<---------------cut here---------------end--------------->8--- > >A further improvement can be to (optionally) underline the longest >common prefix in the completion preview while showing the full >candidate, similarly to how we currently underline sole candidates=2E >That way you can tell how far you'd get by completing to the longest >common prefix=2E WDYT? > --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E