Skip to content

Commit

Permalink
fix(project): proper convention to forget remote zombie projects
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jan 8, 2024
1 parent 3267853 commit aca7981
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/me-builtin.el
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ or file path may exist now."
:straight t
:after minemacs-loaded
:demand t
:hook (kill-emacs . project-forget-zombie-projects)
:hook (kill-emacs . +project-forget-zombie-projects)
:custom
(project-list-file (concat minemacs-local-dir "project-list.el"))
(project-vc-extra-root-markers '(".projectile.el" ".project.el" ".project")))
Expand Down
2 changes: 1 addition & 1 deletion core/me-keybindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"prC" #'project-async-shell-command
;; forget
"pF" '(nil :wk "forget/cleanup")
"pFz" #'project-forget-zombie-projects
"pFz" #'+project-forget-zombie-projects
"pFp" #'project-forget-project
"pFu" #'project-forget-projects-under
"pFc" #'+project-list-cleanup
Expand Down
12 changes: 12 additions & 0 deletions core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,18 @@ When DIR is not detected as a project, ask to force it to be by adding a
(with-temp-buffer
(write-file (expand-file-name ".project.el" dir)))))

(defun +project-forget-zombie-projects ()
"Forget all known projects that don't exist any more.
Like `project-forget-zombie-projects', but handles remote projects differently,
it forget them only when we are sure they don't exist."
(interactive)
(dolist (proj (project-known-project-roots))
(unless (or (and (file-remote-p proj nil t) (file-readable-p proj)) ; Connected remote + existent project
(file-remote-p proj) ; Non connected remote project
(file-exists-p proj)) ; Existent local project
(project-forget-project proj))))

(defun +project-gdb ()
"Invoke `gdb' in the project's root."
(interactive)
Expand Down

0 comments on commit aca7981

Please sign in to comment.