projectile icon indicating copy to clipboard operation
projectile copied to clipboard

(re-)load a project

Open mooseyboots opened this issue 2 years ago • 3 comments

this is more just a query about how to re-load a project. i wonder if this functionality is implemented, and if not, whether users have some other way of handling this. i'm only a very basic user of projectile.el.

when working on an elisp project, i often need to change branches, then re-load my project's code. i.e. i switch to dired, nav to the code dir, call t to invert all marks (mark all if none marked), then call L to load all marked files.

does projectile.el have a way to do this?

mooseyboots avatar Apr 12 '23 11:04 mooseyboots

Does this help with what you're trying to achieve?

(global-auto-revert-mode t)

Projectile currently can close Projectile buffers, but there's no functionality to recreate special buffers.

bbatsov avatar Apr 12 '23 12:04 bbatsov

i don't think so, no. i'm not worried about whether buffers are open or updated or not (my buffers update when i switch branches).

i'm interested in loading the code inside them after switching git branches. say i work on a branch in an elisp project, but then i want to return to develop branch in order to actually use the project in my own emacs set up, while not working on it. so i save/close the project's buffers and switch branches in magit, but the feature branch is still the code that is loaded into my emacs session. so i have to manually go to the code in dired and load it with dired-do-load as i mentioned.

it's no problem if it's not a feature in projectile, i just wondered also how others deal with this issue. i guess it's only an issue for elisp devs.

mooseyboots avatar Apr 12 '23 13:04 mooseyboots

i cooked up a hack to do this, but it isn't general, it just loads .el files:

(defun mb/projectile-load-source-files ()
    ""
    (interactive)
    (let* ((projectile-root (projectile-acquire-root))
           (subdir (read-directory-name "Load dir: " projectile-root))
           (regex (rx bos
                      (not ".") ; don't load hidden files
                      (* (any alnum "-" "_"))
                      ".el"
                      eos))
           (files (directory-files subdir nil regex)))
      (dolist (file files)
        (load file))))

mooseyboots avatar May 04 '23 08:05 mooseyboots