Skip to content

Commit

Permalink
[Fix #1232] Switch to a simpler scheme for updating the modeline
Browse files Browse the repository at this point in the history
Now it's done just once when a file is opened, which should be good
enough for everyone and as fast as possible.

It's funny that after so many years we simply came back to square one.
On the bright side - I can finally delete all the dreaded caching and
optimization code that was added mostly to address this.
  • Loading branch information
bbatsov committed Sep 20, 2018
1 parent 0786f6a commit bbca83f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -3877,23 +3877,19 @@ is chosen."

;;; Projectile Minor mode
(defcustom projectile-mode-line
'(:eval (format " Projectile[%s]"
(projectile-project-name)))
"Mode line lighter for Projectile.

The value of this variable is a mode line template as in
`mode-line-format'. See Info Node `(elisp)Mode Line Format' for
details about mode line templates.

Customize this variable to change how Projectile displays its
status in the mode line. The default value displays the project
name. Set this variable to nil to disable the mode line
entirely."
"Projectile"
"Mode line lighter for Projectile."
:group 'projectile
:type 'sexp
:risky t
:type 'string
:package-version '(projectile . "0.12.0"))

(defun projectile-update-mode-line ()
"Report project in mode-line."
(let* ((project-name (projectile-project-name))
(message (format " %s[%s]" projectile-mode-line project-name)))
(setq projectile-mode-line message))
(force-mode-line-update))

(defvar projectile-command-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "4 a") #'projectile-find-other-file-other-window)
Expand Down Expand Up @@ -4055,11 +4051,13 @@ Otherwise behave as if called interactively.
(add-hook 'find-file-hook 'projectile-find-file-hook-function)
(add-hook 'projectile-find-dir-hook #'projectile-track-known-projects-find-file-hook t)
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook t t)
(add-hook 'find-file-hook 'projectile-update-mode-line t t)
(ad-activate 'compilation-find-file)
(ad-activate 'delete-file))
(t
(remove-hook 'find-file-hook #'projectile-find-file-hook-function)
(remove-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook t)
(remove-hook 'find-file-hook #'projectile-update-mode-line)
(ad-deactivate 'compilation-find-file)
(ad-deactivate 'delete-file))))

Expand Down

0 comments on commit bbca83f

Please sign in to comment.