From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: `isearch-complete1' should use `completion-at-point' or `completion-in-region' Date: Wed, 15 Jan 2020 08:57:54 -0500 Message-ID: References: <7da1738e-1e8a-3c12-31bf-741ee171db5c@Alexander.Shukaev.name> <8736ckl015.fsf@mail.linkov.net> <87pnfl1wj9.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao:159.69.161.202"; logging-data="121227"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Alexander Shukaev , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 15 16:07:41 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1irjC2-0003va-Uq for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Jan 2020 14:58:46 +0100 Original-Received: from localhost ([::1]:54504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irjC2-00021M-12 for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Jan 2020 08:58:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33986) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irjBS-0001BG-QC for emacs-devel@gnu.org; Wed, 15 Jan 2020 08:58:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irjBO-0002T6-Jf for emacs-devel@gnu.org; Wed, 15 Jan 2020 08:58:10 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:13926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irjBO-0002SW-CC for emacs-devel@gnu.org; Wed, 15 Jan 2020 08:58:06 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 35D1782C32; Wed, 15 Jan 2020 08:58:05 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 99D9380B69; Wed, 15 Jan 2020 08:58:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1579096683; bh=y/0Z6YImUBrVN3xzv5yn/lUFucIkxn1GpIYf+KhV+54=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Wk9XGqMMtsviFM4OiAsv1FRoIrV8/FUxG5C2tYJqHVsK0Nh5QwpuztmvPuzK+4UHe CqNa8yejvK7S/WjwiSGLzN6ea5FkNHaxcyRgC6CBLH4aId/nfcs1k/I04kwVfzIZyV g8G5kMuIcAQS5FhVTe3YBuc7O3p2SklzjwzYCFOlPjq+K3qvbSFHZnPwxZnwJPVizc gHhGM+5YA5j2S5uI+pG6eztwy22H64BN2bSIJZWFbuJKVqTCaXGSvzQXfcVsjCXkzI 9PO5r5Eqsn+axdgqFfc0fWxqux8t3hUeZCoWwPAoCoguI7vOGkelWO8oybxidRRlLq 6JmoJXxpjZqzQ== Original-Received: from pastel (unknown [45.72.156.100]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4989E1208B1; Wed, 15 Jan 2020 08:58:03 -0500 (EST) In-Reply-To: <87pnfl1wj9.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 15 Jan 2020 01:51:54 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:244272 Archived-At: > Maybe something like this: > > (defun isearch-completion-at-point-function () > (list (minibuffer-prompt-end) (point-max) > (if isearch-regexp regexp-search-ring search-ring))) Looks fine, yes. > (defun isearch-completion-at-point () > (interactive) > (let* ((completion-ignore-case case-fold-search) > (completion-at-point-functions '(isearch-completion-at-point-function))) > (completion-at-point))) Ah, no I was thinking rather of something like (minibuffer-with-setup-hook (lambda () (setq-local completion-ignore-case case-fold-search) (add-hook 'completion-at-point-functions #'isearch-completion-at-point-function nil t)) ...) This way, things like `company-mode` can use it (tho IIUC company-mode currently doesn't work in the minibuffer) and `isearch-complete-edit` can be an obsolete alias of `completion-at-point`. >> For `isearch-complete`, it's a bit more tricky because it's a form of >> completion that is performed on a text that's kept inside a string >> rather than inside a buffer, so I think we'll still need some ad-hoc >> code, but it could better use our completion framework. > `isearch-complete` already activates the minibuffer conditionally > when there are completions. It could activate the minibuffer always, > then immediately exit the minibuffer when completion-at-point > finds no completions. Yes. What I meant is that `isearch-complete` can't be turned into a mere obsolete alias of `completion-at-point`. FWIW, I think it might be worthwhile trying to rewrite isearch such that it always uses the minibuffer (instead of using a transient keymap and displaying the search string in the echo area). Then `isearch-edit` would simply change the minibuffer's keymap such that we only exit the minibuffer in the "usual" way. In such a setting `isearch-complete` could be a simple alias of `completion-at-point`. Stefan