feat(emacs): Fill some search-related stubs

This commit is contained in:
Madeleine Sydney
2025-02-20 15:45:20 -07:00
parent 98a71dc13b
commit e2193dbd53
13 changed files with 227 additions and 26 deletions

View File

@@ -8,9 +8,32 @@
(when-let* ((project (project-current nil dir)))
(project-root project)))
(defun syd-cd-project ()
(defun syd-project-cd ()
"Change the working directory to the root of the current project."
(cd (syd-project-root)))
(define-obsolete-function-alias 'syd-cd-project 'syd-project-cd
"2025-02-20")
(defmacro syd-with-project-root (root &rest body)
"Execute BODY with ROOT recognised as what project.el calls a \"transient
project\"."
(declare (indent defun))
(let ((root* (gensym "root"))
(forget-after-p (gensym "forget-after-p")))
`(let* ((,root* ,root)
(,forget-after-p
(not (member ,root* (project-known-project-roots)))))
(let ((project-find-functions (lambda (_) (cons 'transient ,root*))))
,@body)
(when ,forget-after-p
(project-forget-project ,root*)))))
(defun syd-project-search ()
(interactive)
(require 'syd-file)
;; TODO: Prompt for path project root is not found.
(syd-search-directory (syd-project-root)))
(provide 'syd-project)
;;; syd-project.el ends here