From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: Re: Recommendation for CAPF setup when you don't know completion string in advance Date: Tue, 11 May 2021 09:42:21 -0400 Message-ID: References: Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_0C6FD967-FD22-4BC7-A0D7-89352C36C018" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26656"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 11 15:52:35 2021 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 1lgSoM-0006no-Rx for ged-emacs-devel@m.gmane-mx.org; Tue, 11 May 2021 15:52:34 +0200 Original-Received: from localhost ([::1]:37420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgSoK-0008A1-U8 for ged-emacs-devel@m.gmane-mx.org; Tue, 11 May 2021 09:52:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgSeb-00085b-SO for emacs-devel@gnu.org; Tue, 11 May 2021 09:42:29 -0400 Original-Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:35773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lgSeX-0001Wh-3X for emacs-devel@gnu.org; Tue, 11 May 2021 09:42:29 -0400 Original-Received: by mail-qk1-x736.google.com with SMTP id x8so18714225qkl.2 for ; Tue, 11 May 2021 06:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=ogQb2e93bEwiZdPvJI0ZvscZGZVMslHHjBhxYmuUu6g=; b=o/jCGwCJLxc++5xaO1A5BGPqcF/xOHxqkPxHRCkiFtQqP9irh7hM8H3TxZMJAipiFj vH6JCGGRwyfM/cP3EQOwRDATM2uBFt3CnFh/Wirm3YAArDh3pC3ubjDWkpOq4HEcQLpn ai3EeSu/EOWr4gtSrdektzZj+t9d5nlTaPoIlbdUsle0bde9Hj+OzfJjvCiAZ3zt5rtR k69u0vF1qLzQcVpFWffeBYTkqvJwcXYycIFAStpWW5uV1nPqpokDsF5oQIHi6YmJ+r0c hSeqaOkJUOn7GR8fh/7WreXh9DGa8j6OC8vT67+Jq70GrfBIx2M8hWQ3spw1Wmnxsl/9 POdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=ogQb2e93bEwiZdPvJI0ZvscZGZVMslHHjBhxYmuUu6g=; b=MqBgnAqBpKKZIKNlN+9Sx54hwxqR3e+IaCyBHN3oHvA/QebLdaWJuDKHQx8VPTFywN ol13zHTQQ3e4ZojJKP0f67uQBlFBw8Oxw5dkHirbRmQO/mc9Bpr+oO4RJe6TcGsu+XDk ulXI9SOr/GklyAqmnROF4XQHJCLOJcdS/VsM0omtd8n5NoODbcaDQ4Ik8iLmPt9RVslL KycluoTSNVsyfCL6WRuidTh7IB0in9xmNV0+U3+L9pOwtPgPVP5a++7GiqK4LWWZi16t p0JLS1MClcMsVRH8YgIArTbkDHptiMx76xldaGwlQJ4i5qRgP+5vxxC4voB6+GCME0Pm ymXg== X-Gm-Message-State: AOAM533PKF/zz2jVsL5XJR9fNwPrvcEzZzLEeeYrneIPPQzOneiW+Xjk Owh3HTdELUfle1i637exCOk= X-Google-Smtp-Source: ABdhPJwB8RVI7RJ9+cIKh0jb1Hai13bS6Az/wY3+Aj1odKj7YldaksnqXvDKKhW9bTcuNMkWFMcWdw== X-Received: by 2002:a05:620a:240c:: with SMTP id d12mr8846150qkn.190.1620740543944; Tue, 11 May 2021 06:42:23 -0700 (PDT) Original-Received: from smtpclient.apple (cm-134-228-25-135.buckeyecom.net. [134.228.25.135]) by smtp.gmail.com with ESMTPSA id 189sm14392898qkh.99.2021.05.11.06.42.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 May 2021 06:42:23 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.80.0.2.43) Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=jdtsmith@gmail.com; helo=mail-qk1-x736.google.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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 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" Xref: news.gmane.io gmane.emacs.devel:269157 Archived-At: --Apple-Mail=_0C6FD967-FD22-4BC7-A0D7-89352C36C018 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >=20 > There's `completion-table-with-context`. > Note that it comes with the following: >=20 > ;; TODO: add `suffix' maybe? >=20 > so you probably won't be able to use it as-is and you'll need to write > your function instead. But hopefully it should be enough to get > you started.=20 Looking at `completion-table-with-context=E2=80=99, it seems just to = prepend the prefix after the completion happens, if a string is returned = from `complete-with-action'. I=E2=80=99m struggling then to understand = the point of completion-boundaries lookup at all. I presume the = boundaries returned by a table function are relative to the string = enclosed by then original START=E2=80=A6END range originally returned by = the CAPF. =20 To make this concrete, suppose you are completing this string: /path/to/some[Tab] and your CAPF indicates the range of the entire string, but then its = table function returns non-trivial boundaries: `(boundaries 9 . 0). In = this case, the `completion-file-name-table=E2=80=99 still also trims the = full path string to its non-directory end component (=E2=80=98some=E2=80=99= ) before passing on to `file-name-completion`. Then finally it prepends = the directory back on again. So what good did returning boundaries do = it, if it had to cut out the completion string of interest, find = completions for it, then glue the prefix back on anyway?= --Apple-Mail=_0C6FD967-FD22-4BC7-A0D7-89352C36C018 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

There's = `completion-table-with-context`.
Note that it comes with the following:

   ;; TODO: add = `suffix' maybe?

so you probably won't be able to use it as-is and you'll need = to write
your function = instead.  But hopefully it should be enough to get
you = started. 

Looking = at `completion-table-with-context=E2=80=99, it seems just to prepend the = prefix after the completion happens, if a string is returned from = `complete-with-action'.  I=E2=80=99m struggling then to understand = the point of completion-boundaries lookup at all.  I presume the = boundaries returned by a table function are relative to the string = enclosed by then original START=E2=80=A6END range originally returned by = the CAPF.  

To make this = concrete, suppose you are completing this string:

/path/to/some[Tab]

and your CAPF indicates the range of the = entire string, but then its table function returns non-trivial = boundaries: `(boundaries 9 . 0).  In this case, the = `completion-file-name-table=E2=80=99 still also = trims the full path string to its non-directory end component = (=E2=80=98some=E2=80=99) before passing on to `file-name-completion`. =  Then finally it prepends the directory back on again. So what good = did returning boundaries do it, if it had to cut out the completion = string of interest, find completions for it, then glue the prefix back = on anyway?= --Apple-Mail=_0C6FD967-FD22-4BC7-A0D7-89352C36C018--