From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler Newsgroups: gmane.emacs.bugs Subject: bug#56613: 29; minibuffer-complete-history throws an error for minibuffer-history-variable=t Date: Mon, 18 Jul 2022 09:41:09 +0200 Message-ID: <1a0674ad-8201-e707-5992-ddfaca9ab558@daniel-mendler.de> References: <86bktna9zo.fsf@mail.linkov.net> <86wncayjaw.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21720"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , 56613@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 18 09:42:22 2022 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 1oDLOX-0005Q8-B6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Jul 2022 09:42:21 +0200 Original-Received: from localhost ([::1]:40110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDLOW-0007mY-AJ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Jul 2022 03:42:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDLOJ-0007mO-Ii for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2022 03:42:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDLOE-0000wx-07 for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2022 03:42:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oDLOD-0002JV-SM for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2022 03:42:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Jul 2022 07:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56613 X-GNU-PR-Package: emacs Original-Received: via spool by 56613-submit@debbugs.gnu.org id=B56613.16581300838844 (code B ref 56613); Mon, 18 Jul 2022 07:42:01 +0000 Original-Received: (at 56613) by debbugs.gnu.org; 18 Jul 2022 07:41:23 +0000 Original-Received: from localhost ([127.0.0.1]:49116 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDLNa-0002Ia-Io for submit@debbugs.gnu.org; Mon, 18 Jul 2022 03:41:22 -0400 Original-Received: from server.qxqx.de ([178.63.65.180]:38531 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDLNX-0002IM-29 for 56613@debbugs.gnu.org; Mon, 18 Jul 2022 03:41:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pvlxGZp+OiamGvzxWQUG/TgURsyt/gyZgBhulBWbzPQ=; b=El5N6Ke63yEH0sxD5Ee4Ubftq/ DBOfsnC3lkMR9imAVsu9vrpMfcJnoEZ9DcHlSeNXr0L1OpHkNDE5j7zlphRwGy+bnjA1aWHK3IKJ2 mHWlASrqLeSSCFWGIv5S5N5AHHa56Fsn+MEJ10/kpPpUt1oZ2gyox9EVm6td1shNov2g=; Content-Language: en-US In-Reply-To: <86wncayjaw.fsf@mail.linkov.net> 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" Xref: news.gmane.io gmane.emacs.bugs:237332 Archived-At: On 7/18/22 09:24, Juri Linkov wrote: >> In order to disable sorting from the side of the completion table, it is >> better to use the completion metadata. This way the sort function will >> also be picked up by all the alternative completion UIs. >> >> (completion-in-region >> (minibuffer--completion-prompt-end) (point-max) >> (lambda (str pred action) >> (if (eq action 'metadata) >> '(metadata (display-sort-function . identity) >> (cycle-sort-function . identity)) >> (complete-with-action action completions str pred)))) > > Thanks for the suggestion, now fixed as well. Thanks! Since you added this function twice (for history and defaults completion) you could also introduce a helper function. I use such helpers in my projects. Maybe such a function would be useful at other places in the Emacs code base? I haven't grepped but I think this pattern appears often. (defun completion-table-presorted (table &rest metadata) "Disable sorting in the completion UI for TABLE which is already sorted." (lambda (string pred action) (if (eq action 'metadata) `(metadata (display-sort-function . identity) (cycle-sort-function . identity) ,@metadata) (complete-with-action action table string pred)))) Or maybe the more general function would be useful too? (defun completion-table-with-metadata (table &rest metadata) "Return completion TABLE with METADATA." (lambda (string pred action) (if (eq action 'metadata) `(metadata ,@metadata) (complete-with-action action table string pred)))) > Stefan added this comment in minibuffer-complete-history: > > ;; FIXME: Can we make it work for CRM? > > But I can't find a function that would return the > current completion boundaries to use instead of hard-coding > minibuffer--completion-prompt-end and point-max. Then > completing-read-multiple should set locally such a function > that will use crm-separator and return a cons (BEG . END). Doesn't it work if you retrieve the boundaries first with `completion-boundaries` from `minibuffer-completion-table`? In my Vertico package I use the following code and it works without issues with CRM. The API requires a little bit of a ceremony. (let* ((content (minibuffer-contents-no-properties)) (pt (max 0 (- (point) (minibuffer-prompt-end)))) (before (substring content 0 pt)) (after (substring content pt)) (bounds (completion-boundaries before minibuffer-completion-table minibuffer-completion-predicate after))) ...) Daniel