Added caching of ros-packages of buffers.

The modeline is updated pretty often and searching for the current
buffer's ros package without caching is too expensive.
This commit is contained in:
Lorenz Moesenlechner 2010-04-25 21:16:36 +00:00
parent 19836148a0
commit 22ae023afb
1 changed files with 8 additions and 2 deletions

View File

@ -105,6 +105,8 @@
(defvar ros-find-args nil)
(defvar ros-find-args-history nil)
(defvar ros-buffer-package nil "A buffer-local variable for caching the current buffer's ros package.")
(make-variable-buffer-local 'ros-buffer-package)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Preloading
@ -224,8 +226,12 @@
(ros-package-for-path fn))))
(defun ros-current-pkg-modeline-entry ()
(let ((pkg (ros-package-for-buffer (current-buffer))))
(let ((pkg (or ros-buffer-package (ros-package-for-buffer (current-buffer)))))
(unless ros-buffer-package
(if pkg
(setf ros-buffer-package pkg)
(setf ros-buffer-package :none)))
(if (and pkg (not (eq pkg :none)))
(format "(ROS Pkg: %s)" pkg)
"")))