You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I sometimes want to pass additional argument to ag. According to the DOCSTRING,
If called with a prefix, prompts for flags to pass to ag.
It works well when my search string contains no shell-quote characters. For example, if I use C-u M-x ag, and search "struct", command args will be prompted in the minibuffer with the point/cursor placed at the end of other args and before the "--" and wait for my input (Here I use <cursor> to indicate the cursor position):
ag command: ag --literal --group --line-number --column --color --color-match 30\;43 --color-path 1\;32 --smart-case --stats <cursor> -- struct .
However, if my search string contains shell-quote characters, the cursor is placed weirdly:
if I use C-u M-x ag, and search "struct kvm":
ag command: ag --literal --group --line-number --column --color --color-match 30\;43 --color-path 1\;32 --smart-case --stats <cursor>-- struct\ kvm .
if there are more shell-quote characters, for example, search "struct kvm {":
ag command: ag --literal --group --line-number --column --color --color-match 30\;43 --color-path 1\;32 --smart-case --stats --<cursor> struct\ kvm\ \{ .
The cursor is placed after the "--"!
If I want to add additional argument, I have to move the cursor back before "--". It seems that the cursor position in the minibuffer is incorrectly calculated.
My guess
In ag/search, the point position is calculated as follows:
However, here command-string is quoted, while string is unquoted. So direct subtraction does not take the backslash into account. In my case, command-string is ag --literal --group ... struct\ kvm\ \{ ., while string is struct kvm {.
Subtracting by 5 is also incorrect after the introduction of the commit bd81d68 since the length after "--" can be arbitrary due to :files.
Other Information
On my machine, the output of ag --version is
ag version 2.2.0
Features:
+jit +lzma +zlib
My Emacs version is 26.1 (Download from emacsformacosx).
I'm using: macOS Mojave 10.14.6.
The text was updated successfully, but these errors were encountered:
I sometimes want to pass additional argument to
ag
. According to theDOCSTRING
,It works well when my search string contains no shell-quote characters. For example, if I use
C-u M-x ag
, and search "struct
", command args will be prompted in the minibuffer with the point/cursor placed at the end of other args and before the "--
" and wait for my input (Here I use<cursor>
to indicate the cursor position):However, if my search string contains shell-quote characters, the cursor is placed weirdly:
C-u M-x ag
, and search "struct kvm
":struct kvm {
":The cursor is placed after the "
--
"!If I want to add additional argument, I have to move the cursor back before "
--
". It seems that the cursor position in the minibuffer is incorrectly calculated.My guess
In
ag/search
, the point position is calculated as follows:ag.el/ag.el
Line 262 in bd81d68
However, here
command-string
is quoted, whilestring
is unquoted. So direct subtraction does not take the backslash into account. In my case,command-string
isag --literal --group ... struct\ kvm\ \{ .
, whilestring
isstruct kvm {
.Subtracting by 5 is also incorrect after the introduction of the commit bd81d68 since the length after "
--
" can be arbitrary due to:files
.Other Information
On my machine, the output of
ag --version
isMy Emacs version is
26.1
(Download from emacsformacosx).I'm using:
macOS Mojave 10.14.6
.The text was updated successfully, but these errors were encountered: