From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?Q?Simen_Heggest=C3=B8yl?= Newsgroups: gmane.emacs.devel Subject: Re: New feature in project.el: Remembering the previously used projects Date: Sat, 30 May 2020 08:05:25 +0200 Message-ID: <34310.7516107679$1590818781@news.gmane.org> References: <6f0f6cc9-52f4-8383-9827-ead54e898472@yandex.ru> <87h7vy9wrv.fsf@gmail.com> <81be7027-4079-0de6-b4dc-d669cd4c6f71@yandex.ru> <7b8fe2bf-3d1e-65f8-0fdb-111bd39490b5@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="59358"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) Cc: emacs-devel , =?utf-8?Q?K=C3=A9vin?= Le Gouguec To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 30 08:06:17 2020 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 1jeudN-000FLa-Bd for ged-emacs-devel@m.gmane-mx.org; Sat, 30 May 2020 08:06:17 +0200 Original-Received: from localhost ([::1]:53274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeudM-0000a9-DP for ged-emacs-devel@m.gmane-mx.org; Sat, 30 May 2020 02:06:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeucl-0008Va-G9 for emacs-devel@gnu.org; Sat, 30 May 2020 02:05:39 -0400 Original-Received: from aibo.runbox.com ([91.220.196.211]:38322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeucj-0001ZV-DM for emacs-devel@gnu.org; Sat, 30 May 2020 02:05:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Date:References:Subject:Cc:To:From; bh=GO3X4H1UCV5YcKVMgwt3DbIvILS2DYk1mzViU8ugTEo=; b=PDksOJZngMItWBkxYsFHfGUMu/ +lT9abFMR2wM1EP5EJobPrlUPRzEXt52PDivM46fDG2DTxFt/068gRcHrvLE5QgNPKr+hSTMqwP/x 7iLkfbswc49TPgpnVwwfSYfoDVL0AiCICsstfxbY5RgKLDGSaJRapEPEUygfpZylNGyWBVLH3HZBl o7f1zem32f/STBAaG+cbs69YJumNIyG/nl5sRIFMzF4dgkTffWCdemtkzyQVGbxaddOgGvFQ2ymTY 6FKlqj1kgXkLe1rKfPkM1sq3sN4rrXOKzx1O+4n3pUR3UpiMl6JaqVY6+zqD/NxeQS1QuASV/pEUx AWxvBbqg==; Original-Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1jeucg-0006WE-0m; Sat, 30 May 2020 08:05:34 +0200 Original-Received: by submission02.runbox with esmtpsa [Authenticated alias (963757)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1jeucY-0001yW-8C; Sat, 30 May 2020 08:05:26 +0200 Received-SPF: pass client-ip=91.220.196.211; envelope-from=simenheg@runbox.com; helo=aibo.runbox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/30 02:05:34 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, MSGID_MULTIPLE_AT=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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:251640 Archived-At: Dmitry Gutov writes: > And another thought: maybe we should only add a project to the project > list if user interaction happened (i.e. going through > project-prompt-project-dir). Simen, what do you think? > > The patch below mostly does that, except it misses the case when a > directory was selected from project-switch-project. [...] Hm, I think it misses all cases when project-switch-project is used, since project-current will find the project using project--find-in-directory (project-switch-project already did the prompting part). Maybe a simple solution could be to only write to the file when the addition caused the project list to change? I think it's a good change regardless, but is it enough to fix your issue, K=C3=A9vin? diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 1f2a4e8471..a2ef84e444 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -751,14 +751,15 @@ project--write-project-list (write-region nil nil filename nil 'silent)))) (defun project--add-to-project-list-front (pr) - "Add project PR to the front of the project list and save it. -Return PR." + "Add project PR to the front of the project list. +Save the result to disk if the project list was changed." (project--ensure-read-project-list) - (let ((dir (project-root pr))) + (let* ((dir (project-root pr)) + (do-write (not (equal (car project--list) dir)))) (setq project--list (delete dir project--list)) - (push dir project--list)) - (project--write-project-list) - pr) + (push dir project--list) + (when do-write + (project--write-project-list)))) (defun project--remove-from-project-list (pr-dir) "Remove directory PR-DIR from the project list. Dmitry Gutov writes: > Alternatively, we could defer writing the file until Emacs is being > closed (and do that in kill-emacs-hook). Maybe. I think doing it more eagerly has some advantages though if we can make it work: - Launching a new Emacs session while another one is running will use the latest project list. - If there's any problem writing to the file I imagine it's better to be notified about it up front rather than at the time Emacs is killed. -- Simen