1

I'm using Projectile, and after seeing the really awesome .emacs file I decided to copy the lines that set the mode-line to display the project name, like so:

:config (projectile-global-mode 1) (setq-default ;; <snip> projectile-mode-line '(:eval (projectile-project-name)))) 

I've got this included in my init.el and it almost works - the only problem is that the variable projectile-project-name is nil, so it doesn't actually show the name of the project (and this is even after I've done C-C p p and chosen a project.

How is projectile-project-name set and/or where is that information stored? (Maybe in the .projectile file?)

5
  • 1
    As per your code, you're calling the projectile-project-name function which does not purely depend on the variable of the same name (but does use that value by preference, when it's non-nil). Commented Aug 30, 2018 at 7:18
  • It seems that projectile already sets projectile-mode-line to a value which includes the project name. Or at least the current version does. If you weren't already seeing that, your problem is probably that you have a custom mode line which isn't displaying projectile-mode-line at all. Commented Aug 30, 2018 at 7:20
  • (:eval (format " Projectile[%s]" (projectile-project-name))) is the value I'm seeing for projectile-mode-line Commented Aug 30, 2018 at 7:21
  • I'm using smart-mode-line, which seems to embed the projectile-mode-line into the mode line at the bottom of the screen. Commented Aug 30, 2018 at 15:57
  • Thanks for the tip about projectile-project-name being a function - I hadn't caught that. When I call it interactively (using M-:) it returns '-'..... because that particular file wasn't part of a project. It returns something reasonable when the file (buffer) that's open is part of the project Commented Aug 30, 2018 at 16:04

1 Answer 1

1

Much thanks to @phils for helping me to realize that Projectile displays the project name when the buffer that has the focus is in a project. If that buffer's file isn't in a project then it displays '-'

Thinking about this, this makes perfect sense - the error is clearly on my end :)

I think I was confused because Visual Studio / Eclipse / etc do it the opposite way - once you've got a project open you're always 'in' that project, even if you open unrelated files.

Both ways seems reasonable, and now I know how Projectile works :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.