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).
This commit is contained in:
Lars Ingebrigtsen 2022-08-25 17:02:34 +02:00
parent ec4f976e8e
commit 681f2e23ae

View file

@ -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)