[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 681f2e23ae 2/2: Add a new user option grep-command-position
From: |
Lars Ingebrigtsen |
Subject: |
master 681f2e23ae 2/2: Add a new user option grep-command-position |
Date: |
Thu, 25 Aug 2022 11:03:20 -0400 (EDT) |
branch: master
commit 681f2e23ae3a07decf1a459c982ee7940986cff4
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add a new user option grep-command-position
* lisp/progmodes/grep.el (grep-command): Mention it.
(grep-command-position): New user option.
(grep): Use it (bug#50502).
---
lisp/progmodes/grep.el | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 4c1f801980..d64beaefcf 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -126,11 +126,20 @@ include it when specifying `grep-command'.
In interactive usage, the actual value of this variable is set up
by `grep-compute-defaults'; to change the default value, use
-\\[customize] or call the function `grep-apply-setting'."
+\\[customize] or call the function `grep-apply-setting'.
+
+Also see `grep-command-position'."
:type '(choice string
(const :tag "Not Set" nil))
:set #'grep-apply-setting)
+(defcustom grep-command-position nil
+ "Where point will be put when prompting for a grep command.
+If nil, put point at the end. If not nil, this should be the
+column number where point should be set in `grep-command'."
+ :type '(choice (const :tag "At the end" nil)
+ natnum))
+
(defcustom grep-template nil
"The default command to run for \\[lgrep].
The following place holders should be present in the string:
@@ -931,10 +940,15 @@ list is empty)."
(progn
(grep-compute-defaults)
(let ((default (grep-default-command)))
- (list (read-shell-command "Run grep (like this): "
- (if current-prefix-arg default grep-command)
- 'grep-history
- (if current-prefix-arg nil default))))))
+ (list (read-shell-command
+ "Run grep (like this): "
+ (if current-prefix-arg
+ default
+ (if grep-command-position
+ (cons grep-command grep-command-position)
+ grep-command))
+ 'grep-history
+ (if current-prefix-arg nil default))))))
;; If called non-interactively, also compute the defaults if we
;; haven't already.
(when (eq grep-highlight-matches 'auto-detect)