From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#67275: [PATCH] ; Improve and add tests for Completion Preview mode Date: Sat, 25 Nov 2023 12:11:03 +0200 Message-ID: <83sf4ucfd4.fsf@gnu.org> References: <8334x2ko1y.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36597"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67275@debbugs.gnu.org To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 25 11:12:06 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1r6pdu-0009L5-F4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Nov 2023 11:12:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6pdn-0007HF-7Q; Sat, 25 Nov 2023 05:11:59 -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 1r6pdl-0007Gr-PA for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 05:11:57 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6pdl-00072l-HJ for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 05:11:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r6pdq-00050v-2h for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 05:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Nov 2023 10:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67275 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67275-submit@debbugs.gnu.org id=B67275.170090708119219 (code B ref 67275); Sat, 25 Nov 2023 10:12:02 +0000 Original-Received: (at 67275) by debbugs.gnu.org; 25 Nov 2023 10:11:21 +0000 Original-Received: from localhost ([127.0.0.1]:37888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6pdA-0004zt-IP for submit@debbugs.gnu.org; Sat, 25 Nov 2023 05:11:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6pd6-0004zc-UZ for 67275@debbugs.gnu.org; Sat, 25 Nov 2023 05:11:18 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6pcw-0006iv-BJ; Sat, 25 Nov 2023 05:11:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=rJVZygdwhnQyNh1z05td2ywpYKx8JUCEbcaLGLHC9nk=; b=lRwjZzxqAf/K 8ZEgvfb1j+rrCPzOvoqVjhFOcSN9QHklGrlWfjSQinyYJs6Azkm58rCUo9fzOf2EmCSlkjGCAw7SF b3QmSy7Hg68PxyKEN1FsPSzyMZuxdWzRTmQDl8ZdknWBfpEdZI3eA79OeFB42anHkfTaha0g9wUl2 7tOrk8nYRMI5RInUsd1ZKRTM7pF7Tkm3m6/FRvAWsG8e2GJ0UniQcOKmW6bZpKlohBXyx0rEW23S3 SOIvfLCvKRG6Z08Fu5mN5JDryN7z2mFP7rbuUej+gbC5ErWUvU9JDtUZstic+KXGtgP9FQgS7hJPd yA+Xj2accXO91/WjKA4Nwg==; In-Reply-To: (message from Eshel Yaron on Sun, 19 Nov 2023 12:23:16 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274945 Archived-At: > From: Eshel Yaron > Cc: 67275@debbugs.gnu.org > Date: Sun, 19 Nov 2023 12:23:16 +0100 > > Eli Zaretskii writes: > > >> +When TABLE contains a matching completion, return a list > >> +\(PREVIEW BEG END ALL EXIT-FN) where PREVIEW is the text to show > >> +in the completion preview, ALL is the list of all matching > >> +completion candidates, and EXIT-FN is either a function to call > >> +after inserting PREVIEW or nil. When TABLE does not contain > >> +matching completions, or when there are multiple matching > >> +completions and `completion-preview-exact-match-only' is non-nil, > >> +return nil instead." > > > > It is better to use "if" here where you use "when". "When" can be > > interpreted as a time-related condition, which is not what you want > > here. > > Right, done in the updated patch (v2) below. > > >> +(defun completion-preview--capf-wrapper (capf) > >> + "Translate output of CAPF to properties for completion preview overlay. > >> + > >> +If CAPF returns a list (BEG END TABLE . PROPS), call > > > > If CAPF _returns_ something, it is probably a function. But then why > > does the first sentence say "output of CAPF"? functions in ELisp don't > > "output" stuff. > > Thanks, I've replaced "output" with "return value". > > >> +`completion-preview--try-table' to check TABLE for matching > >> +completion candidates. If `completion-preview--try-table' > >> +returns a non-nil value, return that value. Otherwise, return a > >> +list with nil car which means that completion failed, unless > >> +PROPS includes the property `:exclusive' with value `no', in > >> +which case this function returns nil which means to try other > >> +functions from `completion-at-point-functions'." > > > > This basically tells in words what the code does. But since the code > > is quite simple, I wonder why we need this in the doc string. The > > disadvantage of having this in the doc string is that we'd need to > > update it each time the code changes. > > > > Instead, think if something in what the code does needs to be > > explained _beyond_ what the code itself says, like if you need to > > explain the reasons why the code does what it does, or why you access > > this or that property, and explain that -- in comments, not in the doc > > string. The doc string should ideally be a higher-level description > > of the function's purpose and the meaning of its return values. > > Makes sense, thanks. I removed the lengthy description and added a > comment explaining the only non-obvious part. > > > Here's the updated patch: Thanks, now installed on master.