When I issue the command helm-projectile-switch-project, can I have it open the Most Recently Used file in that project, instead of asking me for a file?
If the file is already open, switch to that buffer?;)
Already a function for that, maybe?;)
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI'm not sure such a command already exists, but here's one that I wrote a while ago:
(defun lw-switch-project ()
(interactive)
(let* ((projects (projectile-relevant-known-projects))
(project (f-expand (completing-read "Switch to project: " projects)))
(windows (window-list))
(opened-files (-filter #'buffer-file-name
(projectile-project-buffers project)))
(all-files (if (> (length windows) (length opened-files))
(append
opened-files
(--> (projectile-project-files project)
(-flatten
(-separate (lambda (f) (or (f-ext-p f "py") (f-ext-p f "scala")
(f-ext-p f "sc") (f-ext-p f "el"))) it))
(-take (- (length windows) (length opened-files)) it)
(-map (-partial #'f-join project) it)
(-map #'find-file-noselect it)))
opened-files)))
(--each (-zip windows all-files)
(set-window-buffer (car it) (cdr it)))))
It should prompt you for a project, then fill your windows with buffers belonging to that project, prioritising already open buffers and program files (simply checked by extension), then going by MRU. Though note it uses f.el
and dash.el
.