From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#74694: comint-complete-input-ring Date: Wed, 04 Dec 2024 20:46:40 +0200 Organization: LINKOV.NET Message-ID: <87cyi7i8vj.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18343"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) To: 74694@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 04 19:49:23 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 1tIuR9-0004bS-95 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Dec 2024 19:49:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIuQt-0006wv-PL; Wed, 04 Dec 2024 13:49:10 -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 1tIuQo-0006wU-CW for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2024 13:49: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 1tIuQo-0000Yz-3R for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2024 13:49: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:From:To:Subject; bh=lUVq3pNsiYmqAHuJ5oOeKMJ3ShfZUbGloWud5Nvjy7Y=; b=BBnhBnRrmMC2mF7Z5B49757Wn5sNE9Ha/WB+VDqKxeEGEMQWggztXAzSxPeiMmWcxSI97OOhdxivMLOp5U0aVftcaDiipkBTBXHF3z7g8pxxKoaxyjRObx7Gt9mGzC9SIQWaQWeJ0b+EwuvgTdmL4IvXWBXrSLmJ13XpnhHGzvLFLqeXGrli8fIHydxoUsONGS6H1tD9itULmI5jhuf/powqn7YxUV27GZbD0h194WyXO9YDGnAAgifh6NQVoC8BY7M/BzWnB2Iwj0o1fjUxo6gcxR2OUD7rVDDCCPXskGUuadbjFWdXXKcBy0VRZypO79Ae2HsJvWAQWAp426z46g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tIuQn-0000uI-Tq for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2024 13:49:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Dec 2024 18:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74694 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17333380943389 (code B ref -1); Wed, 04 Dec 2024 18:49:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Dec 2024 18:48:14 +0000 Original-Received: from localhost ([127.0.0.1]:36824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIuQ2-0000sb-E7 for submit@debbugs.gnu.org; Wed, 04 Dec 2024 13:48:14 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:60294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIuQ0-0000sQ-FT for submit@debbugs.gnu.org; Wed, 04 Dec 2024 13:48:12 -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 1tIuPy-0006nk-0v for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2024 13:48:10 -0500 Original-Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIuPv-0000Jn-Kd for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2024 13:48:09 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 9FE601C0002 for ; Wed, 4 Dec 2024 18:48:03 +0000 (UTC) X-GND-Sasl: juri@linkov.net Received-SPF: pass client-ip=2001:4b98:dc4:8::225; envelope-from=juri@linkov.net; helo=relay5-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:296425 Archived-At: --=-=-= Content-Type: text/plain Like discussed in https://mail.gnu.org/archive/html/emacs-devel/2024-11/msg00094.html here is the patch that implements completion on comint history: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=comint-complete-input-ring.patch diff --git a/lisp/comint.el b/lisp/comint.el index 6423e695430..9b8ea6869c2 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -543,6 +543,7 @@ comint-mode-map (define-key map "\er" 'comint-history-isearch-backward-regexp) (define-key map [?\C-c ?\M-r] 'comint-previous-matching-input-from-input) (define-key map [?\C-c ?\M-s] 'comint-next-matching-input-from-input) + (define-key map [?\C-x up] 'comint-complete-input-ring) (define-key map "\e\C-l" 'comint-show-output) (define-key map "\C-m" 'comint-send-input) (define-key map "\C-d" 'comint-delchar-or-maybe-eof) @@ -1180,6 +1181,26 @@ comint-dynamic-list-input-ring (set-window-configuration conf) (push ch unread-command-events)))))) +(defun comint-complete-input-ring () + "Complete a list of recent inputs entered into the current buffer. +Like `minibuffer-complete-defaults' but completes on comint inputs. +This function makes `comint-dynamic-list-input-ring' obsolete." + (interactive) + (let ((completions + (if (and (ring-p comint-input-ring) + (not (ring-empty-p comint-input-ring))) + (ring-elements comint-input-ring) + (user-error "No history available"))) + (completion-in-region-mode-predicate + (lambda () (get-buffer-window "*Completions*" 0)))) + (completion-in-region + (comint-line-beginning-position) (point-max) + (lambda (string pred action) + (if (eq action 'metadata) + '(metadata (category . comint-input) + (display-sort-function . identity) + (cycle-sort-function . identity)) + (complete-with-action action completions string pred)))))) (defun comint-regexp-arg (prompt) "Return list of regexp and prefix arg using PROMPT." --=-=-=--