From: Eshel Yaron Date: Thu, 3 Apr 2025 16:46:08 +0000 (+0200) Subject: (project-forget-project): Add minibuffer-action X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3a8e6eee05149611dd506181de2242d613995ac5;p=emacs.git (project-forget-project): Add minibuffer-action --- diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 41ddcf6e49c..19a77720e80 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1887,6 +1887,17 @@ the project list." (project--remove-from-project-list project-root "Project `%s' removed from known projects")) +(put 'project-forget-project 'minibuffer-action + (cons + (lambda (name) + (project-forget-project + (or (get-text-property 0 'project-root name) + (seq-find (lambda (dir) + (when-let ((proj (project-current nil dir))) + (string= (project-name proj) name))) + (project-known-project-roots))))) + "forget")) + (defvar project--dir-history) (defun project-prompt-project-dir (&optional prompt) @@ -1934,20 +1945,24 @@ sub-directory of `project-new-projects-directory' using the selected name as the initial input for completion, and return that directory." (let* ((current (project-current)) (default (and current (project-name current))) - (name (completing-read (format-prompt (or prompt "Project") default) - (lambda (string pred action) - (if (eq action 'metadata) - `(metadata (sort-function . minibuffer-sort-alphabetically)) - (complete-with-action - action - (seq-keep (lambda (dir) - (when-let ((proj (project-current nil dir))) - (project-name proj))) - (project-known-project-roots)) - string pred))) - nil nil nil - 'project-name-history - default))) + (name + (minibuffer-with-setup-hook + (lambda () (setq completion-max-replace-secs 0)) + (completing-read (format-prompt (or prompt "Project") default) + (lambda (string pred action) + (if (eq action 'metadata) + `(metadata (sort-function . minibuffer-sort-alphabetically)) + (complete-with-action + action + (seq-keep (lambda (dir) + (when-let ((proj (project-current nil dir)) + (name (project-name proj))) + (propertize name 'project-root dir))) + (project-known-project-roots)) + string pred))) + nil nil nil + 'project-name-history + default)))) (or (seq-find (lambda (dir) (when-let ((proj (project-current nil dir))) (string= (project-name proj) name)))