all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Dmitry Gutov <dgutov@yandex.ru>, Eli Zaretskii <eliz@gnu.org>
Cc: 47287@debbugs.gnu.org
Subject: bug#47287: 28.0.50; [PATCH] Add command project-remove-known-project
Date: Mon, 22 Mar 2021 08:48:47 +0100	[thread overview]
Message-ID: <m1a6qvhbmo.fsf@Frende-MacBook.lan> (raw)
In-Reply-To: <4f5e3918-e133-88e4-b5c9-90a81e348497@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

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



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-command-project-remove-known-project.patch --]
[-- Type: text/x-patch, Size: 3216 bytes --]

From 78f9aea9d96373721e2590cd79eef360bbc93f0d Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
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)


  reply	other threads:[~2021-03-22  7:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-20 23:28 bug#47287: 28.0.50; [PATCH] Add command project-remove-known-project Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-21  0:27 ` Dmitry Gutov
2021-03-21  6:33   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-21 11:42     ` Dmitry Gutov
2021-03-21  6:17 ` Eli Zaretskii
2021-03-21  6:38   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-21 12:12     ` Dmitry Gutov
2021-03-21 12:15       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-21 23:21       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-21 23:54         ` Dmitry Gutov
2021-03-22  7:48           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-03-22 11:52             ` Dmitry Gutov
2021-03-22 12:29               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-23 11:37             ` Eli Zaretskii
2021-03-23 12:30               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-23 12:43                 ` Eli Zaretskii
2021-03-23 12:50                   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-24 23:17                     ` Dmitry Gutov
2021-03-25  0:03                       ` Basil L. Contovounesios
2021-03-25  1:04                         ` Dmitry Gutov
2021-03-25  6:15                           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-25  7:29                             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-21 13:24                               ` Dmitry Gutov
2021-09-21 18:36                                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1a6qvhbmo.fsf@Frende-MacBook.lan \
    --to=bug-gnu-emacs@gnu.org \
    --cc=47287@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.