[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/mheerdegen-preview 3c43b86 08/33: WIP: New command 'el-se
From: |
Michael Heerdegen |
Subject: |
[elpa] scratch/mheerdegen-preview 3c43b86 08/33: WIP: New command 'el-search-repository' |
Date: |
Wed, 24 Oct 2018 18:30:47 -0400 (EDT) |
branch: scratch/mheerdegen-preview
commit 3c43b860fd7bec053dd49ab1dac0e83db10964bb
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
WIP: New command 'el-search-repository'
---
packages/el-search/el-search.el | 50 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index efb9033..bfab694 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -3514,6 +3514,56 @@ related user options."
(lambda (search) (setf (alist-get 'description (el-search-object-properties
search))
"el-search-ibuffer-marked-files"))))
+(declare-function vc-read-revision 'vc)
+(declare-function vc-find-revision 'vc)
+(defun el-search-repository (repo revision pattern &optional file-regexp)
+ ;; FIXME: this is a stub. Occur to-match-jumping doesn't work.
+ ;; Currently only works with git. Slow.
+ (interactive (let* ((repo (let ((this-vc-root-dir (vc-root-dir)))
+ (expand-file-name
+ (read-directory-name "Repository root: "
+ this-vc-root-dir
this-vc-root-dir 'mustmatch))))
+ (result (list repo
+ (read-string "Revision (leave empty for
\"worktree\"): ")
+ (read-string "File regexp: ")
+ (el-search-read-pattern-for-interactive
"Search pattern: "))))
+ (cl-rotatef (nth 2 result) (nth 3 result))
+ result))
+ (let ((just-worktree (or (not revision) (string= revision ""))))
+ (el-search-setup-search
+ pattern
+ (lambda ()
+ (let* ((default-directory repo)
+ (files (seq-filter
+ #'el-search--elisp-file-p
+ (seq-filter
+ (if file-regexp
+ (lambda (fn) (string-match-p file-regexp fn))
+ #'el-search-true)
+ (mapcar #'expand-file-name
+ (split-string
+ (shell-command-to-string
+ (if just-worktree
+ "git ls-files -z --recurse-submodules"
+ (format "git ls-tree --name-only -z -r %s
--"
+ (shell-quote-argument revision))))
+ "\0" t))))))
+ (seq-map (lambda (filename)
+ (let ((default-directory repo))
+ (if just-worktree
+ filename
+ (with-current-buffer
+ (let ((inhibit-message t))
+ (vc-find-revision filename revision))
+ (setq-local el-search--temp-buffer-flag t)
+ (add-hook 'kill-buffer-hook
+ (lambda ()
+ (when (file-exists-p buffer-file-name)
+ (delete-file buffer-file-name)))
+ 'append 'local)
+ (current-buffer)))))
+ (stream files)))))))
+
;;;; Register usage
(defun el-search-to-register (register &optional el-search-object)
- [elpa] branch scratch/mheerdegen-preview created (now 0d07bb8), Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview a006107 02/33: WIP: Add diverse "sloppy" pattern types, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 0107628 04/33: WIP: New package "gnus-article-notes", Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview efe4f41 01/33: WIP: [el-search] Fix nested match issues in *El Occur*, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 3c43b86 08/33: WIP: New command 'el-search-repository',
Michael Heerdegen <=
- [elpa] scratch/mheerdegen-preview c88c4c1 27/33: WIP: Include leading comments in occur defun context, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 3f656ab 11/33: WIP [el-search] Add quick help command, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 2d15aa7 22/33: WIP: [el-search] Fine tune separator for splicing replace, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 9cfe823 32/33: WIP: [el-search] Enhance doc of el-search-occur-mode, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview d774bfe 24/33: WIP: Test: Make mouse clicks not abort the search, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 1020ca9 16/33: WIP: Optimize caching, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview fadf6f9 05/33: WIP: New :key arg for "filename" and new pattern types "file" and "dir", Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 1fcb333 03/33: WIP: Add package "sscell", Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview 35be4f8 12/33: WIP [el-search] Fix more "redundant _ pattern" cases, Michael Heerdegen, 2018/10/24
- [elpa] scratch/mheerdegen-preview fa8dbb8 07/33: WIP: New file el-search/el-search-pp.el, Michael Heerdegen, 2018/10/24