[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d4e7087: Save project list as lisp data
From: |
Simen Heggestøyl |
Subject: |
master d4e7087: Save project list as lisp data |
Date: |
Tue, 9 Jun 2020 14:46:18 -0400 (EDT) |
branch: master
commit d4e7087b68d70a1f05decbce07340801fe08fe7e
Author: Simen Heggestøyl <simenheg@gmail.com>
Commit: Simen Heggestøyl <simenheg@gmail.com>
Save project list as lisp data
Save the project list file as lisp data instead of line separated
strings to make it more extendable in the future.
* lisp/progmodes/project.el (project--read-project-list)
(project--write-project-list, project--add-to-project-list-front)
(project--remove-from-project-list): Adjust to `project--list' now
being an alist.
---
lisp/progmodes/project.el | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 4d57fb2..0cca518 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -763,13 +763,8 @@ Arguments the same as in `compile'."
(when (file-exists-p filename)
(with-temp-buffer
(insert-file-contents filename)
- (let ((dirs (split-string (buffer-string) "\n" t))
- (project-list '()))
- (dolist (dir dirs)
- (cl-pushnew (file-name-as-directory dir)
- project-list
- :test #'equal))
- (reverse project-list)))))))
+ (goto-char (point-min))
+ (read (current-buffer)))))))
(defun project--ensure-read-project-list ()
"Initialize `project--list' if it hasn't already been."
@@ -780,7 +775,8 @@ Arguments the same as in `compile'."
"Persist `project--list' to the project list file."
(let ((filename project-list-file))
(with-temp-buffer
- (insert (string-join project--list "\n"))
+ (insert ";;; -*- lisp-data -*-\n")
+ (pp project--list (current-buffer))
(write-region nil nil filename nil 'silent))))
(defun project--add-to-project-list-front (pr)
@@ -788,9 +784,9 @@ Arguments the same as in `compile'."
Save the result to disk if the project list was changed."
(project--ensure-read-project-list)
(let ((dir (project-root pr)))
- (unless (equal (car project--list) dir)
- (setq project--list (delete dir project--list))
- (push dir project--list)
+ (unless (equal (caar project--list) dir)
+ (setq project--list (assoc-delete-all dir project--list))
+ (push (list dir) project--list)
(project--write-project-list))))
(defun project--remove-from-project-list (pr-dir)
@@ -798,8 +794,8 @@ Save the result to disk if the project list was changed."
If the directory was in the list before the removal, save the
result to disk."
(project--ensure-read-project-list)
- (when (member pr-dir project--list)
- (setq project--list (delete pr-dir project--list))
+ (when (assoc pr-dir project--list)
+ (setq project--list (assoc-delete-all pr-dir project--list))
(message "Project `%s' not found; removed from list" pr-dir)
(project--write-project-list)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master d4e7087: Save project list as lisp data,
Simen Heggestøyl <=