From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: New feature in project.el: Remembering the previously used projects Date: Sat, 30 May 2020 02:22:00 +0300 Message-ID: <81be7027-4079-0de6-b4dc-d669cd4c6f71@yandex.ru> References: <6f0f6cc9-52f4-8383-9827-ead54e898472@yandex.ru> <87h7vy9wrv.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="37713"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 Cc: =?UTF-8?Q?Simen_Heggest=c3=b8yl?= , emacs-devel To: =?UTF-8?Q?K=c3=a9vin_Le_Gouguec?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 30 01:22:45 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 1jeoKq-0009hq-R1 for ged-emacs-devel@m.gmane-mx.org; Sat, 30 May 2020 01:22:44 +0200 Original-Received: from localhost ([::1]:60282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeoKp-0004Dl-RL for ged-emacs-devel@m.gmane-mx.org; Fri, 29 May 2020 19:22:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeoKD-0003et-N8 for emacs-devel@gnu.org; Fri, 29 May 2020 19:22:05 -0400 Original-Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:45263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeoKC-0001UA-9D for emacs-devel@gnu.org; Fri, 29 May 2020 19:22:05 -0400 Original-Received: by mail-wr1-x431.google.com with SMTP id c3so5709167wru.12 for ; Fri, 29 May 2020 16:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vdKlXN0CNv8C6SKVPFy721o0qltkhq5mLA2clbGNbZU=; b=gjGBKlKoKu7C4p7yu2oMTDJxyC6vcLylDEyxf55pu0MSI6Ga+TAIvsEM/Fx67kEkSO NDBCePJfME7bjPIcVaDs5zZW99DXPENKVqToV7jSIQqzGe7MEUHp7wDP5xfzi8+uBTXt 6rNxy+NTZ/qdJO39EYA1XDitooLJQCKQWL+//sqs4jFcu0EWjsgJzCWOokq7KvkIMxUh A0QcpvEBzh9KahBt1kvywandd4VuhtxUXlGpqY/253Vnu/TTv8WMQ2IcUYDq/7DO18Fy dedH0XraJahPGKvzmQLmvYlN7Qf2ZlgEb3SYCwkMCFSNr+jecl7B7zX2hbEqlSNv4+TG dqWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vdKlXN0CNv8C6SKVPFy721o0qltkhq5mLA2clbGNbZU=; b=Lh+DivnTChORz/ArGUTO+LoM0MRZRyD6rVw3tYzK1uiJq5M2KW4W+Z1fWqAOCj/lFh 3fxcuvAt9REuS7tKzEx6AA8Ydxvw5VDJJyEefdnqNqYbz1IJMj5ecT7rOqV6FgBh1Kb0 7ZK8TGdav2Am/u6EwLly8wE2pODsF2UdrtmG4lZVgRvxKy9AMTpgaGpSNhXRV3BlH7fs aIQHvmIDheOGmhYkGJcTUdQPMRV1disqLJh6DTkvdenoFRk+qK2zwJoByfgTzQneBuyY pZgF5ygnDoGA6hoUxFoV2Q8AhxOlTtfynpUAHWdkBXMg7NUxvaZoizJOKdZxZ9YUB+5K HvQA== X-Gm-Message-State: AOAM530ir+V3HrMLbew14/H0s6Aty65yGUXRHaJzWitsLKCyjKP/zk0Z 2Eo5xvepbDa43pUwgkzQ+Ao= X-Google-Smtp-Source: ABdhPJxDinumURAU8uE9td8PaXGQ04qxNgMjYtah4pa03MgwOQJxB2sMNHR5psxY/5G9uWlNLFWEpA== X-Received: by 2002:adf:e387:: with SMTP id e7mr6278052wrm.70.1590794522459; Fri, 29 May 2020 16:22:02 -0700 (PDT) Original-Received: from [192.168.0.3] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id z22sm1206135wmf.9.2020.05.29.16.22.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 May 2020 16:22:01 -0700 (PDT) In-Reply-To: <87h7vy9wrv.fsf@gmail.com> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=raaahh@gmail.com; helo=mail-wr1-x431.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-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:251630 Archived-At: On 30.05.2020 01:55, Kévin Le Gouguec wrote: > I have one gripe with it though: I've rigged frame-title-format to show > the basename of the project root directory[1], which means I have a call > to project-current on every redisplay. First thought: you can cache it based it the value of default-directory. Which should cut down on these calls (which trigger directory traversals, etc) dramatically, and should be an improvement either way. > IIUC, when default-directory is inside a project, project-current now > calls project--add-to-project-list-front, which in turn calls > project--write-project-list. > > This slows down redisplay quite noticeably on my end[2]. I don't know > what the best solution would be; does it sound acceptable to add an > optional SKIP-LIST-UPDATE argument for project-current, or is it too > much trouble for this peculiar use-case? 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. To fix that, we could either duplicate the bit of logic there, or undo, in part, the commit 9f88356b6770fb710c47e277dbdb4ba31b463d08 (turn project-prompt-project-dir back into project-prompt-project, to return a project instance, and handle the addition to history in there). Anyway, the quick patch: diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 1f2a4e8471..2611b04680 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -114,10 +114,11 @@ project-current ((unless project-current-inhibit-prompt maybe-prompt) (setq dir (project-prompt-project-dir) - pr (project--find-in-directory dir)))) - (if pr - (project--add-to-project-list-front pr) - (project--remove-from-project-list dir) + pr (project--find-in-directory dir)) + (if pr + (project--add-to-project-list-front pr) + (project--remove-from-project-list dir)))) + (unless pr (setq pr (cons 'transient dir))) pr))