[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#64088: [PATCH] Make project-root for vc projects return an absolute
From: |
Spencer Baugh |
Subject: |
bug#64088: [PATCH] Make project-root for vc projects return an absolute path |
Date: |
Tue, 27 Jun 2023 16:01:29 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Dmitry Gutov <dmitry@gutov.dev> writes:
> On 15/06/2023 23:48, Spencer Baugh wrote:
>> - (setq project (list 'vc backend root))
>> + (setq project (list 'vc backend (expand-file-name root)))
>
> Spec violated or not (like Eli said, abbreviated names are still
> absolute), we should probably try to fix this in another place, so
> that other backends (whatever external ones exist) don't have to worry
> about the distinction.
>
> As you can see, in project-buffers, for example, we call expand-file-name.
OK, how about this?
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ddb033d50f9..b365e195415 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1575,7 +1575,10 @@ project-list-file
(defvar project--list 'unset
"List structure containing root directories of known projects.
-With some possible metadata (to be decided).")
+With some possible metadata (to be decided).
+
+Entries should be canonicalized with `expand-file-name' before
+being added.")
(defun project--read-project-list ()
"Initialize `project--list' using contents of `project-list-file'."
@@ -1613,7 +1616,7 @@ project-remember-project
Save the result in `project-list-file' if the list of projects
has changed, and NO-WRITE is nil."
(project--ensure-read-project-list)
- (let ((dir (project-root pr)))
+ (let ((dir (expand-file-name (project-root pr))))
(unless (equal (caar project--list) dir)
(dolist (ent project--list)
(when (equal dir (car ent))
@@ -1629,7 +1632,7 @@ project--remove-from-project-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 project-root project--list)))
+ (when-let ((ent (assoc (expand-file-name project-root) project--list)))
(setq project--list (delq ent project--list))
(message report-message project-root)
(project--write-project-list)))