From: Dmitry Gutov <dgutov@yandex.ru>
To: Juri Linkov <juri@linkov.net>
Cc: 47012@debbugs.gnu.org
Subject: bug#47012: xref copies keymap properties to minibuffer
Date: Mon, 5 Apr 2021 05:15:52 +0300 [thread overview]
Message-ID: <4d56dcd9-9beb-1bf9-eceb-be9a6eda31c4@yandex.ru> (raw)
In-Reply-To: <87mtudbrvd.fsf@mail.linkov.net>
On 05.04.2021 01:55, Juri Linkov wrote:
>>> This is the simplest implementation:
>>> #+begin_src emacs-lisp
>>> (defun project-find-word (regexp)
>>> "Word-based version of ‘project-find-regexp’.
>>> Modifies the ‘xref-search-program-alist’ template
>>> to add the option ‘-w’ that matches whole words."
>>> (interactive (list (project--read-regexp)))
>>> (let ((xref-search-program-alist
>>> (mapcar (lambda (p)
>>> (cons (car p) (replace-regexp-in-string "<C>" "-w \\&" (cdr p))))
>>> xref-search-program-alist)))
>>> (project-find-regexp regexp)))
>>> #+end_src
>>
>> Wouldn't it work the same if you instead modify the regexp to be surrounded
>> with \b...\b?
>
> Indeed, with more typing.
I meant that your project-find-word would do that to the regexp, instead
of trying to alter the template.
> Ideally, there should be an isearch command
> that will send the constructed regexp to 'project-find-regexp' from
> isearch word-mode, symbol-mode like:
>
> #+begin_src emacs-lisp
> (define-key isearch-mode-map "\C-xpg" 'isearch-project-find-regexp)
>
> (defun isearch-project-find-regexp ()
> (interactive)
> (let ((isearch-recursive-edit nil))
> (isearch-done nil t)
> (isearch-clean-overlays))
> (let ((regexp (cond ((functionp isearch-regexp-function)
> (funcall isearch-regexp-function isearch-string))
> (isearch-regexp-function (word-search-regexp isearch-string))
> (isearch-regexp isearch-string)
> (t (regexp-quote isearch-string)))))
> (project-find-regexp regexp))
> (and isearch-recursive-edit (exit-recursive-edit)))
> #+end_src
>
> But unfortunately it fails on ripgrep with:
>
> Search failed with status 123: regex parse error
>
> Maybe because ripgrep can't swallow Emacs regexps.
That's right: it doesn't understand constructs like "\\<ChangeLog\\>".
I've been meaning to experiment with removing Emacs-specific
instructions from the regexp, using the result in a search, and then
postprocessing with "correct" regexp later, but still haven't gotten
around to that.
FIXME in xref--regexp-to-extended is somewhat related.
prev parent reply other threads:[~2021-04-05 2:15 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-08 20:03 bug#47012: xref copies keymap properties to minibuffer Juri Linkov
2021-03-09 2:08 ` Dmitry Gutov
2021-03-11 20:58 ` Juri Linkov
2021-03-24 20:38 ` Juri Linkov
2021-03-24 21:57 ` Dmitry Gutov
2021-03-25 9:40 ` Juri Linkov
2021-03-25 10:57 ` Dmitry Gutov
2021-03-25 21:28 ` Juri Linkov
2021-03-25 22:12 ` Dmitry Gutov
2021-03-30 19:16 ` Juri Linkov
2021-03-31 15:47 ` Dmitry Gutov
2021-03-31 15:59 ` Eli Zaretskii
2021-03-31 16:10 ` Dmitry Gutov
2021-03-31 16:57 ` Eli Zaretskii
2021-04-01 0:25 ` Dmitry Gutov
2021-04-01 7:17 ` Eli Zaretskii
2021-03-31 17:05 ` Juri Linkov
2021-04-01 1:16 ` Dmitry Gutov
2021-04-01 8:43 ` Juri Linkov
2021-04-01 14:13 ` Dmitry Gutov
2021-04-01 18:45 ` Juri Linkov
2021-04-01 19:06 ` Eli Zaretskii
2021-04-01 21:28 ` Dmitry Gutov
2021-04-02 6:08 ` Eli Zaretskii
2021-04-02 23:50 ` Dmitry Gutov
2021-04-03 7:24 ` Eli Zaretskii
2021-04-03 18:12 ` Dmitry Gutov
2021-04-03 18:19 ` Eli Zaretskii
2021-04-02 8:20 ` Juri Linkov
2021-04-01 22:43 ` Dmitry Gutov
2021-04-02 8:25 ` Juri Linkov
2021-04-02 23:23 ` Dmitry Gutov
2021-04-04 22:55 ` Juri Linkov
2021-04-05 2:15 ` Dmitry Gutov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4d56dcd9-9beb-1bf9-eceb-be9a6eda31c4@yandex.ru \
--to=dgutov@yandex.ru \
--cc=47012@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.