-
-
Notifications
You must be signed in to change notification settings - Fork 393
helm-browse-project: improve detecting project vc backend #2732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Quang Trung Ta ***@***.***> writes:
Hi,
This is an improvement on the previous code that I wrote to detect VC backend in a Git/Hg nested scenario.
I just discovered that the vc package can do the job well, and can be extended to other VC tools.
For some reasons my previous answer was never sent, sorry.
Sending again.
Thanks, but this patch has two problems:
1) If vc is disabled before your current-buffer has been loaded,
vc-deduce-backend returns nil, it is what is happening here because I
disable vc before loading all my buffers (with psession) when starting
emacs. Hopefully I could fix this with
(setq vc-deduce-backend-nonvc-modes t).
2) The next part of your patch is breaking again
helm-browse-project-history in the best case otherwise it may return an
error if helm-ls-git or/and helm-ls-hg are not installed:
+ (helm-acond ((equal project-vc-backend 'Git)
+ (require 'helm-ls-git nil t)
+ (push-to-hist (helm-ls-git-root-dir))
(helm-ls-git))
- ((equal project-type 'Hg)
- (push-to-hist hg-project)
+ ((equal project-vc-backend 'Hg)
+ (require 'helm-ls-hg nil t)
+ (push-to-hist (helm-hg-root))
So if we consider 1) is very rare and can be fixed with user setting
(vc-deduce-backend-nonvc-modes) we could fix 2) by using such a patch:
diff --git a/helm-files.el b/helm-files.el
index 82f7ba0a..530ea7f5 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -7116,6 +7116,7 @@ and
<https://github.com/emacs-helm/helm-ls-hg>."
(interactive "P")
(require 'helm-x-files)
+ (require 'vc)
(let* ((helm-type-buffer-actions
(remove (assoc "Browse project from buffer"
helm-type-buffer-actions)
@@ -7125,26 +7126,19 @@ and
(fboundp 'helm-ls-git-root-dir)
(helm-ls-git-root-dir))
it))
- ;; handle nested projects (Hg inside Git or vice versa) issue#2723.
(hg-project (helm-aif (and (require 'helm-ls-hg nil t)
(fboundp 'helm-hg-root)
(helm-hg-root))
it))
- (project-type (cond ((and git-project (not hg-project)) 'Git)
- ((and hg-project (not git-project)) 'Hg)
- ((and hg-project git-project)
- (if (string-prefix-p
- (expand-file-name git-project)
- (expand-file-name hg-project))
- 'Hg 'Git))
- (t nil))))
+ ;; handle nested projects (Hg inside Git or vice versa) issue#2723.
+ (project-type (vc-deduce-backend)))
(cl-flet ((push-to-hist (root)
(setq helm-browse-project-history
(cons root (delete root helm-browse-project-history)))))
- (helm-acond ((equal project-type 'Git)
+ (helm-acond ((and (equal project-type 'Git) git-project)
(push-to-hist git-project)
(helm-ls-git))
- ((equal project-type 'Hg)
+ ((and (equal project-type 'Hg) hg-project)
(push-to-hist hg-project)
(helm-hg-find-files-in-project))
((helm-browse-project-get--root-dir (helm-current-directory))
… ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
You can view, comment on, or merge this pull request online at:
#2732
Commit Summary
• cf2b03f helm-browse-project: improve detecting project vc backend
File Changes
(1 file)
• M helm-files.el (29)
Patch Links:
• https://github.com/emacs-helm/helm/pull/2732.patch
• https://github.com/emacs-helm/helm/pull/2732.diff
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.*Message ID: ***@***.***>
--
Thierry
|
Merged with some modifications fixing issues mentioned above, also the last commit is not needed IMO I removed it. |
Closing now. |
@thierryvolpiatto: Thanks for integrating this PR! Just a confirmation that this PR needs the setting By default, |
Hi,
This is an improvement on the previous code that I wrote to detect VC backend in a Git/Hg nested scenario.
I just discovered that the
vc
package can do the job well, and can be extended to other VC tools.