From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron Newsgroups: gmane.emacs.devel Subject: Re: master 431f8ff1e38: * lisp/imenu.el: Support more values for imenu-flatten (bug#70846) Date: Sun, 14 Jul 2024 12:55:53 +0200 Message-ID: References: <171558357066.26019.9766615061719600757@vcs2.savannah.gnu.org> <20240513065931.0D83AC12C31@vcs2.savannah.gnu.org> <86v83hwxjs.fsf@mail.linkov.net> <86ikzhq6ja.fsf@mail.linkov.net> <86o798x5hz.fsf@gnu.org> <86bk572e6a.fsf@mail.linkov.net> <861q62pb8y.fsf@mail.linkov.net> <864jayjd8u.fsf@gnu.org> <86le49ymsl.fsf@mail.linkov.net> <86msoo4cf3.fsf@mail.linkov.net> <865xv9ugjx.fsf@mail.linkov.net> <867cffdsp8.fsf@mail.linkov.net> <86ttgs78eu.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30888"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier , Eli Zaretskii , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 14 12:56:56 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 1sSwuV-0007qo-8G for ged-emacs-devel@m.gmane-mx.org; Sun, 14 Jul 2024 12:56:55 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSwtd-0001wI-Ew; Sun, 14 Jul 2024 06:56:01 -0400 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 1sSwtb-0001w5-Aq for emacs-devel@gnu.org; Sun, 14 Jul 2024 06:55:59 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSwtZ-0005eG-O4; Sun, 14 Jul 2024 06:55:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1720954556; bh=y7Zcur7uwJnaPPAxL9EucfVhSaTbZhCVvGRCGe7KNZA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=t9F9FvoGmPIfsoA3fO2E11JUkfzRW3Ea0jvwW2GgfE4HyhF1UXOlAsV8JkO8lbFdK /DCPkKPNBBMkdo5WgQ+/pjxm1kZITBKWoF3Rz/bMvJ/OJbGAOMo11efno76jky26m7 wJPZ135OB9FVq0XlDRx5lXMXxBpBnDrbBe7K1ix8lc3+C5kxwdxbVo6o/D9RQwwv0u MkD6U3Cg0dljW6mYhJRUI8dtdNeP7oI9MG7BSrEdX24wprwjQyO48lWGerFkF2l8rq 0R1wr+JU9yatyecQ5H/9ZSN3Mhg+oht9klSLibGZG4uEpTu6e3/Z3Gdv0YxqjgTVah FHKx8UFqkHrmw== In-Reply-To: <86ttgs78eu.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 14 Jul 2024 09:53:05 +0300") Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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:321637 Archived-At: Juri Linkov writes: >> I'm afraid imenu-flatten=annotation has one more hurdle to overcome. >> Consider: >> >> 1. emacs -Q >> 2. (setq imenu-flatten 'annotation) >> 2. C-x C-f .../lisp/imenu.el >> 3. M-g i >> 4. M- M- M- M- ... >> 5. Now the selected candidate in *Completions* is e.g. imenu--cleanup, >> this is also the minibuffer contents, so far so good. >> 6. Type M-RET to jump to this candidate. >> 7. Land on imenu instead of imenu--cleanup. >> >> No matter how far down you go with M-, if you go through the entry >> for imenu, that's where you'll land when you hit M-RET. This is because >> imenu-flatten=annotation tries to identify candidates by their text >> properties, but completion--replace retains common parts while replacing >> minibuffer text, along with the text properties of these common parts. >> >> This affects imenu-flatten=group too. >> >> It might be possible to resolve this by setting a different >> completion-list-insert-choice-function that circumvents replaces the >> whole minibuffer contents, unlike completion--replace, which tries hard >> to preserve markers etc. > > Maybe then imenu--completion-buffer should try to get the text property > from the end of completion? Provided that completion--replace will keep > some properties at the end instead of using insert-and-inherit. I'm not sure, I think that might work in some cases, but since completion--replace also keeps the common suffix it may still suffer from the same issue when going from candidate "foo-baz" to "bar-baz". Then there's the problem of what happens when you simply type the candidate you want to jump to, without completion. For example M-g i imenu RET goes to the imenu function when imenu-flatten=nil, but if imenu-flatten=annotation then it goes to the defgroup. What I would suggest is to ensure completion candidates are unambiguous as strings rather than relying on text properties. Namely: - Restore imenu-flatten to a boolean option: either flat or nested. - If imenu-flatten is non-nil, prepend the full prefix to each candidate, like imenu-flatten=prefix does currently. This takes care of disambiguating the candidate strings. - If completions-group is also non-nil, then group candidates according to their prefix and trim the prefix in the group-function when transforming candidates for display. Best, Eshel