From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: sbaugh@catern.com Newsgroups: gmane.emacs.bugs Subject: bug#63829: 29.0.90; project-find-file's future history breaks with common-parent-directory Date: Sat, 19 Aug 2023 12:00:37 +0000 (UTC) Message-ID: <871qfzi6mz.fsf@catern.com> References: <16b64d95-35e9-ef94-2c54-17b670111f0f@gutov.dev> <86h6rnw7gm.fsf@mail.linkov.net> <3e404df1-b3a9-f9e3-4270-f42df8b704c7@gutov.dev> <87a5uti6mo.fsf@catern.com> <73a695f3-7c6a-0e50-41dd-61f8269f6ecf@gutov.dev> <875y5fitiq.fsf@catern.com> <208300a3-25e1-d057-11ac-179e52b8f547@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8450"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Spencer Baugh , Juri Linkov , 63829@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 19 14:01:26 2023 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 1qXKdx-000233-VO for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Aug 2023 14:01:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXKdc-0007dV-Fa; Sat, 19 Aug 2023 08:01:04 -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 1qXKdZ-0007bv-J3 for bug-gnu-emacs@gnu.org; Sat, 19 Aug 2023 08:01:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXKdZ-0005Gg-BA for bug-gnu-emacs@gnu.org; Sat, 19 Aug 2023 08:01:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qXKdZ-0004s5-Sm for bug-gnu-emacs@gnu.org; Sat, 19 Aug 2023 08:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Aug 2023 12:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63829 X-GNU-PR-Package: emacs Original-Received: via spool by 63829-submit@debbugs.gnu.org id=B63829.169244644818695 (code B ref 63829); Sat, 19 Aug 2023 12:01:01 +0000 Original-Received: (at 63829) by debbugs.gnu.org; 19 Aug 2023 12:00:48 +0000 Original-Received: from localhost ([127.0.0.1]:49642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qXKdM-0004rS-Cz for submit@debbugs.gnu.org; Sat, 19 Aug 2023 08:00:48 -0400 Original-Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]:14934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qXKdI-0004rB-Qf for 63829@debbugs.gnu.org; Sat, 19 Aug 2023 08:00:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=ve9TsvxuTbbboLn9KsE3u9R5zUaDm/g3aIF3Un7pUSg=; b=SjxVmE9501UzmnDyrjT/ls7DZcSEM1226xeu9piHxiPaTlWyKmwgzw8j1XPAbaBF2Bnr wSzGT6X2n1SC5Q7zvpMFXRa8+l73U1nTVIiAdN8DNJpbc5A/hxSaQnHwo0mly7tBWuTt2b UKRpikvPpB3g0tRmen5dPPxEL+xH8cuhT9wruepvM4xHV+PNOGEeLT/fBeEpKSGpFRDeeX grOb/IlbBP1ybT2crlNhP9SFadZwQjUg0FPS0+/fe4vR7FhwhOGuTfNEEtgjL89uVWqz0b nVGaoHBiZwK0EsScJIQfJ9bqWzK4kgNG5bSf+vvr6EjGBLNqM+SC/vn/ZgCA7IuA== Original-Received: by filterdrecv-8684c58db7-rkmgq with SMTP id filterdrecv-8684c58db7-rkmgq-1-64E0AEE5-47 2023-08-19 12:00:37.446974132 +0000 UTC m=+8684544.839540135 Original-Received: from earth.catern.com (unknown) by geopod-ismtpd-1 (SG) with ESMTP id JOQ3-7NkQXmAcYi7xaeb9w Sat, 19 Aug 2023 12:00:37.211 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gutov.dev Original-Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id A625D62562; Sat, 19 Aug 2023 08:00:36 -0400 (EDT) In-Reply-To: <208300a3-25e1-d057-11ac-179e52b8f547@gutov.dev> (Dmitry Gutov's message of "Sat, 19 Aug 2023 05:08:38 +0300") X-SG-EID: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbJ44j8pmP2gn12MHR+YNk85FilZsC4dxz9mRLa6v263rPqh5T3Qk5tmkY+dWo6IyxbJtIEpIZ5pEIpHoA0vcGrUeMeLa808eB3spEQIxVN1/Eo31No6pHSu8uv3MKNbKbI//tefwYVGRiXRnehwVDIosHaP/GVAhzCS5rPLwu1NZQ== X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:267856 Archived-At: Dmitry Gutov writes: > On 17/08/2023 22:41, Spencer Baugh wrote: >> Dmitry Gutov writes: >>> - (file (funcall project-read-file-name-function >>> - "Find file" all-files nil 'file-name-history >>> - suggested-filename))) >>> + (file >>> + (let ((file-name-history (mapcar >>> + (lambda (f) >>> + (or (project--expand-file-name >>> f project) f)) >>> + file-name-history))) >>> + (funcall project-read-file-name-function >>> + "Find file" all-files nil 'file-name-history >>> + suggested-filename)))) >>> + (when history-add-new-input >>> + ;; Have to re-add it here because of the let-binding above. >>> + (add-to-history 'file-name-history >>> + (propertize file 'project (project-root project)))) >>> (if (string= file "") >>> (user-error "You didn't specify the file") >>> (find-file file)))) >> This seems good, sure. But doesn't this make the history entries >> appear >> twice? > > It doesn't, since whatever modification to file-name-history is done > inside project-read-file-name-function is erased when the surrounding > 'let' form (pre-altering its value) returns. > >> Maybe we should just pull the history-adding functionality out of >> project-read-file-name-function entirely. I've tried doing that below. > > Just for project-find-dir, right? That makes sense. > >> Also, I realized just now that this should probably affect >> project-find-dir as well, as should my previous patch adding >> project-relative future history. (I actually coincidentally just now >> got a user request for "switch between projects and stay in the same >> dir") > > ^^ > >> So here's a revised version of this history change which also affects >> project-find-dir. In a subsequent mail I'll send a patch for the >> "future history" behavior of project-find-dir too. (yet to be written) > > That ones looks good too (I'll go over the cosmetics a little later). > > Regarding project-file-name-history-relativize, I wanted to ask about > a shorter name, but... it seems like there aren't many to be had. > > Also originally I wanted to just enable the feature and then see what > actual modifications people will want. Perhaps some will ask for > find-file and project-find-file histories to be totally separate > instead? Or maybe not. Sure, if it's something you think is reasonable to enable by default that's totally fine for me. A modification that makes some sense to me (although it's hard) is actually to merge find-file and project-find-file history *more*. Right now a path in the history can only be adjusted for the current project if it was originally added to the history by project-find-file. It might be nice if the adjustment worked for paths added by find-file too, although that is tricky to do efficiently since they don't (yet?) have the project embedded in them with a text property.