From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74408: 30.0.92; FR: Add a function completion-list-candidate-at-point Date: Mon, 18 Nov 2024 18:25:31 -0500 Message-ID: References: <87y11hefdb.fsf@daniel-mendler.de> <87v7wle77p.fsf@daniel-mendler.de> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23805"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74408@debbugs.gnu.org To: Daniel Mendler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 19 00:26:20 2024 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 1tDB8N-000626-89 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Nov 2024 00:26:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDB89-0000iP-Ar; Mon, 18 Nov 2024 18:26:06 -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 1tDB86-0000i9-Bu for bug-gnu-emacs@gnu.org; Mon, 18 Nov 2024 18:26:02 -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 1tDB86-00079K-3O for bug-gnu-emacs@gnu.org; Mon, 18 Nov 2024 18:26:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=xKJL/A7Hvr2Dup+/3AX5IG8Q/ypZNZ0OdOuRT3/IhRg=; b=JZVcf05fNhvBlZzJUZK2LK3wsGWREW2o3h5NRdOlwWuCsQzOQx1rJd2irjiT1v4qt4Lp5PVqIC1f1bpF9yYzJB83xfOEudxEn3LioZrvI0F+LlRgr8GdJdyDa2Zx8sDXr3FxwEewarx25Hp8jnG7u7Vdz1hyny6Oi7q9UqiFNvIVH6XmM0ts8OC2VDEQ0SsManf2kfpWgQvl57x/FKZ0P6vGqGt0SIh30q/tkGICsdhhWrQUnSbWZK2rYIbzs6EjbCxgVqMfYI4D+tONNpXTW+RHw/o6ZwdJkdXYszB0V2CdHMkCPOS+m7DUupBRX1BBSnKiKD/SyQ8eHkqCPBeP8A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tDB85-0000gq-U4 for bug-gnu-emacs@gnu.org; Mon, 18 Nov 2024 18:26:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Nov 2024 23:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74408 X-GNU-PR-Package: emacs Original-Received: via spool by 74408-submit@debbugs.gnu.org id=B74408.17319723442625 (code B ref 74408); Mon, 18 Nov 2024 23:26:01 +0000 Original-Received: (at 74408) by debbugs.gnu.org; 18 Nov 2024 23:25:44 +0000 Original-Received: from localhost ([127.0.0.1]:39651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tDB7n-0000gH-KC for submit@debbugs.gnu.org; Mon, 18 Nov 2024 18:25:43 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tDB7k-0000g2-GD for 74408@debbugs.gnu.org; Mon, 18 Nov 2024 18:25:41 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id EED0480821; Mon, 18 Nov 2024 18:25:33 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731972333; bh=ZGGCFcOfJPkS+T09h9HGheCjh8pTR3P9t1wJjv9H0s4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=XX7tpSn3ZXSHRNng/L/ODU63fclrIyEDn0Fs3JpSMvEjBR7cA6tokAnHVAkivK+Ta S/qvJRF3ySZCYXItrTn9W2DkCcuettfixH0OXmDB7t8B1+i4fWG05CHTd9bPvhY+ZE +zmdU565OHZjbbcQdnIQqMRUFZoDVRrX9o2Pbt1m9xOXGOi7OzEU2lMIWUA9EqgDbL P8F2I4dKidsrKcA3YNN776zsV6nHjraG5MDxn6PBPlbxJtFSqrq0qJJ6BW7cJG8uMp g4/TwUtZgyln0unCP6AW4eW/OmvGzJRvGYmb9Sczt746hMzZPnZbAeRwUspQ7XEJ5J E1inuHg/op+tQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id F30E9803CA; Mon, 18 Nov 2024 18:25:32 -0500 (EST) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E05D31204C2; Mon, 18 Nov 2024 18:25:32 -0500 (EST) In-Reply-To: <87v7wle77p.fsf@daniel-mendler.de> (Daniel Mendler's message of "Mon, 18 Nov 2024 01:06:18 +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:295615 Archived-At: > Thanks. Patch attached. Thanks, Daniel. Minor comments below. > @@ -2628,8 +2628,10 @@ minibuffer-completion-help > (when-let* ((buffer (get-buffer "*Completions*")) > (window (get-buffer-window buffer 0))) > (with-current-buffer buffer > - (when-let* ((beg (completions--start-of-candidate-at (window-point window)))) > - (cons (get-text-property beg 'completion--string) (- (point) beg)))))) > + (when-let* ((cand (save-excursion > + (goto-char (window-point window)) > + (completion-list-candidate-at-point)))) > + (cons (car cand) (- (point) (cadr cand))))))) > ;; If the *Completions* buffer is shown in a new > ;; window, mark it as softly-dedicated, so bury-buffer in > ;; minibuffer-hide-completions will know whether to AFAICT, it's easy to make `completion-list-candidate-at-point` accept an optional position argument (which would default to point), which would be helpful in the two places where we use that function. WDYT? > +(defun completion-list-candidate-at-point () > + "Return candidate string at point and bounds in completions buffer." I suggest you use something like "(STRING BEG END)" to describe the format. Stefan