Commit 078e19a2aff6
Changed files (2)
tools
emacs
config
lisp
tools/emacs/config/config-projects.el
@@ -5,18 +5,6 @@
(require 'json)
-(defun vde/open-readme ()
- "Open a README file in the current project.
-It will search for README.org, README.md or README in that order"
- (interactive)
- (let* ((default-directory (vde-project--project-current)))
- (cond ((file-exists-p (expand-file-name "README.org" default-directory))
- (find-file "README.org"))
- ((file-exists-p (expand-file-name "README.md" default-directory))
- (find-file "README.md"))
- ((file-exists-p (expand-file-name "README" default-directory))
- (find-file "README")))))
-
(use-package project
:commands (project-find-file project-find-regexp vde-project-vterm vde-project-run-in-vterm)
:custom ((project-switch-commands '((?f "File" project-find-file)
@@ -34,39 +22,6 @@ It will search for README.org, README.md or README in that order"
("C-x p s" . vde-project-vterm)
("C-x p X" . vde-project-run-in-vterm)
("C-x p G" . checkout-github-pr))
- :init
- (defun vde-project-run-in-vterm (command &optional directory)
- "Run the given `COMMAND' in a new vterm buffer in `project-root' or the
-given `DIRECTORY'.
-
-This is similar to `compile' but with vterm.
-One reason for this is to be able to run commands that needs a TTY."
- (interactive "sCommand: ")
- (let* ((cwd (or directory (vde-project--project-root-or-default-directory)))
- (default-directory cwd)
- (buffer-name (format "*vterm %s: %s*" cwd command))
- (buffer (get-buffer buffer-name))
- (vterm-kill-buffer-on-exit nil)
- (vterm-shell (concat "bash -c '" command ";exit'")))
- (when buffer
- (kill-buffer buffer))
- (let ((buffer (generate-new-buffer buffer-name)))
- (pop-to-buffer buffer)
- (with-current-buffer buffer
- (vterm-mode)))))
-
- (defun vde/project-try-local (dir)
- "Determine if DIR is a non-VC project."
- (if-let ((root (if (listp vde/project-local-identifier)
- (seq-some (lambda (n)
- (locate-dominating-file dir n))
- vde/project-local-identifier)
- (locate-dominating-file dir vde/project-local-identifier))))
- (cons 'local root)))
- (cl-defmethod project-root ((project (head local)))
- (cdr project))
-
- (cl-defmethod project-root ((project (eql nil))) nil)
:config
(setq vde/project-local-identifier '(".project")) ;; "go.mod"
tools/emacs/lisp/project-func.el
@@ -65,5 +65,49 @@
(project-root (project-current)))
(t default-directory)))
+;;;##autoload
+(defun vde-project-run-in-vterm (command &optional directory)
+ "Run the given `COMMAND' in a new vterm buffer in `project-root' or the
+given `DIRECTORY'.
+
+This is similar to `compile' but with vterm.
+One reason for this is to be able to run commands that needs a TTY."
+ (interactive "sCommand: ")
+ (let* ((cwd (or directory (vde-project--project-root-or-default-directory)))
+ (default-directory cwd)
+ (buffer-name (format "*vterm %s: %s*" cwd command))
+ (buffer (get-buffer buffer-name))
+ (vterm-kill-buffer-on-exit nil)
+ (vterm-shell (concat "bash -c '" command ";exit'")))
+ (when buffer
+ (kill-buffer buffer))
+ (let ((buffer (generate-new-buffer buffer-name)))
+ (pop-to-buffer buffer)
+ (with-current-buffer buffer
+ (vterm-mode)))))
+
+;;;###autoload
+(defun vde/open-readme ()
+ "Open a README file in the current project.
+It will search for README.org, README.md or README in that order"
+ (interactive)
+ (let* ((default-directory (vde-project--project-current)))
+ (cond ((file-exists-p (expand-file-name "README.org" default-directory))
+ (find-file "README.org"))
+ ((file-exists-p (expand-file-name "README.md" default-directory))
+ (find-file "README.md"))
+ ((file-exists-p (expand-file-name "README" default-directory))
+ (find-file "README")))))
+
+;;;###autoload
+(defun vde/project-try-local (dir)
+ "Determine if DIR is a non-VC project."
+ (if-let ((root (if (listp vde/project-local-identifier)
+ (seq-some (lambda (n)
+ (locate-dominating-file dir n))
+ vde/project-local-identifier)
+ (locate-dominating-file dir vde/project-local-identifier))))
+ (cons 'local root)))
+
(provide 'project-func)
;;; project-func.el ends here