diff options
| author | Yuchen Pei <id@ypei.org> | 2023-06-26 15:17:20 +1000 | 
|---|---|---|
| committer | Yuchen Pei <id@ypei.org> | 2023-06-26 15:17:20 +1000 | 
| commit | ea1e815c3dc1781aa5cb6d401e233c73fa8a108b (patch) | |
| tree | 189aa1cc44277f5c298eed5230c4ae2784fafeec /emacs/.emacs.d/lisp/my/my-project.el | |
| parent | f77444c030038100908e298666f8f84f85e768cb (diff) | |
Adapted more configs from other emacs configs
Including wasamasa and jwiegley
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-project.el')
| -rw-r--r-- | emacs/.emacs.d/lisp/my/my-project.el | 45 | 
1 files changed, 45 insertions, 0 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-project.el b/emacs/.emacs.d/lisp/my/my-project.el index 21a05f1..6835487 100644 --- a/emacs/.emacs.d/lisp/my/my-project.el +++ b/emacs/.emacs.d/lisp/my/my-project.el @@ -61,6 +61,51 @@    "Remember all projects under `my-projects-root-dirs'."    (pcase-dolist (`(_ . ,dir) my-projects-root-dirs)      (project-remember-projects-under dir))) + +;; Override project-remember-projects-under The original function is +;; buggy: it does not look for projects in surdirs unless recursive. +(defun my-project-remember-projects-under (dir &optional recursive) +  "Index all projects below a directory DIR. +If RECURSIVE is non-nil, recurse into all subdirectories to find +more projects.  After finishing, a message is printed summarizing +the progress.  The function returns the number of detected +projects." +  (interactive "DDirectory: \nP") +  (project--ensure-read-project-list) +  (let ((queue (directory-files +                dir +                t +                directory-files-no-dot-files-regexp)) +        (count 0) +        (known (make-hash-table +                :size (* 2 (length project--list)) +                :test #'equal ))) +    (dolist (project (mapcar #'car project--list)) +      (puthash project t known)) +    (while queue +      (when-let ((subdir (pop queue)) +                 ((file-directory-p subdir))) +        (when-let ((project (project--find-in-directory subdir)) +                   (project-root (project-root project)) +                   ((not (gethash project-root known)))) +          (project-remember-project project t) +          (puthash project-root t known) +          (message "Found %s..." project-root) +          (setq count (1+ count))) +        (when (and recursive (file-directory-p subdir)) +          (setq queue +                (nconc +                 (directory-files +                  subdir t directory-files-no-dot-files-regexp t) +                 queue))))) +    (unless (eq recursive 'in-progress) +      (if (zerop count) +          (message "No projects were found") +        (project--write-project-list) +        (message "%d project%s were found" +                 count (if (= count 1) "" "s")))) +    count)) +  ;; FIXME: do we really need this or does the project package already  ;; do so?  (defun my-project-read-project ()  | 
