From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#47287: 28.0.50; [PATCH] Add command project-remove-known-project Date: Mon, 22 Mar 2021 08:48:47 +0100 Message-ID: References: <83v99lav45.fsf@gnu.org> <95323A8F-5875-413E-952D-383163B0D1A8@thornhill.no> <4f5e3918-e133-88e4-b5c9-90a81e348497@yandex.ru> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19765"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47287@debbugs.gnu.org To: Dmitry Gutov , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 22 08:49:10 2021 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 1lOFJF-0004zi-IO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 Mar 2021 08:49:10 +0100 Original-Received: from localhost ([::1]:36806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOFJE-0007nD-CC for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 Mar 2021 03:49:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOFJ8-0007mg-4G for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2021 03:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOFJ7-0006Sa-Ro for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2021 03:49:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lOFJ7-0002lp-QR for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2021 03:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Mar 2021 07:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47287 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 47287-submit@debbugs.gnu.org id=B47287.161639933610638 (code B ref 47287); Mon, 22 Mar 2021 07:49:01 +0000 Original-Received: (at 47287) by debbugs.gnu.org; 22 Mar 2021 07:48:56 +0000 Original-Received: from localhost ([127.0.0.1]:56066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOFJ1-0002lV-MZ for submit@debbugs.gnu.org; Mon, 22 Mar 2021 03:48:56 -0400 Original-Received: from out0.migadu.com ([94.23.1.103]:25739) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOFIw-0002lJ-Pd for 47287@debbugs.gnu.org; Mon, 22 Mar 2021 03:48:53 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1616399328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ETcGXdrWJU6v9127YR8goGrCi7xhFxnXKfrdu8R5T8A=; b=kwI3UQpAOk2a3COcDiWEANyKYw/GTB7RgsDw4aSPZ2fOWg7ZjvE6FuyThDNUwzRCuzZ81g OJwJl1ZKp8yoJ994t6FUMn9ixlUC9myYkHOE7RXvubuuLK+aCU/sy4fmWqxh+7UaWOWKF8 OlGZMXN6wJDSJiCgSVBv6txp4c9eQ3opxZWiy6su5IaY1SAQSlUKqeExIua6Yh5yRTuLDr QY5JSfDLrVQ9ojTBO2EebPutsGxzAY/HmK30pA5LcBFagvLZC8x2nY3KT8Q7+4kQxCWecX 1Jskgjy4hWFzFoUhp89Nkh6huoxeMKYRXXqWNLkBHY+yleVW8WnjjjgFD3GRBQ== In-Reply-To: <4f5e3918-e133-88e4-b5c9-90a81e348497@yandex.ru> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: theo@thornhill.no 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:202821 Archived-At: --=-=-= Content-Type: text/plain Hi, > It's fine, but it would be better for both function's argument to follow > projectile-add-known-project (meaning, call it 'project-root'). See attached patch. > > Regarding report-message, I figured it would just be a separate > 'message' call in both caller functions. Apparently that might to this > message appearing more often (due to the requested project not actually > appearing in project--list?), but I wonder if we shouldn't replace that > when-let with a presence assertion instead. Yeah, we could do that. However, the nice thing now is at least that the behavior is bundled together, so we don't need to remember to report. Not sure what is best :) > > Anyway, the latter is not a big deal; project--remove-from-project-list > can be changed at any time later. Sure! Do the manual later, or now? -- Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-command-project-remove-known-project.patch >From 78f9aea9d96373721e2590cd79eef360bbc93f0d Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Mon, 22 Mar 2021 00:19:23 +0100 Subject: [PATCH] Add command project-remove-known-project * etc/NEWS: Mention the new command. * lisp/progmodes/project.el (project--remove-from-project-list): Add new argument, report-message, used to signal various messages when removal has happened. * lisp/progmodes/project.el (project-remove-known-project): New command that removes the selected directory from the project-list-file. * lisp/progmodes/project.el (project-current): Add the report message. --- etc/NEWS | 4 ++++ lisp/progmodes/project.el | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 49a4bb8106..abe7107f12 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1573,6 +1573,10 @@ project's root directory, respectively. +++ *** New user option 'project-list-file'. +*** New command 'project-remove-known-project'. +This command lets you interactively remove an entry from the list of projects +in 'project-list-file' + ** xref --- diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index b6a886f731..d76bcbbe96 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -201,7 +201,8 @@ of the project instance object." (when maybe-prompt (if pr (project-remember-project pr) - (project--remove-from-project-list directory) + (project--remove-from-project-list + directory "Project `%s' not found; removed from list") (setq pr (cons 'transient directory)))) pr)) @@ -1217,17 +1218,26 @@ Save the result in `project-list-file' if the list of projects has changed." (push (list dir) project--list) (project--write-project-list)))) -(defun project--remove-from-project-list (pr-dir) - "Remove directory PR-DIR of a missing project from the project list. +(defun project--remove-from-project-list (project-root report-message) + "Remove directory PROJECT-ROOT of a missing project from the project list. If the directory was in the list before the removal, save the result in `project-list-file'. Announce the project's removal -from the list." +from the list using REPORT-MESSAGE." (project--ensure-read-project-list) - (when-let ((ent (assoc pr-dir project--list))) + (when-let ((ent (assoc project-root project--list))) (setq project--list (delq ent project--list)) - (message "Project `%s' not found; removed from list" pr-dir) + (message report-message project-root) (project--write-project-list))) +;;;###autoload +(defun project-remove-known-project (project-root) + "Remove directory PROJECT-ROOT from the project list. +PROJECT-ROOT is the root directory of a known project listed in +the project list." + (interactive (list (project-prompt-project-dir))) + (project--remove-from-project-list + dir "Project `%s' removed from known projects")) + (defun project-prompt-project-dir () "Prompt the user for a directory that is one of the known project roots. The project is chosen among projects known from the project list, -- 2.24.3 (Apple Git-128) --=-=-=--