[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/projectile de9b4ecfa3 1/2: [Fix #1831] Enable the project.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/projectile de9b4ecfa3 1/2: [Fix #1831] Enable the project.el integration only when `projectile-mode` is active |
Date: |
Wed, 15 Mar 2023 08:01:55 -0400 (EDT) |
branch: elpa/projectile
commit de9b4ecfa3fafc88c6193007ebc1128c85b32b6e
Author: Bozhidar Batsov <bozhidar@batsov.dev>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>
[Fix #1831] Enable the project.el integration only when `projectile-mode`
is active
---
CHANGELOG.md | 1 +
projectile.el | 70 ++++++++++++++++++++++++++++++++---------------------------
2 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7571288225..d2b4e052e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
### Changes
* [#1285](https://github.com/bbatsov/projectile/pull/1825): By default, use
[fd](https://github.com/sharkdp/fd) in Git repositories instead of `git
ls-files` when it is installed, in order to solve the problem where deleted
files were still shown in `projectile-find-file` until their deletions were
staged. The user-facing behavior should be the same, although potentially with
different performance characteristics in large Git repositories. The old
behavior can be reclaimed by setting `pr [...]
+* [#1831](https://github.com/bbatsov/projectile/issues/1831): Enable the
project.el integration only when `projectile-mode` is active.
## 2.7.0 (2022-11-22)
diff --git a/projectile.el b/projectile.el
index 44cdba2b80..09f6d436da 100644
--- a/projectile.el
+++ b/projectile.el
@@ -6081,6 +6081,42 @@ when opening new files."
(when (> (length project-buffers) projectile-max-file-buffer-count)
(kill-buffer (car (last project-buffers)))))))
+;;;; project.el integration
+;;
+;; Projectile will become the default provider for
+;; project.el project and project files lookup when
+;; projectile-mode is enabled.
+;;
+;; The integration can also be manually enabled like this:
+;;
+;; (add-hook 'project-find-functions #'project-projectile)
+;;
+;; See https://github.com/bbatsov/projectile/issues/1591 for
+;; more details.
+
+;; it's safe to require this directly, as it was added in Emacs 25.1
+(require 'project)
+
+(cl-defmethod project-root ((project (head projectile)))
+ (cdr project))
+
+(cl-defmethod project-files ((project (head projectile)) &optional _dirs)
+ (let ((root (project-root project)))
+ ;; Make paths absolute and ignore the optional dirs argument,
+ ;; see
https://github.com/bbatsov/projectile/issues/1591#issuecomment-896423965
+ ;; That's needed because Projectile uses relative paths for project files
+ ;; and project.el expects them to be absolute.
+ ;; FIXME: That's probably going to be very slow in large projects.
+ (mapcar (lambda (f)
+ (concat root f))
+ (projectile-project-files root))))
+
+(defun project-projectile (dir)
+ "Return Projectile project of form ('projectile . root-dir) for DIR."
+ (let ((root (projectile-project-root dir)))
+ (when root
+ (cons 'projectile root))))
+
;;;###autoload
(define-minor-mode projectile-mode
"Minor mode to assist project management and navigation.
@@ -6117,12 +6153,14 @@ Otherwise behave as if called interactively.
(projectile--cleanup-known-projects)
(when projectile-auto-discover
(projectile-discover-projects-in-search-path))
+ (add-hook 'project-find-functions #'project-projectile)
(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)
(advice-add 'compilation-find-file :around
#'compilation-find-file-projectile-find-compilation-buffer)
(advice-add 'delete-file :before
#'delete-file-projectile-remove-from-cache))
(t
+ (remove-hook 'project-find-functions #'project-projectile)
(remove-hook 'find-file-hook #'projectile-find-file-hook-function)
(remove-hook 'dired-before-readin-hook
#'projectile-track-known-projects-find-file-hook t)
(advice-remove 'compilation-find-file
#'compilation-find-file-projectile-find-compilation-buffer)
@@ -6140,38 +6178,6 @@ Otherwise behave as if called interactively.
;;;###autoload
(define-obsolete-function-alias 'projectile-global-mode 'projectile-mode "1.0")
-;;;; project.el integration
-;;
-;; Projectile will become the default provider for
-;; project.el project and project files lookup.
-;; See https://github.com/bbatsov/projectile/issues/1591 for
-;; more details.
-
-;; it's safe to require this directly, as it was added in Emacs 25.1
-(require 'project)
-
-(cl-defmethod project-root ((project (head projectile)))
- (cdr project))
-
-(cl-defmethod project-files ((project (head projectile)) &optional _dirs)
- (let ((root (project-root project)))
- ;; Make paths absolute and ignore the optional dirs argument,
- ;; see
https://github.com/bbatsov/projectile/issues/1591#issuecomment-896423965
- ;; That's needed because Projectile uses relative paths for project files
- ;; and project.el expects them to be absolute.
- ;; FIXME: That's probably going to be very slow in large projects.
- (mapcar (lambda (f)
- (concat root f))
- (projectile-project-files root))))
-
-(defun project-projectile (dir)
- "Return Projectile project of form ('projectile . root-dir) for DIR."
- (let ((root (projectile-project-root dir)))
- (when root
- (cons 'projectile root))))
-
-(add-hook 'project-find-functions #'project-projectile)
-
(provide 'projectile)
;;; projectile.el ends here