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: [PATCH] RE: bug#33595: 26; Have `try-completion' or `completion--done' run abnormal hook if sole completion Date: Mon, 3 Dec 2018 10:52:55 -0800 (PST) Message-ID: <5de4751e-8389-4400-aafe-9225e9470f01@default> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="__154386317597254993abhmp0018.oracle.com" X-Trace: blaine.gmane.org 1543864059 27187 195.159.176.226 (3 Dec 2018 19:07:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 3 Dec 2018 19:07:39 +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 20:07:34 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 1gTtZ2-0006pR-Qc for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Dec 2018 20:07:29 +0100 Original-Received: from localhost ([::1]:51457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTtb9-0007U3-BC for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Dec 2018 14:09:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTtap-00064U-7m for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 14:09:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTtM1-0006tY-Qk for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 13:54:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gTtM1-0006tS-M4 for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 13:54:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gTtM1-0004Ws-JF for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 13:54:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Dec 2018 18:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33595 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33595-submit@debbugs.gnu.org id=B33595.154386318817348 (code B ref 33595); Mon, 03 Dec 2018 18:54:01 +0000 Original-Received: (at 33595) by debbugs.gnu.org; 3 Dec 2018 18:53:08 +0000 Original-Received: from localhost ([127.0.0.1]:59403 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtL8-0004Vh-BG for submit@debbugs.gnu.org; Mon, 03 Dec 2018 13:53:08 -0500 Original-Received: from userp2120.oracle.com ([156.151.31.85]:41030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtL5-0004VA-R3 for 33595@debbugs.gnu.org; Mon, 03 Dec 2018 13:53:04 -0500 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB3InFka021728 for <33595@debbugs.gnu.org>; Mon, 3 Dec 2018 18:52:57 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; s=corp-2018-07-02; bh=uOIxhbc/oQhoyqqww+W6Tn9bWA8tssOeuhyvdoehils=; b=HGlEgXrbbToZbtkbQhiBLeWbOfX3fpJuW+MHaXSDRZtXaiurT2ht/og+tTizU3PqEb6p RgSWAMXw+ZMJw1sySMvEbiVDZVvzJrakXwx3eRJ95necWD30u3rCkqYYE9+j6RAI1Upp vl1cCVWkAFzlhFqKetG3uSHvc/qpCjw2h+egSRpy7fWeiBRVYBsWhm3nzG9S780re/Up m2AWkm78VBV6dbKbFLKqxHn8xFtZxxjFw88oQicJ8RlrGwhIzocoolNk6fYKX3bYUurk 2cYQwAZcoh2WI2iTnVkBMLOkq/vl7JjsIE1pYGaJw7/WPiXt+ro3ZVMpj+i/SK5fAEYQ vg== Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2p3jxr849b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <33595@debbugs.gnu.org>; Mon, 03 Dec 2018 18:52:57 +0000 Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB3IquBa028521 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <33595@debbugs.gnu.org>; Mon, 3 Dec 2018 18:52:56 GMT Original-Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB3IqugN021691 for <33595@debbugs.gnu.org>; Mon, 3 Dec 2018 18:52:56 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=9096 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=13 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-1812030173 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:153026 Archived-At: --__154386317597254993abhmp0018.oracle.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable The attached patch implements this enhancement. Simple example use cases: (defun my-find-file-other-window (filename &optional wildcards) "`find-file-other-window', but show file info if only one completion matc= hes." (interactive (unwind-protect (progn (add-hook 'completion-sole-match-functions 'describe-file) (find-file-read-args "Find file in other window: " (confirm-nonexistent-file-or-buffer))) (remove-hook 'completion-sole-match-functions 'describe-file))) (find-file-other-window filename wildcards)) (defun my-describe-function (function) "`describe-function', but show output if only one completion matches." (interactive (unwind-protect (progn (add-hook 'completion-sole-match-functions (lambda (fn) (describe-function (intern fn)))) (let* ((fn (function-called-at-point)) (enable-recursive-minibuffers t) (val (completing-read (if fn (format "Describe function (default %s): " fn) "Describe function: ") #'help--symbol-completion-table (lambda (f) (or (fboundp f) (get f 'function-documentation))) t nil nil (and fn (symbol-name fn))))) (unless (equal val "") (setq fn (intern val))) (unless (and fn (symbolp fn)) (user-error "You didn't specify a function symbol")) (unless (or (fboundp fn) (get fn 'function-documentation)) (user-error "Symbol's function definition is void: %s" fn)) (list fn)))) (remove-hook 'completion-sole-match-functions (lambda (fn) (describe-function (intern fn))))) (describe-function function)) ---- Or, using macro `with-hook-added' (see bug #33601): (defun my-find-file-other-window (filename &optional wildcards) "`find-file-other-window', but show file info if only one completion matc= hes." (interactive (with-hook-added completion-sole-match-functions describe-file (find-file-read-args "Find file in other window: " (confirm-nonexistent-file-or-buffer)))) (find-file-other-window filename wildcards)) (defun my-describe-function (function) "`describe-function', but show output if only one completion matches." (interactive (with-hook-added completion-sole-match-functions (lambda (fn) (describe-function (intern fn))) (let* ((fn (function-called-at-point)) (enable-recursive-minibuffers t) (val (completing-read (if fn (format "Describe function (default %s): " fn) "Describe function: ") #'help--symbol-completion-table (lambda (f) (or (fboundp f) (get f 'function-documentation))) t nil nil (and fn (symbol-name fn))))) (unless (equal val "") (setq fn (intern val))) (unless (and fn (symbolp fn)) (user-error "You didn't specify a function symbol")) (unless (or (fboundp fn) (get fn 'function-documentation)) (user-error "Symbol's function definition is void: %s" fn)) (list fn)))) (describe-function function)) --__154386317597254993abhmp0018.oracle.com Content-Type: application/octet-stream; name="minibuffer-2018-12-03a.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="minibuffer-2018-12-03a.patch" ZGlmZiAtdSBtaW5pYnVmZmVyLmVsIG1pbmlidWZmZXItMjAxOC0xMi0wM2EtcGF0Y2hlZC5lbAot LS0gbWluaWJ1ZmZlci5lbAkyMDE4LTEyLTAzIDA5OjIzOjQ1Ljg1ODYwODIwMCAtMDgwMAorKysg bWluaWJ1ZmZlci0yMDE4LTEyLTAzYS1wYXRjaGVkLmVsCTIwMTgtMTItMDMgMDk6Mjc6MTcuODYy Mzk3MzAwIC0wODAwCkBAIC03NTMsNiArNzUzLDEwIEBACiB0aGUgc2Vjb25kIGZhaWxlZCBhdHRl bXB0IHRvIGNvbXBsZXRlLiIKICAgOnR5cGUgJyhjaG9pY2UgKGNvbnN0IG5pbCkgKGNvbnN0IHQp IChjb25zdCBsYXp5KSkpCiAKKyhkZWZ2YXIgY29tcGxldGlvbi1zb2xlLW1hdGNoLWZ1bmN0aW9u cyAoKQorICAiRnVuY3Rpb25zIHRvIGJlIHJ1biB3aGVuIGNvbXBsZXRpb24gcmVzdWx0cyBpbiBv bmx5IG9uZSBtYXRjaC4KK0VhY2ggZnVuY3Rpb24gbXVzdCBhY2NlcHQgdGh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