Skip to content

Commit

Permalink
[Fix #1016] Add a new defcustom controlling what to do with the curre…
Browse files Browse the repository at this point in the history
…nt project on switch (#1310)
  • Loading branch information
s-surineni authored and bbatsov committed Oct 4, 2018
1 parent 5c4a3b4 commit bc24537
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -3483,13 +3483,33 @@ An open project is a project with any open buffers."
(list (abbreviate-file-name (projectile-project-root))))
projects))

(defun projectile--move-current-project-to-end (projects)
"Move current project (if any) to the end of list in the list of PROJECTS"
(if (projectile-project-p)
(append
(projectile--remove-current-project projects)
(list (abbreviate-file-name (projectile-project-root))))
projects))

(defun projectile-relevant-known-projects ()
"Return a list of known projects except the current one (if present)."
(projectile--remove-current-project projectile-known-projects))
"Return a list of known projects."
(cond
((eq projectile-current-project-on-switch 'remove)
(projectile--remove-current-project projectile-known-projects))
((eq projectile-current-project-on-switch 'move-to-end)
(projectile--move-current-project-to-end projectile-known-projects))
((eq projectile-current-project-on-switch 'keep)
projectile-known-projects)))

(defun projectile-relevant-open-projects ()
"Return a list of open projects except the current one (if present)."
(projectile--remove-current-project (projectile-open-projects)))
"Return a list of open projects."
(cond
((eq projectile-current-project-on-switch 'remove)
(projectile--remove-current-project projectile-known-projects))
((eq projectile-current-project-on-switch 'move-to-end)
(projectile--move-current-project-to-end projectile-known-projects))
((eq projectile-current-project-on-switch 'keep)
projectile-known-projects)))

;;;###autoload
(defun projectile-switch-project (&optional arg)
Expand Down Expand Up @@ -3951,6 +3971,18 @@ thing shown in the mode line otherwise."
:type 'string
:package-version '(projectile . "0.12.0"))

(defcustom projectile-current-project-on-switch 'remove
"Determines whether to display current project as an option
when switching projects.
When set to 'remove current project is not included,
'move-to-end will display current project and the end of the list of known projects,
'keep will leave the current project at the default position."
:group 'projectile
:type '(radio
(const :tag "remove" remove)
(const :tag "move-to-end" move-to-end)
(const :tag "keep" keep)))

(define-obsolete-variable-alias 'projectile-mode-line-lighter 'projectile-mode-line-prefix)

(defvar-local projectile--mode-line projectile-mode-line-prefix)
Expand Down

0 comments on commit bc24537

Please sign in to comment.