diff --git a/lisp/bindings.el b/lisp/bindings.el index c77b64c05da..ba9f44b920c 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -616,6 +616,7 @@ mode-line-end-spaces " " 'mode-line-position '(vc-mode vc-mode) + '(project-mode project-name) " " 'mode-line-modes 'mode-line-misc-info diff --git a/lisp/desktop.el b/lisp/desktop.el index 6aacb85c12c..6198441d788 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -547,6 +547,7 @@ desktop-minor-mode-table '((defining-kbd-macro nil) (isearch-mode nil) (vc-mode nil) + (project-mode nil) (vc-dir-mode nil) (erc-track-minor-mode nil) (savehist-mode nil)) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 7c51778d5d4..06bd0d09b8e 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1883,5 +1908,47 @@ project-switch-project (let ((project-current-directory-override dir)) (call-interactively command)))) +;;; Project mode + +;; Tell Emacs about this new kind of minor mode +(add-to-list 'minor-mode-alist '(project-mode project-name)) + +(defvar project-name nil + "The project name of the current buffer when it belongs to a project.") + +;;;###autoload +(put 'project-name 'risky-local-variable t) +(put 'project-name 'permanent-local t) + +(defvar project-menu-entry + `(menu-item ,(purecopy "Project") ,menu-bar-project-menu)) + +(defconst project-mode-line-map + (let ((map (make-sparse-keymap))) + (define-key map [mode-line down-mouse-1] project-menu-entry) + map)) + +;;;###autoload +(define-minor-mode project-mode + "Toggle display of project menu in the project-aware buffers." + (if project-mode + (setq-local project-name (concat + " " + (propertize + (project-name (project-current)) + 'mouse-face 'mode-line-highlight + 'local-map project-mode-line-map))))) + +(defun project-mode--turn-on () + "Turn on `project-mode' in all pertinent buffers." + (when (project-current) + (project-mode 1))) + +;;;###autoload +(define-globalized-minor-mode global-project-mode + project-mode project-mode--turn-on + :group 'project + :version "30.1") + (provide 'project) ;;; project.el ends here