[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/urgrep 83e62357da 018/115: Provide a friendly default v
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/urgrep 83e62357da 018/115: Provide a friendly default value when searching |
|
Date: |
Wed, 10 May 2023 03:00:39 -0400 (EDT) |
branch: externals/urgrep
commit 83e62357da9fc2aa44622999fc9b0a4896d37f10
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
Provide a friendly default value when searching
---
urgrep.el | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/urgrep.el b/urgrep.el
index 98f3d03516..a149fa8907 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -138,9 +138,9 @@
(tool-vc-backend (urgrep-get-property tool 'vc-backend)))
;; Cache the VC backend name if we need it.
(when-let (((and tool-vc-backend (not vc-backend-name)))
- (curr-proj (project-current)))
+ (proj (project-current)))
(setq vc-backend-name
- (vc-responsible-backend (project-root curr-proj))))
+ (vc-responsible-backend (project-root proj))))
(when (and (executable-find tool-executable t)
(or (not tool-vc-backend)
(string= vc-backend-name tool-vc-backend)))
@@ -396,13 +396,24 @@ This function is called from `compilation-filter-hook'."
;; Minibuffer configuration
-(defun urgrep--search-prompt ()
+(defun urgrep--search-default ()
+ "Return the default thing to search for.
+If the region is active, return that. Otherwise, return the symbol at point."
+ (if (use-region-p)
+ (buffer-substring-no-properties (region-beginning) (region-end))
+ (when-let ((symbol (symbol-at-point)))
+ (substring-no-properties (symbol-name symbol)))))
+
+(defun urgrep--search-prompt (default)
"Return the prompt to use when asking for the search query.
-This depends on the current values of various urgrep options."
+This depends on the current values of various urgrep options. DEFAULT indicates
+the default query, if any."
(concat "Search "
(if urgrep-search-regexp "regexp" "string")
(when (> urgrep-context-lines 0)
(format " -C%d" urgrep-context-lines))
+ (when default
+ (format " (default %s)" default))
": "))
(defun urgrep--update-search-prompt ()
@@ -414,9 +425,10 @@ This depends on the current values of various urgrep
options."
(match (text-property-search-forward 'field t t))
(begin (prop-match-beginning match))
(end (prop-match-end match))
- (props (text-properties-at begin)))
+ (props (text-properties-at begin))
+ (prompt (urgrep--search-prompt urgrep--search-default)))
(delete-region begin end)
- (insert (apply #'propertize (urgrep--search-prompt) props))))
+ (insert (apply #'propertize prompt props))))
;; Fix up the point if it ends up in the prompt; this can happen if the point
;; was at the beginning of the editable text.
(if (< (point) (minibuffer-prompt-end)) (goto-char (minibuffer-prompt-end))))
@@ -458,9 +470,13 @@ Return a list that can be passed to `urgrep-command' to
turn into a shell
command."
(let* ((urgrep-search-regexp regexp)
(urgrep-context-lines context)
- (query (read-from-minibuffer (urgrep--search-prompt) nil
- urgrep-minibuffer-map nil
- 'urgrep-search-history)))
+ (default (urgrep--search-default))
+ (prompt (urgrep--search-prompt default))
+ (query (minibuffer-with-setup-hook
+ (lambda () (setq-local urgrep--search-default default))
+ (read-from-minibuffer prompt nil urgrep-minibuffer-map nil
+ 'urgrep-search-history default)))
+ (query (if (equal query "") default query)))
(list query :group urgrep-group-matches :regexp urgrep-search-regexp
:context urgrep-context-lines)))
- [elpa] externals/urgrep ff96211f26 058/115: Update comment, (continued)
- [elpa] externals/urgrep ff96211f26 058/115: Update comment, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep d93a565190 060/115: Simplify implementation of 'urgrep', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 0270e11849 072/115: Allow directory for `urgrep' and `urgrep-run-command' to be relative, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 86e7055ce5 063/115: Typo, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 5aabe4ffa9 066/115: Remove debug code, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 7fd67f1db5 092/115: Run CI against Emacs 28.2, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 2ef7daa448 093/115: Reorganize tests a bit, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 500c01092d 086/115: Fix display override for null character in context lines, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 229ae0bfb5 110/115: Use a version identifier compatible with 'version-to-string', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 6aefc895bc 113/115: Set system-type to gnu/linux when making the Urgrep command for Eshell, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 83e62357da 018/115: Provide a friendly default value when searching,
ELPA Syncer <=
- [elpa] externals/urgrep 98e20f0630 021/115: Use pcase macros for filling in optional arguments, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep bf24dac2ac 025/115: Allow for separate before/after contexts, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep f2ba643f35 028/115: Typo, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep c26ff9b22b 029/115: Add note about grep issues on MS Windows, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 6f50ef99d3 032/115: Remove urgrep--to-command, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 3599ad1a56 033/115: Update comment, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep ba2b01b91b 042/115: Remove no-longer-needed `post-arguments', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 3643c933c4 055/115: Add support for ugrep, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 0de93bfdb9 068/115: Fix use of wgrep on long urgrep results, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e2e8898ab2 074/115: Update copyright, ELPA Syncer, 2023/05/10