From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#55016: 28.1; xref-find-references finds no matches if project dir contains a space Date: Sun, 24 Apr 2022 05:00:09 +0300 Message-ID: <873e04ab-0e7c-c750-21ff-320c84c9b64e@yandex.ru> References: <83o80xv944.fsf@gnu.org> <8335i9ug94.fsf@gnu.org> <831qxtuee8.fsf@gnu.org> <83zgkhszhp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37920"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Cc: 55016@debbugs.gnu.org, spepo.42@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 24 04:01:12 2022 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 1niRYl-0009kR-UR for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Apr 2022 04:01:12 +0200 Original-Received: from localhost ([::1]:60444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niRYk-0000iy-FY for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 22:01:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niRYc-0000ip-F2 for bug-gnu-emacs@gnu.org; Sat, 23 Apr 2022 22:01:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niRYb-0003Op-SW for bug-gnu-emacs@gnu.org; Sat, 23 Apr 2022 22:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1niRYb-0005td-Lk for bug-gnu-emacs@gnu.org; Sat, 23 Apr 2022 22:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Apr 2022 02:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55016 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 55016-submit@debbugs.gnu.org id=B55016.165076561922606 (code B ref 55016); Sun, 24 Apr 2022 02:01:01 +0000 Original-Received: (at 55016) by debbugs.gnu.org; 24 Apr 2022 02:00:19 +0000 Original-Received: from localhost ([127.0.0.1]:57475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1niRXv-0005sY-Cc for submit@debbugs.gnu.org; Sat, 23 Apr 2022 22:00:19 -0400 Original-Received: from mail-wm1-f48.google.com ([209.85.128.48]:39556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1niRXt-0005sF-R8 for 55016@debbugs.gnu.org; Sat, 23 Apr 2022 22:00:18 -0400 Original-Received: by mail-wm1-f48.google.com with SMTP id ay11-20020a05600c1e0b00b0038eb92fa965so10380888wmb.4 for <55016@debbugs.gnu.org>; Sat, 23 Apr 2022 19:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=/NESL/+tPWPWySlHbBqnDjFcSjDmBJZ4kPsSVyXO4wo=; b=Vwd3kqOtWeWDSDFz0L5DJoWXOiZPEDh2CIIuGppuJv0OCcI3SYKe7EIPtoQj/9VD2z 5Y4VU8qhqnXtI0TiL+rUn1I/zptbOyjnv8M8T2cHc9fJJwqI/gfIomCRiAkdH5StFNIW nFtmXpz02hr3bUPqcsoYKTzz2oL5Fp4Aidg+SqEazERDBc8x1d8r+xYDD4AE8VltcgLz uUdq8rrcNWvEIQQVUgiGjyoZrJeWklBCWMxsuOwsPVqNJSGiDEwjupQ8bU6IBH1zfpfC dJhz4tJvbEiNzy7zZ5Z3xlco2j4eq7hC06Po2oILTFxHQWUR8yin5hgW0Z9X/XmS2Y7t dsog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=/NESL/+tPWPWySlHbBqnDjFcSjDmBJZ4kPsSVyXO4wo=; b=PdxnFKVSOyt8rqUoG4z03/aqcZfcTCizf3ksQgodwXnbe1GlKopMJep/O+P1FWVtfO AxWawFrQ9HzLWei/NRhjstWs2QUvKlot1ZDcNZUkdHNRICzHynIE6UC1d5Nvd7HotzAQ PHJX2HUAwidVROuGopFEdKQ3V3d8DCT1uXgiWcwiPyQbS1K9PGj/4pWNdbCiNd8ifb7S plRte+GSdq8sSeUX8w94akx++Xtzb1vlgxEh8us1ceaeuQkFAHg2ZcRjdHuAeFlMQm3e oQfovox3NcwAOlHOYNpDeVpvD+igcurHkkRCh+NdGuf++agcldt8MXmQR9UW+MpXbfVz 0gyw== X-Gm-Message-State: AOAM532rFHyRgkCUsyPjqDYaXWJx+Mpdk6RmwQ2fVu+VP2ipJDlqo9IG TA1w7EIDM5pQd56vOxqiGZ8= X-Google-Smtp-Source: ABdhPJy3uSCRcaYrvdYMZMYcJmA47mcNDD4EoGKvB/Wm4lbxdsiZnclnzHEROG9yS2QC6vGv1JiORQ== X-Received: by 2002:a7b:ce04:0:b0:38c:6c34:9aac with SMTP id m4-20020a7bce04000000b0038c6c349aacmr10306544wmc.142.1650765611820; Sat, 23 Apr 2022 19:00:11 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id c11-20020a05600c0a4b00b0037c91e085ddsm10092969wmq.40.2022.04.23.19.00.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Apr 2022 19:00:11 -0700 (PDT) Content-Language: en-US In-Reply-To: <83zgkhszhp.fsf@gnu.org> 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:230527 Archived-At: Hi Eli, Sorry for the slow reply. On 19.04.2022 21:24, Eli Zaretskii wrote: > Dmitry, there's something here I don't understand. In > semantic-symref-perform-search method that uses find/grep, we do this: > > (with-current-buffer b > (erase-buffer) > (setq default-directory rootdir) > (let ((cmd (semantic-symref-grep-use-template > (directory-file-name (file-local-name rootdir)) > filepattern grepflags greppat))) > (process-file semantic-symref-grep-shell nil b nil > shell-command-switch cmd))) > > Since we bind default-directory to ROOTDIR, why do we also need to > pass ROOTDIR to semantic-symref-grep-use-template? Why not use ".", > or even nil (which gets expanded to "." AFAIU)? Then this entire > issue with embedded blanks in ROOTDIR would not have happened, because > the problematic directory name would not be exposed to the shell. > > What am I missing here? This approach dates back to before CEDET was added. But I imagine the logic was similar to what I used in: xref-matches-in-directory that it's easier to handle absolute file names which Grep outputs this way, rather that concatenate them later. Nowadays, though, that function has come full circle with in 71f8b55f46a, for various reasons, including macOS having a very old version of 'find'. Note that we fixed this particular bug in ab3ba912fc7. symref/grep.el doesn't use ignore instructions, though, so it can easily use either approach. Due to how semantic-symref-* defmethods are currently structured, though, the current xref-matches-in-directory's approach seems like more of a pain: semantic-symref-parse-tool-output-one-line cannot use lexical context from semantic-symref-perform-search (where we would bind a local-dir variable once to subsequently use when parsing every line). A dynamic var seems to work, though. With we could avoid having to use 'substring'. That should lead to a little less consing. No idea how, though. (Should this also use 'file-name-unquote'?) diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index 27ea80fc32..025faf1042 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -139,6 +139,8 @@ semantic-symref-grep--quote-grep (lambda (s) (concat "\\" s)) string nil t)) +(defvar semantic-symref-grep-local-dir nil) + (cl-defmethod semantic-symref-perform-search ((tool semantic-symref-tool-grep)) "Perform a search with Grep." ;; Grep doesn't support some types of searches. @@ -170,11 +172,12 @@ semantic-symref-perform-search (erase-buffer) (setq default-directory rootdir) (let ((cmd (semantic-symref-grep-use-template - (directory-file-name (file-local-name rootdir)) + "." filepattern grepflags greppat))) (process-file semantic-symref-grep-shell nil b nil shell-command-switch cmd))) - (setq ans (semantic-symref-parse-tool-output tool b)) + (let ((semantic-symref-grep-local-dir (directory-file-name (file-local-name rootdir)))) + (setq ans (semantic-symref-parse-tool-output tool b))) ;; Return the answer ans)) @@ -190,12 +193,12 @@ semantic-symref-parse-tool-output-one-line ((eq (oref tool resulttype) 'line-and-text) (when (re-search-forward grep-re nil t) (list (string-to-number (match-string line-group)) - (match-string file-group) + (concat semantic-symref-grep-local-dir (substring (match-string file-group) 1)) (buffer-substring-no-properties (point) (line-end-position))))) (t (when (re-search-forward grep-re nil t) (cons (string-to-number (match-string line-group)) - (match-string file-group)) + (concat semantic-symref-grep-local-dir (substring (match-string file-group) 1))) ))))) (provide 'semantic/symref/grep)