-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ripgrep in semantic-symref-tool-grep #7
Conversation
* lisp/finder.el (finder-compile-keywords): Now that 'version' is set for more files, it is no longer necessary to check that we have a version when picking the file from which to take the description. Doing so caused built-in packages (where the version is known) to have their package description taken from the last .el file that matched the file name pattern, usually the last source file in the sub-directory. This bug was introduced in July 2019 and first released in Emacs 27.1. Thanks to Michael Albinus for reviewing this patch.
* lisp/calendar/timeclock.el (timeclock--previous-workday): New variable. (timeclock-find-discrep): Use it to flush values when timeclock-workday changes (bug#50216). (timeclock-mode-line-display): Mention `timeclock-workday' setting in doc string.
* lisp/follow.el (follow-recenter): Make `C-c . C-l' work in windows before the middle one, too (bug#50220). Copyright-paperwork-exempt: yes
* lisp/userlock.el (userlock--check-content-unchanged): Make the assertion more robust -- we may be called here from a different contexts if `query-about-changed-file' is nil.
* lisp/progmodes/python.el (python-shell-interpreter): Note what to do when using ipython3 (bug#44732).
* doc/emacs/fixit.texi (Spelling): Replace mentions of flyspell-use-mouse-3-for-menu with context-menu-mode. * lisp/mouse.el (context-menu-map): Use the function from the text property context-menu-function at mouse click event. * lisp/textmodes/flyspell.el (flyspell--set-use-mouse-3-for-menu): Remove function. (flyspell-use-mouse-3-for-menu): Remove defcustom added recently in 28.1. (flyspell-context-menu): New function. (flyspell-mode): Don't call flyspell--set-use-mouse-3-for-menu. (flyspell-mode-on): Replace flyspell-use-mouse-3-for-menu with context-menu-mode. (make-flyspell-overlay): When context-menu-mode is non-nil, put overlay context-menu-function with flyspell-context-menu instead of using keymap flyspell-mouse-map.
* lisp/emacs-lisp/comp.el (comp-run-async-workers): Forward `comp-file-preloaded-p' to async workers.
* lisp/newcomment.el (uncomment-region-default-1): Make all-whitespace `comment-continue' work (bug#50226). Copyright-paperwork-exempt: yes
* lisp/eshell/esh-cmd.el (eshell-eval-command): Make asynchronous `eshell-command' work (e.g. `M-x eshell-command RET sleep 10 &') (bug#50209).
* lisp/emacs-lisp/nadvice.el (advice--make-docstring): Put the advice things at the end of the documentation (bug#50222). It's important to have the first line of the original documentation remain the first line, because it's used when doing one-line summaries of the function.
* lisp/simple.el (command-completion-using-modes-p): Fix completion over commands that are defined for multiple modes (bug#50228).
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-init-header): Don't overly truncate headers that are before a right-aligned column (bug#44594). (tabulated-list--available-space): Separated out into own function... (tabulated-list-print-col): ... from here.
* lisp/eshell/em-cmpl.el (eshell-complete-parse-arguments): Expand "..." (bug#19626).
* lisp/progmodes/sh-script.el (sh-smie--default-backward-token): Fix indentation of continuation lines (bug#44592).
* lisp/vc/vc-git.el (vc-git-rename-file): Don't use vc-git--literal-pathspecs.
* lisp/progmodes/flymake.el (flymake--mode-line-title): Bind [mode-line down-mouse-3] to flymake-menu (bug#50067)
* test/lisp/vc/vc-tests.el (vc-test--rename-file): New function. (vc-test-%s05-rename-file): New family of tests (bug#39452).
…#23586) * src/nsfns.m (Fx_create_frame): Enable the app. * src/nsterm.m (ns_delete_terminal): Disable the app.
* doc/lispref/eval.texi (Eval): Mention that 'values' is obsolete. * etc/NEWS: Add a rationale for obsoleting 'values'.
* lib-src/Makefile.in (ns_applibexecdir): New variable.
* lisp/progmodes/cc-engine.el (c-looking-at-or-maybe-in-bracelist): early in function, check alternatively for c-back-over-compound-identifier when doing c-backward-token-2. * bracelist-36.{cc,res}: New test files.
* lib-src/seccomp-filter.c (export_filter): Remove use of nonstandard macro TEMP_FAILURE_RETRY.
* lisp/progmodes/sh-script.el (sh-smie--default-backward-token): Allow more parentheses in a token (bug#44592).
* lisp/comint.el (comint-osc-directory-tracker, comint-osc-handlers): Define and register a handler for OSC 7. (comint-osc-process-output): Do fewer checks on 'comint-last-output-start'.
* configure.ac: * test/infra/Dockerfile.emba: * test/infra/gitlab-ci.yml: Fix mentions of --with-nativecomp (bug#50255).
* doc/emacs/custom.texi (Init Syntax): Mention set-variable (bug#50248). (Init Examples): Add an example.
* lisp/progmodes/xref.el: (xref--show-xref-buffer): Fix support for xref-auto-jump-to-first-xref.
* test/lisp/net/tramp-tests.el (tramp--test--deftest-direct-async-process): Fix macro declaration. (tramp-test29-start-file-process, tramp-test30-make-process): Do not run connection type test for direct async processes.
* lisp/textmodes/ispell.el (ispell-init-process): When Ispell initialization reports an error, call 'ispell-accept-output' only if the Ispell process is still alive. (Bug#50370) Copyright-paperwork-exempt: yes
* lisp/progmodes/python.el (python-shell-send-string): use a temporary file for sufficiently long strings. (python-shell-send-file, python-shell-eval-file-setup-code): Avoid showing "plumbing code" in the traceback (bug#32042).
* doc/emacs/maintaining.texi (Looking Up Identifiers): * etc/NEWS: Document the new Xref user options. Move a lost Xref-related entry to the rest of them.
* lisp/progmodes/xref.el (xref-auto-jump-to-first-definition) (xref-auto-jump-to-first-xref, xref-search-program): Fix defcustoms.
* etc/NEWS: Clarify completion-list-mode entry (bug#50394).
* lisp/subr.el (read-char-choice-use-read-key): Explain the difference. (read-char-choice): Mention the variables. (y-or-n-p-use-read-key): Explain the difference. (y-or-n-p): Mention the variable (bug#50390).
* lisp/emacs-lisp/cl-macs.el (cl-struct-slot-info): Autoload (bug#50301). * test/lisp/emacs-lisp/memory-report-tests.el: Don't require cl-macs.
* test/lisp/vc/vc-tests.el (vc-test--version-diff): Fix Git backend when running in clean environment. (vc-test-git06-version-diff): Unskip on Hydra.
tags 49836 + patch
So here is the complete support for rigrep in grep.el: |
I think we can improve this part: On 03.08.2021 11:10, Juri Linkov wrote:
It might be cleaner to see whether grep-find-template already includes
I think the original idea (surrounding with \W) is sound: after all, not The problem with the above regexp is that it uses the basic syntax, As long as we're able to ask Grep to search with Extended syntax, we can Something like (replace-regexp-in-string "grep " "grep -E" The new user option can be used too, but I'd probably prefer a more |
Indeed, but such a hack is a temporary measure and can be removed later
I tried to search for 'soap-type-is-array?' in the Emacs tree,
It would be more preferable not to change the existing default logic The new user option is already used in many places in grep.el |
On 05.08.2021 00:23, Juri Linkov wrote:
Did you search through symref, or in console? If the former, it seems $ rg "\bsoap-type-is-array?\b" ChangeLog.2 $ rg "\bsoap-type-is-array?\b" ^^ no matches And $ rg "\bsoap-type-is-array?" has matches, of course.
See above. But also consider what happens if a user sees that Worse than that, any third-party package that uses grep-find-template It's a hard problem: grep.el is not prepared for abstracting like that. Further: seeing xref-search-program-alist, people asked for support for
I'm actually fine with this part.
This can work. Except the comparison should be with "grep", I think: all |
semantic-symref-grep-use-template constructs such command line: "rg ... -e \\bsoap-type-is-array\?\\b" that finds matches.
This difference could be explained in the documentation.
This already happened after trying to customize grep-find-template
Is there a package that can translate between them reliably?
Why not, semantic-symref already supports alternative tools
I'm worried about the case when the user customizes |
On 06.08.2021 03:35, Juri Linkov wrote:
The correct one will probably look like "rg ... -e \\bsoap-type-is-array\\?\\b" (same number of backslashes before '?' as before 'b'), and it won't find E.g., try searching for 'file-name-as-directory?'. Or 'carr?'.
If it comes to that, yes, but it's usually better to fix usability
The problem exists, and has been for a long time: grep.el doesn't Let's try to make sure we don't create bigger problems when fixing it.
For the limited purpose of symref/grep, we could use Note that it actually translates from a (subset of) Emacs regexp to The above function is how one can use Emacs syntax (though only limited I also saw some commits to ELPA yesterday, that show that Consult https://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/?h=externals/consult&id=7bd3e44929d44cf0e17f38e943e9be2bd6014237 Not sure how mature it is (seems still in development), but perhaps we
It's easy enough for Xref, yes. It only has to support one single,
(string-match "\bgrep\b" grep-program) could take care of this. To sum up, I'm all for adding some clutches to symref/grep.el, to As for having grep-program customizable, perhaps we should add some new Or indeed have templates use Extended syntax, and grep-expand-template |
9849c23
to
3684ae1
Compare
Creating a separate bug report from bug#49731 because this is a real problem.
Now grep.el completely supports ripgrep when 'grep-find-template'
is customized to a command line that uses 'rg' such as e.g.
"find -type f -print0 | sort -z | xargs -0 -e
rg -nH --no-heading -j8 --sort path -M 200 --max-columns-preview -e "
But such grep setting breaks the command 'xref-find-references':
Maybe like the existing option 'semantic-symref-grep-shell', e.g.:
(defcustom semantic-symref-grep-program 'grep
"The program to use for regexp search inside files."
:type `(choice
(const :tag "Use Grep" grep)
(const :tag "Use ripgrep" ripgrep)
(symbol :tag "User defined"))
:version "28.1")
But the problem is that for users it's hard to see the connection
between the broken 'xref-find-references' and the need to customize an option
with unrelated name 'semantic-symref-grep'.
A more general solution would be to add to grep.el the same options
that you added to xref:
xref-search-program grep/ripgrep
xref-search-program-alist
'((grep . "xargs -0 grep -snHE -e ")
(ripgrep . "xargs -0 rg -nH --no-messages -g '!*/' -e | sort -t: -k1,1 -k2n,2"))
This means to turn the existing variable 'grep-program' into the user option
as the following patch does.
Also later grep.el could use the value "rg" of 'grep-program'
to create the corresponding grep-find-template in grep-compute-defaults.
But I don't know if it's ok to mention rigrep in grep.el?
Anyway, here is the patch that fixes 'xref-find-references':