From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#47012: xref copies keymap properties to minibuffer Date: Fri, 02 Apr 2021 11:25:59 +0300 Organization: LINKOV.NET Message-ID: <87lfa1nvkn.fsf@mail.linkov.net> References: <87czw9tnu9.fsf@mail.linkov.net> <3aad442a-7319-5db5-2fc6-560bb032c34d@yandex.ru> <87a6r9v24b.fsf@mail.linkov.net> <87sg4kb839.fsf@mail.linkov.net> <871rc3bls6.fsf@mail.linkov.net> <871rc2ly7x.fsf@mail.linkov.net> <4228b128-039c-2bcd-002c-5ac830d7a4d3@yandex.ru> <87pmzgtr80.fsf@mail.linkov.net> <186b46fa-3716-a76d-db85-09638d7805c7@yandex.ru> <87v99745jj.fsf@mail.linkov.net> <87zgyiv03f.fsf@mail.linkov.net> <4d3edf81-97d8-4e0e-51c0-7b2d71b57889@yandex.ru> <87o8exsv1p.fsf@mail.linkov.net> <2da88387-25ad-c615-922d-718e1b7a49d1@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2656"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 47012@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 02 10:29:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lSFB0-0000b5-7W for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Apr 2021 10:29:10 +0200 Original-Received: from localhost ([::1]:59238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSFAz-00029j-6m for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Apr 2021 04:29:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSFAs-00029K-RX for bug-gnu-emacs@gnu.org; Fri, 02 Apr 2021 04:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lSFAs-0003j9-K1 for bug-gnu-emacs@gnu.org; Fri, 02 Apr 2021 04:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lSFAs-0007kq-Gn for bug-gnu-emacs@gnu.org; Fri, 02 Apr 2021 04:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Apr 2021 08:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47012 X-GNU-PR-Package: emacs Original-Received: via spool by 47012-submit@debbugs.gnu.org id=B47012.161735208229716 (code B ref 47012); Fri, 02 Apr 2021 08:29:02 +0000 Original-Received: (at 47012) by debbugs.gnu.org; 2 Apr 2021 08:28:02 +0000 Original-Received: from localhost ([127.0.0.1]:59134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lSF9t-0007j8-Pu for submit@debbugs.gnu.org; Fri, 02 Apr 2021 04:28:02 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:57131) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lSF9s-0007it-3i for 47012@debbugs.gnu.org; Fri, 02 Apr 2021 04:28:00 -0400 X-Originating-IP: 91.129.107.223 Original-Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id C6598E0003; Fri, 2 Apr 2021 08:27:52 +0000 (UTC) In-Reply-To: <2da88387-25ad-c615-922d-718e1b7a49d1@yandex.ru> (Dmitry Gutov's message of "Fri, 2 Apr 2021 01:43:24 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203465 Archived-At: >>>>> Please try (setq xref-file-name-display 'project-relative). >>>> Thanks, I didn't know about this. Shouldn't this be the default value >>>> since this is what's displayed by grep and ripgrep. >>> >>> I wouldn't mind, personally. >> This is added to the patch below too. > > LGTM. Pushed now. >> What is the real problem for me is that after navigating to >> a project's subdirectory (with e.g. dired) and typing 'C-u C-x p g', >> it doesn't provide the current directory as the default value. >> It inserts the project root by default, not its subdirectory: >> Base directory: /project/root/ >> whereas 'M-x rgrep' conveniently provides default-directory as default. > > Makes sense, fixed in 4798dc0c51, please check it out. Thanks, now it's more handy. >> BTW, is it possible to make 'project-find-regexp' more compatible with 'rgrep' >> in other features too? What is missing is a way to modify the constructed >> command line. For example, often I need to add "-w" to the constructed command >> to match words only. In 'C-u M-x rgrep', this is easy to do, >> but not in 'C-u C-x p g'. > > That's not so easy to do: the exact command is concealed inside the helper > function in another package (xref). I suppose it's possible to rearrange > things such that command creation and its execution are two different > phases, but TBH I wouldn't love the result. Though I agree it might > be handy. 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 "" "-w \\&" (cdr p)))) xref-search-program-alist))) (project-find-regexp regexp))) #+end_src It has one minor issue: while it correctly filters out lines without word matches, when a line with a word match contains also the same string that is not a complete word, then both are highlighted as matches. There is no such problem in grep where matches are highlighted by the grep program itself. BTW, the above implementation was based on a similar command for rgrep: #+begin_src emacs-lisp (defun wrgrep () "Word-based version of ‘rgrep’. Modifies the grep-find template to add the option ‘-w’ that matches whole words." (interactive) (let ((grep-host-defaults-alist nil) (grep-find-template (replace-regexp-in-string "" "-w \\&" grep-find-template))) (call-interactively 'rgrep))) #+end_src > What I've been thinking we should have instead, is some kind of graphical > prompt with multiple fields, where you can by default input the regexp and > press RET, but you can also see the other options (like the file name glob > to filter by, whether to search the "external roots" or not, whether to > search only a particular directory, whether to ignore case, whether to > search in the project-ignored files as well; options which modify the > regexp or matching logic like your -w could be added too). > > Note that several of the options enumerated above are not something we > could expose in the "edit the command" interface, because the command gets > the list of files from stdin. > > Maybe it would be presented like one-line prompt where you can reach > further fields using TAB, and maybe expand into some multiline pane (still > inside the minibuffer) if some options can't fit on the same line, and you > reach the end of that line by TAB-bing. > > To sum up, if we managed to create some visual interface for specifying the > options that project-find-regexp has control over, maybe it would both > result in a less complex interaction between packages, as well as in a more > powerful UI which more people will be happy with. Sounds like a widget-based form-filling with fields. Actually, such fields already exist in xref-search-program-alist template with placeholders , , , , that are expanded by grep-expand-template.