diff options
| author | Simen Heggestøyl | 2020-05-25 21:10:03 +0200 |
|---|---|---|
| committer | Simen Heggestøyl | 2020-05-26 17:42:24 +0200 |
| commit | 5a48ede3acb1f21a8dd6d56ebbc675b7225d28e5 (patch) | |
| tree | a9e1d2a23ab7d18782fa05df4a9349caa69fb743 | |
| parent | e37e6c8d91c1028fbba52466f40dca2d82b95feb (diff) | |
| download | emacs-5a48ede3acb1f21a8dd6d56ebbc675b7225d28e5.tar.gz emacs-5a48ede3acb1f21a8dd6d56ebbc675b7225d28e5.zip | |
Adapt project functions to the new 'project-root'
* lisp/progmodes/project.el (project-dired, project-eshell)
(project--read-project-list, project--write-project-list)
(project--add-to-project-list-front)
(project--remove-from-project-list): Adapt to the new 'project-root'.
| -rw-r--r-- | lisp/progmodes/project.el | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 132d172a08e..f00aca83d2d 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el | |||
| @@ -670,15 +670,13 @@ PREDICATE, HIST, and DEFAULT have the same meaning as in | |||
| 670 | (defun project-dired () | 670 | (defun project-dired () |
| 671 | "Open Dired in the current project." | 671 | "Open Dired in the current project." |
| 672 | (interactive) | 672 | (interactive) |
| 673 | (let ((dirs (project-roots (project-current t)))) | 673 | (dired (project-root (project-current t)))) |
| 674 | (dired (car dirs)))) | ||
| 675 | 674 | ||
| 676 | ;;;###autoload | 675 | ;;;###autoload |
| 677 | (defun project-eshell () | 676 | (defun project-eshell () |
| 678 | "Open Eshell in the current project." | 677 | "Open Eshell in the current project." |
| 679 | (interactive) | 678 | (interactive) |
| 680 | (let* ((dirs (project-roots (project-current t))) | 679 | (let ((default-directory (project-root (project-current t)))) |
| 681 | (default-directory (car dirs))) | ||
| 682 | (eshell t))) | 680 | (eshell t))) |
| 683 | 681 | ||
| 684 | (declare-function fileloop-continue "fileloop" ()) | 682 | (declare-function fileloop-continue "fileloop" ()) |
| @@ -737,7 +735,7 @@ loop using the command \\[fileloop-continue]." | |||
| 737 | (let ((dirs (split-string (string-trim (buffer-string)) "\n")) | 735 | (let ((dirs (split-string (string-trim (buffer-string)) "\n")) |
| 738 | (project-list '())) | 736 | (project-list '())) |
| 739 | (dolist (dir dirs) | 737 | (dolist (dir dirs) |
| 740 | (cl-pushnew (list (file-name-as-directory dir)) | 738 | (cl-pushnew (file-name-as-directory dir) |
| 741 | project-list | 739 | project-list |
| 742 | :test #'equal)) | 740 | :test #'equal)) |
| 743 | (setq project--list (reverse project-list)))))) | 741 | (setq project--list (reverse project-list)))))) |
| @@ -751,16 +749,16 @@ loop using the command \\[fileloop-continue]." | |||
| 751 | "Persist `project--list' to the project list file." | 749 | "Persist `project--list' to the project list file." |
| 752 | (let ((filename (locate-user-emacs-file "project-list"))) | 750 | (let ((filename (locate-user-emacs-file "project-list"))) |
| 753 | (with-temp-buffer | 751 | (with-temp-buffer |
| 754 | (insert (string-join (mapcar #'car project--list) "\n")) | 752 | (insert (string-join project--list "\n")) |
| 755 | (write-region nil nil filename nil 'silent)))) | 753 | (write-region nil nil filename nil 'silent)))) |
| 756 | 754 | ||
| 757 | (defun project--add-to-project-list-front (pr) | 755 | (defun project--add-to-project-list-front (pr) |
| 758 | "Add project PR to the front of the project list and save it. | 756 | "Add project PR to the front of the project list and save it. |
| 759 | Return PR." | 757 | Return PR." |
| 760 | (project--ensure-read-project-list) | 758 | (project--ensure-read-project-list) |
| 761 | (let ((dirs (project-roots pr))) | 759 | (let ((dir (project-root pr))) |
| 762 | (setq project--list (delete dirs project--list)) | 760 | (setq project--list (delete dir project--list)) |
| 763 | (push dirs project--list)) | 761 | (push dir project--list)) |
| 764 | (project--write-project-list) | 762 | (project--write-project-list) |
| 765 | pr) | 763 | pr) |
| 766 | 764 | ||
| @@ -771,8 +769,8 @@ result to disk." | |||
| 771 | (project--ensure-read-project-list) | 769 | (project--ensure-read-project-list) |
| 772 | ;; XXX: This hardcodes that the number of roots = 1. | 770 | ;; XXX: This hardcodes that the number of roots = 1. |
| 773 | ;; It's fine, though. | 771 | ;; It's fine, though. |
| 774 | (when (member (list pr-dir) project--list) | 772 | (when (member pr-dir project--list) |
| 775 | (setq project--list (delete (list pr-dir) project--list)) | 773 | (setq project--list (delete pr-dir project--list)) |
| 776 | (message "Project `%s' not found; removed from list" pr-dir) | 774 | (message "Project `%s' not found; removed from list" pr-dir) |
| 777 | (project--write-project-list))) | 775 | (project--write-project-list))) |
| 778 | 776 | ||