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.devel Subject: Re: Comint-like history search for Eshell? Date: Mon, 04 Nov 2024 09:40:32 +0200 Organization: LINKOV.NET Message-ID: <875xp3mqdb.fsf@mail.linkov.net> References: <878qu01mfc.fsf@pengjiz.com> <4fca840c-f6f3-53af-a020-11427efc07e7@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16321"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: Pengji Zhang , emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 04 08:50:23 2024 Return-path: Envelope-to: ged-emacs-devel@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 1t7rqx-00049z-7w for ged-emacs-devel@m.gmane-mx.org; Mon, 04 Nov 2024 08:50:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7rpv-0003KA-03; Mon, 04 Nov 2024 02:49:19 -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 1t7rpj-0003JI-4E for emacs-devel@gnu.org; Mon, 04 Nov 2024 02:49:12 -0500 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t7rpg-0008Dr-AD for emacs-devel@gnu.org; Mon, 04 Nov 2024 02:49:06 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 619CD24000A; Mon, 4 Nov 2024 07:48:58 +0000 (UTC) In-Reply-To: <4fca840c-f6f3-53af-a020-11427efc07e7@gmail.com> (Jim Porter's message of "Sun, 3 Nov 2024 15:09:57 -0800") X-GND-Sasl: juri@linkov.net Received-SPF: pass client-ip=217.70.183.193; envelope-from=juri@linkov.net; helo=relay1-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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325080 Archived-At: > Just some general thoughts before I do a more-thorough review: as I see it, > there are two competing ideas for how a user might look up a prior command: > using Isearch (as in this patch) or using completion. Both have some > similarities, but the latter has the advantage of letting you use the > various completion frameworks for filtering/displaying the results. > > I don't know if one or the other is "better" overall; I imagine which one > a user would prefer just depends on individual preference. (That said, > I think I'd probably use a completion-based command history if I had the > option.) > > For this patch in particular, I think it would probably make sense to at > least see about leaving the door open for a completion-based history lookup > in Eshell. I haven't thought very hard about what that would look like yet > though... The standard features that correspond to these two ways are incremental search with 'C-s' (implemented in the proposed patch) and occur with 'M-s o' (there is no occur-like interface for Eshell history AFAIK, it exists only for the minibuffer history, and in shell with 'comint-dynamic-list-input-ring'). However, having a completion UI would be nice too. For example, for shell I use: ``` (defun comint-complete-input-ring () "Complete the input history as far as possible. Like `minibuffer-complete-history' but completes on the comint history items." (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"))) (capf (lambda () (list (save-excursion (move-beginning-of-line 1) (point)) (point-max) (lambda (string pred action) (if (eq action 'metadata) '(metadata (display-sort-function . identity) (cycle-sort-function . identity)) (complete-with-action action completions string pred)))))) (completion-at-point-functions (list capf))) (completion-at-point))) (define-key comint-mode-map [?\C-x up] 'comint-complete-input-ring) ``` So Eshell could have both as well: incremental search and completion.