emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 275be44: Add command project-remove-known-project


From: Dmitry Gutov
Subject: master 275be44: Add command project-remove-known-project
Date: Wed, 24 Mar 2021 19:16:43 -0400 (EDT)

branch: master
commit 275be44dd44de4b7413490ffad912935fe2e1763
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    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.
    
    * doc/emacs/maintaining.text: Add information about the new command to
    the manual.
---
 doc/emacs/maintaining.texi | 16 ++++++++++++++++
 etc/NEWS                   |  5 +++++
 lisp/progmodes/project.el  | 23 +++++++++++++++++------
 3 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 2750418..7e449a5 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -1843,6 +1843,22 @@ in the menu, and which key invokes each command.
 records the list of known projects.  It defaults to the file
 @file{projects} in @code{user-emacs-directory} (@pxref{Find Init}).
 
+@node Managing project list file
+@subsection Managing Projects
+
+@table @kbd
+@item M-x project-remove-known-project
+Remove a known project from the (@code{project-list-file}).
+@end table
+
+@findex project-remove-known-project
+  Normally Emacs handle adding and removing projects to the
+(@code{project-list-file}) automatically.  Sometimes you still want to
+manually edit the available
+projects. @kbd{M-x project-remove-known-project} will prompt you for the
+available projects, and upon selecting one, it will disappear from the
+@code{project-list-file}
+
 @node Change Log
 @section Change Logs
 
diff --git a/etc/NEWS b/etc/NEWS
index 5dbd61f..68812c6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1575,6 +1575,11 @@ 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 b6a886f..0784297 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,27 @@ 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, which is a format string
+passed to `message' as its first argument."
   (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,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]