From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#33595: 26; Have `try-completion' or `completion--done' run abnormal hook if sole completion Date: Sun, 2 Dec 2018 20:07:07 -0800 (PST) Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1543809969 11597 195.159.176.226 (3 Dec 2018 04:06:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 3 Dec 2018 04:06:09 +0000 (UTC) To: 33595@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 03 05:06:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTfUi-0002rs-NX for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Dec 2018 05:06:05 +0100 Original-Received: from localhost ([::1]:46710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTfWo-0001oM-Tk for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Dec 2018 23:08:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTfWf-0001o2-Mz for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2018 23:08:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTfWc-00084j-KT for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2018 23:08:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54330) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gTfWc-00084G-Gn for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2018 23:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gTfWc-0001Jl-9m for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2018 23:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Dec 2018 04:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33595 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15438100505018 (code B ref -1); Mon, 03 Dec 2018 04:08:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Dec 2018 04:07:30 +0000 Original-Received: from localhost ([127.0.0.1]:58588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTfW5-0001Ir-NB for submit@debbugs.gnu.org; Sun, 02 Dec 2018 23:07:30 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54881) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTfW4-0001Ib-EL for submit@debbugs.gnu.org; Sun, 02 Dec 2018 23:07:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTfVx-0007eu-C6 for submit@debbugs.gnu.org; Sun, 02 Dec 2018 23:07:23 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:56630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gTfVw-0007eG-BL for submit@debbugs.gnu.org; Sun, 02 Dec 2018 23:07:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTfVv-0001cK-C2 for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2018 23:07:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTfVr-0007aq-KL for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2018 23:07:19 -0500 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:56040) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gTfVp-0007Yy-4l for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2018 23:07:13 -0500 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB3442OF089347 for ; Mon, 3 Dec 2018 04:07:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=pVTs3XG1JZIG5lwwROMttME5/2W2TNMwOQywvl/2tKQ=; b=kCUCy3QaRQn/w87LkNiyFYQBpmA3Z49fXyZm/u9xDs4+s82OtFFNqB1aOE5FxSpN+4Iz NpEjMC1ZDQ5LMWMXWHESqMAIGufBTJTqwtRq00zoIwDoYYUlITL3yblcWsIYbXfsf+tC KX8PQKwkSEcJTOifq3Z2pZtMnADozj0D24iguZO/w1zXLdsQzPA4uCkE1HC4UK7bSmAo p+8MfO2dU0goQZXXsN1+0xEaqZCxZ+1ubrgCs5HSwSHvtpt7RYMUzmCI/wWYBiinkuth +m32OHJqFfxmC0/q9KNyyF8xE5PSI3LDpp1AXS3Eiz1iIojzi0O2uHiD7ftKR959ExMY Zw== Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2p3j8q3y92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 03 Dec 2018 04:07:10 +0000 Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB3479nb026483 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 3 Dec 2018 04:07:09 GMT Original-Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB3478B3026165 for ; Mon, 3 Dec 2018 04:07:08 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9095 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812030039 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:153015 Archived-At: Enhancement request: When `try-completion' returns `t' there is a "unique match which is exact". Please add an abnormal hook at this point, which accepts that sole completion as argument. This feature would make it easier for callers of `completing-read', `read-file-name', etc. to do something at that point with that sole match, while the user can still change her minibuffer input. For example, the caller could display additional information about that sole match. This could alternatively be done in `completion--done', before it calls `exit-fun', but it would also need to be done in the case where there is no exit function. `try-completion' is the logical place to do this, I think, but it is coded in C. I'm not sure which Lisp place would be best as an alternative, if it's not `completion--done'. A hook is handier for this than, say, defining an exit function that tests for `finished' and binding `completion-extra-properties' to a list that contains `:exit-function' with that function as value. A hook lets you add any number of such "sole completion" functions, and their use is not tied to just one call of a completion function. Here's a quick implementation using `completion--done'. It may be all that's required - not sure about the use of `unknown' as `completion--done' arg FINISHED. It just adds these two lines: (when (eq finished 'finished) (run-hook-with-args 'completion-sole-match-functions string)) (defun completion--done (string &optional finished message) (let* ((exit-fun (plist-get completion-extra-properties :exit-function)) (pre-msg (and exit-fun (current-message)))) (cl-assert (memq finished '(exact sole finished unknown))) (when (eq finished 'finished) (run-hook-with-args 'completion-sole-match-functions string)) (when exit-fun (when (eq finished 'unknown) (setq finished (if (eq (try-completion string minibuffer-completion-table minibuffer-completion-predicate) t) 'finished 'exact))) (funcall exit-fun string finished)) (when (and message ;; Don't output any message if the exit-fun already did so. (equal pre-msg (and exit-fun (current-message)))) (completion--message message)))) (defvar completion-sole-match-functions () "Functions to be run when completion results in only one match. Each function must accept that completion as its first arg.") In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30 Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea Windowing system distributor `Microsoft Corp.', version 10.0.16299 Configured using: `configure --without-dbus --host=3Dx86_64-w64-mingw32 --without-compress-install 'CFLAGS=3D-O2 -static -g3''