3

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.

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
  • 1
    Perhaps not helpful, but I have exactly the same question, haven't looked into this in detail. See also https://www.reddit.com/r/emacs/comments/b50wmx/confused_about_treemacsprojectile_want_to_keep/. – Gijs Oct 26 '20 at 15:11

1 Answers1

2

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))
TerryTsao
  • 565
  • 7
  • 16