[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult 12b8df7: Extract consult--grep-position
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult 12b8df7: Extract consult--grep-position |
Date: |
Sat, 7 Aug 2021 08:57:13 -0400 (EDT) |
branch: externals/consult
commit 12b8df7e94974c82c5839bd8f8b6199184e61965
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Extract consult--grep-position
---
consult.el | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/consult.el b/consult.el
index 0e9860e..c7d5423 100644
--- a/consult.el
+++ b/consult.el
@@ -4038,6 +4038,19 @@ BUILDER is the command argument builder."
(funcall async result)))
(t (funcall async action))))))
+(defun consult--grep-position (cand &optional find-file)
+ "Return the grep position marker for CAND.
+FIND-FILE is the file open function, defaulting to `find-file'."
+ (save-match-data
+ (when (and cand (string-match consult--grep-match-regexp cand))
+ (let ((file (match-string 1 cand))
+ (line (string-to-number (match-string 2 cand)))
+ (col (next-single-property-change (match-end 0) 'face cand)))
+ (setq col (if col (- col (match-end 0)) 0))
+ (consult--position-marker
+ (funcall (or find-file #'find-file) file)
+ line col)))))
+
(defun consult--grep-state ()
"Grep preview state function."
(let ((open (consult--temporary-files))
@@ -4045,16 +4058,9 @@ BUILDER is the command argument builder."
(lambda (cand restore)
(when restore
(funcall open))
- (funcall
- jump
- (save-match-data
- (when (and cand (string-match consult--grep-match-regexp cand))
- (let ((file (match-string 1 cand))
- (line (string-to-number (match-string 2 cand)))
- (col (next-single-property-change (match-end 0) 'face cand)))
- (setq col (if col (- col (match-end 0)) 0))
- (consult--position-marker (funcall (if restore #'find-file open)
file) line col))))
- restore))))
+ (funcall jump
+ (consult--grep-position cand (and (not restore) open))
+ restore))))
(defun consult--grep-group (cand transform)
"Return title for CAND or TRANSFORM the candidate."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/consult 12b8df7: Extract consult--grep-position,
ELPA Syncer <=