From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Andr=C3=A9_A=2E_Gomes?= Newsgroups: gmane.emacs.devel Subject: Re: History completion Date: Wed, 08 Dec 2021 20:02:04 +0000 Message-ID: <87bl1qq30j.fsf@gmail.com> References: <86mtlbvuq2.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10211"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 08 21:03:22 2021 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 1mv39u-0002WC-7M for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Dec 2021 21:03:22 +0100 Original-Received: from localhost ([::1]:45140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mv39t-0003y6-BD for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Dec 2021 15:03:21 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mv38l-0002Rv-Oy for emacs-devel@gnu.org; Wed, 08 Dec 2021 15:02:11 -0500 Original-Received: from [2a00:1450:4864:20::42b] (port=38644 helo=mail-wr1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mv38j-0000gC-PC for emacs-devel@gnu.org; Wed, 08 Dec 2021 15:02:11 -0500 Original-Received: by mail-wr1-x42b.google.com with SMTP id q3so6031150wru.5 for ; Wed, 08 Dec 2021 12:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=E0XendhrmBhhmptTRoD1PHvXGAuweVHxYCuZ/SR2GJs=; b=OFvgXokfJhkorEcWAvOlvgjmff9LKlHSPnGycc7ow0zFBHogIgm95PDDFV9+p7J++/ CN47XKn9zmNF9dWhQOxLwUOqfzQYXHjWgymaWs4TOPalJjOFSpCq230uc+SLUWID+wc5 odWCxx6hM1DGbU9/KIypG5/hJPGtaNU/FNFZ4tGrvLaePt1I7l89h4pfary1IJPMiNb7 2BYBtvTvei4z0N36Jhm5u336UBK0RDPNq/ILdlEKPTo5FAO8d6vHbGADbeOsgX6nWhhm YRKu9y1XDsH/SMRwvhlABMOkLgy7z6tbMRX571GzhYRQAmaJ75MS6rvdB397/soAAzu3 +eDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=E0XendhrmBhhmptTRoD1PHvXGAuweVHxYCuZ/SR2GJs=; b=jAUb75SPSr25PGg1kuwrrsP5uuRpjQIz2kA7iwa/kXofyu2cThzH+IBxVa/aKzePSt BpV33o3809/YXaQTj7Kjb9F83RrLTBQn6hL3dWu81OA7HJoTbDvO0DvPfm45rOT8Rtps SkCkVBB5/EC3iADAzk9pOfzQP0EiG15fIkb5wL9AkjgueNcMARrkO0ZXkkYanEq4Y53F /y9y1BeJbXzhkMdABvFEdtQzvVIZq72MxPpCnowwxkMeXG/JGJrmosa2KLOwxXyBC1te iV/TJhDPauzLntPtZ0YFRRSw+N8qn911vpTO0GG9oAWhQ4+4NRGfedcAP/owudR92SLC L2Ow== X-Gm-Message-State: AOAM531DB66cykzi+xPwwmg4VemjKXo4kwsKDLoSVzFPFA+ry8pqxRSR RvbZnaD48rTu+FxRH7MpKotJz0eL6fo= X-Google-Smtp-Source: ABdhPJzWdJwydQIWikSElHFsWASM6qOrkwkZuakTQZRR82xGuJ8MfrN6VxX/E+edtH4RElL4+A7kgA== X-Received: by 2002:adf:d1e3:: with SMTP id g3mr969317wrd.3.1638993725962; Wed, 08 Dec 2021 12:02:05 -0800 (PST) Original-Received: from guix-xps13 ([2001:818:daa9:6700:462d:384e:6de8:4a1c]) by smtp.gmail.com with ESMTPSA id i17sm3594925wmq.48.2021.12.08.12.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 12:02:05 -0800 (PST) In-Reply-To: <86mtlbvuq2.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 08 Dec 2021 20:54:40 +0200") X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=andremegafone@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" Xref: news.gmane.io gmane.emacs.devel:281387 Archived-At: Juri Linkov writes: > Wouldn't it be nice to allow completion on previous input > in the minibuffer. > > There are two unbound commands =E2=80=98previous-complete-history-element= =E2=80=99 and > =E2=80=98next-complete-history-element=E2=80=99 but their completion is l= imited > only to the beginnings of history items. > > So tried to set the minibuffer completion table to the history list: > > #+begin_src emacs-lisp > (defun minibuffer-setup-history-completions () > (unless (or minibuffer-completion-table minibuffer-completion-predicate) > (setq-local minibuffer-completion-table (symbol-value minibuffer-hist= ory-variable)))) > (add-hook 'minibuffer-setup-hook 'minibuffer-setup-history-completions) > #+end_src This is extremely valuable!!! I have thought about it myself in the past. My inspiration, perhaps yours too, came from `comint-previous-matching-input-from-input' and friends. > It works nicely with =E2=80=98icomplete-mode=E2=80=99 and =E2=80=98fido-v= ertical-mode=E2=80=99 > by automatically displaying completions from the history > depending on input in the minibuffer. But this also has drawbacks: > while typing a completely new command that doesn't exist in the history, > it permanently says at the end of the minibuffer: [No matches] > > So instead of this, tried to show history completions only after > typing a special key. TAB can't be reused because in some minibuffers > such as =E2=80=98M-!=E2=80=99 (shell-command), TAB completes the command/= file names. > > There is =E2=80=98C-tab=E2=80=99 bound to file-cache-minibuffer-complete. > When file-cache is not used, then =E2=80=98C-tab=E2=80=99 could be rebound > to a command that completes on the minibuffer history: > > #+begin_src emacs-lisp > ;; Adapted from =E2=80=98minibuffer-complete=E2=80=99: > (defun minibuffer-complete-history () > (interactive) > (completion-in-region (minibuffer--completion-prompt-end) (point-max) > (symbol-value minibuffer-history-variable) > nil)) > (define-key minibuffer-local-map [C-tab] 'minibuffer-complete-history) > #+end_src Hopefully I was able to follow you thoroughly. I think that such a completion should always be triggered by the user, and not automatically. To cycle the history ring with a given prefix string, I suggest C-n/p. The minibuffer is always a single line after all, or am I missing something? M-n/p can't be taken, and the same applies to C-M-n/p. Another suggestion would be to follow comint mode's bindings: C-c M-r/s. But, unlike comint's case, C-c M-p/n aren't being used so it's also an option. -- Andr=C3=A9 A. Gomes "Free Thought, Free World"