Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs - How to automate adding new projects in BOTH - projectile and treemacs?

My workflow of using Emacs involve checking of many different projects. They are added and removed pretty frequently. This is very annoying and time consuming at the moment:

  1. projectile-add-known-project and set a path to a new project
  2. helm-projectile-switch-project and select a new project
  3. treemacs-add-and-display-current-project
  4. now you're ready to finally start working on it.

Is there a way to automate/simplify/speed it up? Perhaps by using some kind of elisp function? If so, what it may look like?

I have some prior experience of using LISP but I haven't written elisp code before.

like image 539
Nikita Fedyashev Avatar asked Oct 22 '25 04:10

Nikita Fedyashev


1 Answers

Well, you can just simply put what you normally do by hand inside one command. You might wanna change a bit to match your needs perfectly.

(defun add-or-switch-project-dwim (dir)
  "Let elisp do a few chores & set my hands free!"
  (interactive (list (read-directory-name "Add to known projects: ")))
  (projectile-add-known-project dir)
  (find-file dir)
  (treemacs-add-and-display-current-project))
like image 198
TerryTsao Avatar answered Oct 24 '25 12:10

TerryTsao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!