From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 11 16:13:13 2010 Received: (at submit) by debbugs.gnu.org; 11 Nov 2010 21:13:14 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PGeSG-00061w-Dv for submit@debbugs.gnu.org; Thu, 11 Nov 2010 16:13:13 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PGeQm-00060Z-9P for submit@debbugs.gnu.org; Thu, 11 Nov 2010 16:11:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGeVN-0007H3-S5 for submit@debbugs.gnu.org; Thu, 11 Nov 2010 16:16:27 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,MAY_BE_FORGED autolearn=no version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:41118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGeVN-0007Gp-CE for submit@debbugs.gnu.org; Thu, 11 Nov 2010 16:16:25 -0500 Received: from [140.186.70.92] (port=37346 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGeVK-0005xS-RR for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2010 16:16:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGeVI-0007G5-Gw for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2010 16:16:22 -0500 Received: from host29.netdorm.com ([64.182.105.29]:56054 helo=mxout.netdorm.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGeVI-0007C0-9P for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2010 16:16:20 -0500 Received: from mail.dnsexit.com (mail.dnsexit.com [67.214.171.75] (may be forged)) by mxout.netdorm.com (8.13.8/8.13.8) with ESMTP id oABKqbuU032273 for ; Thu, 11 Nov 2010 15:52:37 -0500 Received: from cspcnh.swan.ac.uk (cspcnh.swan.ac.uk [137.44.6.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.dnsexit.com (Postfix) with ESMTP id 34224B7D3A8 for ; Thu, 11 Nov 2010 15:51:06 -0500 (EST) Received: from cspcnh.swan.ac.uk.greenrd.org (exherbo.local [127.0.0.1]) by cspcnh.swan.ac.uk (8.14.4/8.14.4) with ESMTP id oABKlaBR011766 for ; Thu, 11 Nov 2010 20:47:36 GMT Date: Thu, 11 Nov 2010 20:47:36 +0000 Message-ID: <87fwv7a8pj.wl%greenrd@greenrd.org> From: Robin Green To: bug-gnu-emacs@gnu.org Subject: 23.2; grep buffer misinterprets result if filename contains colon character User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.2 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: Swansea University MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 11 Nov 2010 16:13:11 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English if possible, because the Emacs maintainers usually do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. Please describe exactly what actions triggered the bug and the precise symptoms of the bug. If you can, give a recipe starting from `emacs -Q': I did M-x rgrep and searched for a string which happened to be matched by some files, and one of the filenames happened to contain a colon character (':'). Emacs thought that the colon character indicated a line number would immediately follow, and it syntax highlighted the buffer accordingly. When I tried to visit the file in question by navigating to that line and pressing Enter, emacs asked me for which file to visit, because it had truncated the filename at the colon character. If Emacs crashed, and you have the Emacs process in the gdb debugger, please include the output from the following gdb commands: `bt full' and `xbacktrace'. For information about debugging Emacs, please read the file /usr/share/emacs/23.2/etc/DEBUG. In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.20.1) of 2010-05-22 on cspcnh.swan.ac.uk Windowing system distributor `The X.Org Foundation', version 11.0.10900000 configured using `configure '--prefix=/usr' '--host=i686-pc-linux-gnu' '--build=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--docdir=/usr/share/doc/emacs-23.2' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--disable-dependency-tracking' '--disable-silent-rules' '--enable-fast-install' '--libdir=/usr/lib' '--infodir=/usr/share/info/emacs' '--without-kerberos' '--without-kerberos5' '--without-hesiod' '--without-m17n-flt' '--without-xim' '--with-x' '--without-sound' '--with-xft' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' '--without-libotf' '--with-rsvg' '--without-dbus' '--with-gif' '--without-gpm' '--with-jpeg' '--with-png' '--without-tiff' '--with-xpm' '--without-gconf' 'build_alias=i686-pc-linux-gnu' 'host_alias=i686-pc-linux-gnu' 'CC=i686-pc-linux-gnu-gcc' 'CFLAGS=-march=native -pipe -O2' 'CPP=cpp'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_GB.utf8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Grep Minor modes in effect: erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-match-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-netsplit-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t shell-dirtrack-mode: t diff-auto-refine-mode: t show-paren-mode: t tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent input: i t ? t h a t SPC f i l e ? SPC h w y ? w h y ? s S o SPC w h a t SPC i s SPC t h e SPC " r i g h t SPC w a y " SPC t o SPC m a k e SPC a SPC w r a p p e r SPC s c r i p t ? S-SPC J u s t SPC u s e SPC h e r e b i n ? C-x b n c - 4 x - 4 M-x r g r e p h e r e b i n * . e x * M-x r g r e p h e r e b i n * . e x * C-k / v a r / d b / p a l r e C-x C-f / s c c C-g C-g M-x r e p o r t - e m Recent messages: Checking "%inbox" is done Checking "%inbox" Checking "%inbox" is done Checking "%inbox" Checking "%inbox" is done Making completion list... [2 times] Grep exited abnormally with code 123 Grep finished (matches found) Quit Mark set Quit Load-path shadows: /usr/share/emacs/site-lisp/coq hides /usr/share/emacs/site-lisp/ProofGeneral/coq/coq /usr/share/emacs/site-lisp/coq-syntax hides /usr/share/emacs/site-lisp/ProofGeneral/coq/coq-syntax /usr/share/emacs/site-lisp/coq-db hides /usr/share/emacs/site-lisp/ProofGeneral/coq/coq-db /usr/share/emacs/site-lisp/semi/pgg-gpg hides /usr/share/emacs/23.2/lisp/pgg-gpg /usr/share/emacs/site-lisp/flim/hex-util hides /usr/share/emacs/23.2/lisp/hex-util /usr/share/emacs/site-lisp/semi/pgg-parse hides /usr/share/emacs/23.2/lisp/pgg-parse /usr/share/emacs/site-lisp/semi/pgg-pgp5 hides /usr/share/emacs/23.2/lisp/pgg-pgp5 /usr/share/emacs/site-lisp/flim/md4 hides /usr/share/emacs/23.2/lisp/md4 /usr/share/emacs/site-lisp/flim/sha1 hides /usr/share/emacs/23.2/lisp/sha1 /usr/share/emacs/site-lisp/semi/pgg hides /usr/share/emacs/23.2/lisp/pgg /usr/share/emacs/site-lisp/semi/pgg-def hides /usr/share/emacs/23.2/lisp/pgg-def /usr/share/emacs/site-lisp/semi/pgg-pgp hides /usr/share/emacs/23.2/lisp/pgg-pgp /usr/share/emacs/site-lisp/flim/hmac-def hides /usr/share/emacs/23.2/lisp/net/hmac-def /usr/share/emacs/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/23.2/lisp/net/sasl-ntlm /usr/share/emacs/site-lisp/flim/hmac-md5 hides /usr/share/emacs/23.2/lisp/net/hmac-md5 /usr/share/emacs/site-lisp/flim/sasl-cram hides /usr/share/emacs/23.2/lisp/net/sasl-cram /usr/share/emacs/site-lisp/flim/sasl hides /usr/share/emacs/23.2/lisp/net/sasl /usr/share/emacs/site-lisp/flim/ntlm hides /usr/share/emacs/23.2/lisp/net/ntlm /usr/share/emacs/site-lisp/flim/sasl-digest hides /usr/share/emacs/23.2/lisp/net/sasl-digest /usr/share/emacs/site-lisp/wl/rfc2368 hides /usr/share/emacs/23.2/lisp/mail/rfc2368 /usr/share/emacs/site-lisp/wl/utf7 hides /usr/share/emacs/23.2/lisp/gnus/utf7 /usr/share/emacs/site-lisp/semi/smime hides /usr/share/emacs/23.2/lisp/gnus/smime Features: (shadow emacsbug erc-menu erc-join erc-ring erc-networks erc-pcomplete erc-track erc-match erc-button erc-fill erc-stamp erc-netsplit erc-goodies erc erc-backend erc-compat format-spec find-dired grep compile help-mode ansi-color shell comint smtp sasl sasl-anonymous sasl-login sasl-plain pcomplete vc-git info cus-edit wid-edit multi-isearch tabify man view dired-x dired-aux dired wl-score elmo-internal mule-util mel-q-ccl elmo-nntp elmo-imap4 time-stamp elmo-net elmo-dop elmo-cache elmo-map modb-standard wl-mime mime-edit pgg-parse pccl pccl-20 ccl signature mail-utils mime-setup mail-mime-setup semi-setup mime-pgp pgg-def mime-play filename mime-image wl-demo wl-draft eword-encode wl-template sendmail wl-news derived wl-address wl-thread wl-action wl-summary ps-print ps-def lpr wl-refile wl-message elmo-mime mmelmo-buffer mmelmo-imap mime-view mime-conf calist semi-def mmimap mime-parse mmbuffer mmgeneric wl-highlight elmo-multi wl-folder wl wl-e21 wl-util pp elmo-flag elmo-localdir wl-vars epg-config wl-version elmo elmo-signal elmo-msgdb modb modb-generic modb-entity mime elmo-util emu invisible inv-19 poem poem-e20 poem-e20_3 utf7 eword-decode mel mime-def alist std11 mcharset mcs-20 mcs-e20 pces pces-e20 pces-20 broken pcustom elmo-date path-util elmo-vars poe elmo-version pym static apel-ver product luna avoid magit-topgit cl cl-19 magit-svn magit diff-mode log-edit pcvs-util add-log magit-key-mode assoc windmove emacsd-tile edmacro kmacro winner ring server remember org-remember org-datetree org byte-opt bytecomp byte-compile advice help-fns advice-preload org-footnote org-src org-list org-faces org-compat org-macs easymenu time-date noutline outline easy-mmode paren cus-start cus-load site-exherbo eclectic-mode exheres-mode exheres-mode-keywords skeleton sh-script executable cmake-mode thingatpt bbdb-autoloads bbdb regexp-opt timezone proof-site proof-autoloads pg-vars tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process font-render-setting gtk x-toolkit x multi-tty emacs) From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 12 11:37:47 2010 Received: (at 7378) by debbugs.gnu.org; 12 Nov 2010 16:37:47 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PGwdH-00075K-6B for submit@debbugs.gnu.org; Fri, 12 Nov 2010 11:37:47 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PGwdF-00075F-1U for 7378@debbugs.gnu.org; Fri, 12 Nov 2010 11:37:45 -0500 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id oACGgMRX005360; Fri, 12 Nov 2010 11:42:26 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 426F96630D; Thu, 11 Nov 2010 18:09:38 -0500 (EST) From: Stefan Monnier To: Robin Green Subject: Re: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character Message-ID: References: <87fwv7a8pj.wl%greenrd@greenrd.org> Date: Thu, 11 Nov 2010 18:09:38 -0500 In-Reply-To: <87fwv7a8pj.wl%greenrd@greenrd.org> (Robin Green's message of "Thu, 11 Nov 2010 20:47:36 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Score: 0.5 X-NAI-Spam-Rules: 2 Rules triggered DATE_IN_PAST_12_24=0.5, RV3676=0 X-NAI-Spam-Level: X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 7378 Cc: 7378@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.5 (-) > I did M-x rgrep and searched for a string which happened to be matched > by some files, and one of the filenames happened to contain a colon > character (':'). Emacs thought that the colon character indicated > a line number would immediately follow, and it syntax highlighted the > buffer accordingly. When I tried to visit the file in question by > navigating to that line and pressing Enter, emacs asked me for which > file to visit, because it had truncated the filename at the > colon character. AFAIK we do try to figure out what was meant, even though in general grep's output is simply ambiguous when the file name has colons. So, could you give the exact file name you used, so we can try and figure out whether it's a bug in the current heuristic, or it's a hopeless case (it's just too ambiguous), or it's a case that's simply not yet handled. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 13 04:39:26 2010 Received: (at 7378) by debbugs.gnu.org; 13 Nov 2010 09:39:27 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PHCZy-0007ZH-D0 for submit@debbugs.gnu.org; Sat, 13 Nov 2010 04:39:26 -0500 Received: from [67.214.171.75] (helo=mail.dnsexit.com) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PHCZw-0007ZC-D4 for 7378@debbugs.gnu.org; Sat, 13 Nov 2010 04:39:24 -0500 Received: from cspcnh.swan.ac.uk (cspcnh.swan.ac.uk [137.44.6.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.dnsexit.com (Postfix) with ESMTP id 7FF1C8B5D22; Sat, 13 Nov 2010 04:43:19 -0500 (EST) Received: from cspcnh.swan.ac.uk.greenrd.org (exherbo.local [127.0.0.1]) by cspcnh.swan.ac.uk (8.14.4/8.14.4) with ESMTP id oAD9dfau009952; Sat, 13 Nov 2010 09:39:42 GMT Date: Sat, 13 Nov 2010 09:39:41 +0000 Message-ID: <877hgha7fm.wl%greenrd@greenrd.org> From: Robin Green To: Stefan Monnier Subject: Re: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character In-Reply-To: References: <87fwv7a8pj.wl%greenrd@greenrd.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.2 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: Swansea University MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: 7378 Cc: 7378@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.9 (---) At Thu, 11 Nov 2010 18:09:38 -0500, Stefan Monnier wrote: > AFAIK we do try to figure out what was meant, even though in general > grep's output is simply ambiguous when the file name has colons. > > So, could you give the exact file name you used ./installed/data/x11-libs---nx/3.4.0:0:C.30253.1289557929.792611.C/nx-3.4.0.exheres-0 Thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 15 11:24:28 2010 Received: (at 7378) by debbugs.gnu.org; 15 Nov 2010 16:24:28 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PI1r2-0000jd-11 for submit@debbugs.gnu.org; Mon, 15 Nov 2010 11:24:28 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PI1qz-0000jY-DJ for 7378@debbugs.gnu.org; Mon, 15 Nov 2010 11:24:26 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0GANbu4ExFpY76/2dsb2JhbAChWn5yvlSFSgSEWo1f X-IronPort-AV: E=Sophos;i="4.59,200,1288584000"; d="scan'208";a="82590901" Received: from 69-165-142-250.dsl.teksavvy.com (HELO pastel.home) ([69.165.142.250]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 15 Nov 2010 11:29:22 -0500 Received: by pastel.home (Postfix, from userid 20848) id D1814A8263; Mon, 15 Nov 2010 11:29:21 -0500 (EST) From: Stefan Monnier To: Robin Green Subject: Re: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character Message-ID: References: <87fwv7a8pj.wl%greenrd@greenrd.org> <877hgha7fm.wl%greenrd@greenrd.org> Date: Mon, 15 Nov 2010 11:29:21 -0500 In-Reply-To: <877hgha7fm.wl%greenrd@greenrd.org> (Robin Green's message of "Sat, 13 Nov 2010 09:39:41 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 7378 Cc: 7378@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) >> AFAIK we do try to figure out what was meant, even though in general >> grep's output is simply ambiguous when the file name has colons. >> So, could you give the exact file name you used > ./installed/data/x11-libs---nx/3.4.0:0:C.30253.1289557929.792611.C/nx-3.4.0.exheres-0 I guess strictly speaking it's not ambiguous since grep normally starts counting from 1, so the ":0:" cannot actually be the line number (e.g. the patch below could help). But I also expect that among your file names, the ":0:" is just an accident and it could just as well be ":5:" instead, in which case greps' output will be *really* ambiguous. I.e. to resolve this kind of ambiguity, grep-mode would have to check all the possible interpretations and see which ones lead to an existing file name. Such a change would require a good bit more work on grep. Furthermore such ambiguity would need to be resolved not only when the ":N:" comes from the file name but also when it comes from the file's content. Stefan === modified file 'lisp/progmodes/grep.el' --- lisp/progmodes/grep.el 2010-05-21 20:43:04 +0000 +++ lisp/progmodes/grep.el 2010-11-15 16:28:07 +0000 @@ -348,7 +348,11 @@ ;; produces them ;; ("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2\\(?:\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\)?\\2\\)?" ;; 1 3 (4 . 5)) - ("^\\(\\(.+?\\):\\([0-9]+\\):\\).*?\ + ;; Note that we want to use as tight a regexp as we can to try and + ;; handle weird file names (with colons in them) as well as possible. + ;; E.g. we use [1-9][0-9]* rather than [0-9]+ so as to accept ":034:" in + ;; file names. + ("^\\(\\(.+?\\):\\([1-9][0-9]*\\):\\).*?\ \\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)" 2 3 ;; Calculate column positions (beg . end) of first grep match on a line From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 28 18:50:28 2011 Received: (at control) by debbugs.gnu.org; 28 Jan 2011 23:50:29 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Piy5E-0008Mm-2w for submit@debbugs.gnu.org; Fri, 28 Jan 2011 18:50:28 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Piy5B-0008Mb-P3 for control@debbugs.gnu.org; Fri, 28 Jan 2011 18:50:26 -0500 Received: from localhost ([127.0.0.1]:42241) by fencepost.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PiyD5-0004Kp-C7; Fri, 28 Jan 2011 18:58:35 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19779.22571.79126.632840@fencepost.gnu.org> Date: Fri, 28 Jan 2011 18:58:35 -0500 From: Glenn Morris To: control Subject: emacs X-Attribution: GM X-Mailer: VM (www.wonderworks.com/vm), GNU Emacs (www.gnu.org/software/emacs) X-Hue: blue X-Ran: 7RjCPg68\qC=aClx[!"dQ"NlZ}.`KB~=g"b<3zWkG1&Dtj#OGT6>/)"x^|z7(d*tdZ;B31 X-Debbugs-No-Ack: yes X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) merge 6843 7378 From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 07 21:02:30 2011 Received: (at 7378) by debbugs.gnu.org; 8 Sep 2011 01:02:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R1T0e-0002Au-TF for submit@debbugs.gnu.org; Wed, 07 Sep 2011 21:02:29 -0400 Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R1T0b-0002Al-9r for 7378@debbugs.gnu.org; Wed, 07 Sep 2011 21:02:26 -0400 Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id E09606E8065; Wed, 7 Sep 2011 17:58:28 -0700 (PDT) Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id D2555451C44D; Wed, 7 Sep 2011 17:58:27 -0700 (PDT) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character Organization: JURTA References: <87fwv7a8pj.wl%greenrd@greenrd.org> <877hgha7fm.wl%greenrd@greenrd.org> Date: Thu, 08 Sep 2011 02:48:14 +0300 In-Reply-To: (Stefan Monnier's message of "Mon, 15 Nov 2010 11:29:21 -0500") Message-ID: <87obyvkgw9.fsf@mail.jurta.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 7378 Cc: 7378@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > I.e. to resolve this kind of ambiguity, grep-mode would have to check > all the possible interpretations and see which ones lead to an existing > file name. Such a change would require a good bit more work on grep. > Furthermore such ambiguity would need to be resolved not only when > the ":N:" comes from the file name but also when it comes from the > file's content. One more case where highlighting is currently incorrect is grepping mail archives where each mail is located in a separate file with the timestamp in its name like: grep -inH -e "Date: " * 2011-08-31_11:57:03_1:7:Date: Wed, 31 Aug 2011 11:57:03 +0000 2011-08-31_12:08:20_2:7:Date: Wed, 31 Aug 2011 12:08:20 +0000 In the first line "2011-08-31_11" is highlighted as the file name and "57" as the line number. In the second line "2011-08-31_12:08:20_2" is highlighted as the file name (correctly) and "7" as the line number (the difference is because "03" has the leading zero). I see no way to match file names and line numbers correctly with a regexp in such cases. The only way to do this reliably with GNU grep is to ask it to output escape sequences around file names and line numbers. From `man grep': fn=35 SGR substring for file names prefixing any content line. The default is a magenta text foreground over the terminal's default background. ln=32 SGR substring for line numbers prefixing any content line. The default is a green text foreground over the terminal's default background. Then `grep-filter' could find these escape sequences and highlight, and `grep-regexp-alist' could calculate column positions of the highlighted file names and line numbers. Is it worth a try? From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 07 22:56:13 2011 Received: (at 7378) by debbugs.gnu.org; 8 Sep 2011 02:56:14 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R1Umj-00014s-JA for submit@debbugs.gnu.org; Wed, 07 Sep 2011 22:56:13 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R1Umg-00014k-EV for 7378@debbugs.gnu.org; Wed, 07 Sep 2011 22:56:11 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAPcsaE64rwMJ/2dsb2JhbABDp3F5gUYBAQQBViMFCws0EhQYDSSICLdChmsEoCSEQA X-IronPort-AV: E=Sophos;i="4.68,348,1312171200"; d="scan'208";a="135085087" Received: from 184-175-3-9.dsl.teksavvy.com (HELO ceviche.home) ([184.175.3.9]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 07 Sep 2011 22:52:13 -0400 Received: by ceviche.home (Postfix, from userid 20848) id E3C4366246; Wed, 7 Sep 2011 22:52:12 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character Message-ID: References: <87fwv7a8pj.wl%greenrd@greenrd.org> <877hgha7fm.wl%greenrd@greenrd.org> <87obyvkgw9.fsf@mail.jurta.org> Date: Wed, 07 Sep 2011 22:52:12 -0400 In-Reply-To: <87obyvkgw9.fsf@mail.jurta.org> (Juri Linkov's message of "Thu, 08 Sep 2011 02:48:14 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 7378 Cc: 7378@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > The only way to do this reliably with GNU grep is to ask it to output > escape sequences around file names and line numbers. From `man grep': > fn=35 SGR substring for file names prefixing any content line. > The default is a magenta text foreground over the terminal's > default background. > ln=32 SGR substring for line numbers prefixing any content line. > The default is a green text foreground over the terminal's > default background. > Then `grep-filter' could find these escape sequences and highlight, > and `grep-regexp-alist' could calculate column positions of the highlighted > file names and line numbers. > Is it worth a try? Feel free to try, but not for 24.1. And please try and quantify the performance impact (if any), because M-x grep is already too slow. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 28 07:59:27 2017 Received: (at 7378) by debbugs.gnu.org; 28 Jun 2017 11:59:27 +0000 Received: from localhost ([127.0.0.1]:41756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQBd1-0007q2-3P for submit@debbugs.gnu.org; Wed, 28 Jun 2017 07:59:27 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:34714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQBcz-0007pj-07; Wed, 28 Jun 2017 07:59:25 -0400 Received: by mail-io0-f196.google.com with SMTP id m19so5024367ioe.1; Wed, 28 Jun 2017 04:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=QLd8uMlW06ZP9Ok20J/lHBpmDYfIwZeyE49B6xRh0Bg=; b=mUV5JGlVf/W2Cq2nBrt4e05RSDs66q/PVIiSHm7NsE5WRu++hvB5jXUlZtLmsUugGN 0Ef+YcREv33L+VvzXrUdk1PQEuya53x7QEvwUV+7xxlIgiBtImBkJrvrS1pArTl8vHNM penqGq6iP97bNQ++kq2RSTtLnlcbid/iaGytR16iHxd0KfOOYZ4zBB2KBUPudl2JyXmX QWzD9vzscJsPpG32nsi61TwzkGlSYQvmSwt91KEubJqTyqxwu1JvOT4fKdjMz7qkeRCZ RBo8AjvHxEnKVtobKWAx4c8tYcI7IywoVXw3KcyiYWHrJkSAsgoms9oN1ohvzp3bHHJp 0ftw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=QLd8uMlW06ZP9Ok20J/lHBpmDYfIwZeyE49B6xRh0Bg=; b=C4Lp0sx+wpOW8kEOELENqXH6dvayZDI78paQ1mo6O2wLblqKYALhAovM4bt/ZHgZ7v kwWsurxqyy4ZtrHhQNvPqJG/NqW4Mw11/dYq1IeGKcEpbfmQcJt3ZWLaLLQbZ/GZGZQH +phXQdtt3oDM78+5g6/o90vWKyWe+Q8xBsTK/Mhhvl0pCZE0MBvvkyZ1zDWk85gi6aL0 +SWjWO8IgpwZ8ai978NynMqmQvDCf2kygx7TJ/YX/9Ax8cHaozXGpCXO7aUA43Q0MQY+ FBNSjMosfEqMl2O8Pe35wsu/BnGc7G59tXm1ZrP+AGACO1U89aq1BYSmsXp4REdZ2/Cw e06w== X-Gm-Message-State: AKS2vOy4Xah21w2xwsHDCV6ZytBHA5pr3VBC9Ay7cpKV9xl6UfKoto0I i6UZSCWiqBatS1v9 X-Received: by 10.107.16.81 with SMTP id y78mr12004221ioi.105.1498651159259; Wed, 28 Jun 2017 04:59:19 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id b17sm2773935itd.0.2017.06.28.04.59.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Jun 2017 04:59:18 -0700 (PDT) From: npostavs@users.sourceforge.net To: Stefan Monnier Subject: Re: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character References: <87fwv7a8pj.wl%greenrd@greenrd.org> <877hgha7fm.wl%greenrd@greenrd.org> <87obyvkgw9.fsf@mail.jurta.org> Date: Wed, 28 Jun 2017 08:00:53 -0400 In-Reply-To: (Stefan Monnier's message of "Wed, 07 Sep 2011 22:52:12 -0400") Message-ID: <87r2y4midm.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 7378 Cc: Juri Linkov , 7378@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --=-=-= Content-Type: text/plain tags 7378 + patch quit >> The only way to do this reliably with GNU grep is to ask it to output >> escape sequences around file names and line numbers. > Feel free to try, but not for 24.1. And please try and quantify the > performance impact (if any), because M-x grep is already too slow. GNU grep also supports --null to output NUL bytes following file names, I haven't measured but it should be no slower and possibly faster since the regexp is simpler. There is a bit of added complexity to still support other greps which don't have --null: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Use-grep-s-null-option-Bug-6843.patch Content-Description: patch >From 0042aa5616560657e867aa977dad732ab18e30dc Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 13 Sep 2016 20:48:09 -0400 Subject: [PATCH] Use grep's --null option (Bug#6843) * lisp/progmodes/grep.el (grep-use-null-filename-separator): New option. (grep--regexp-alist-column, grep--regexp-alist-bin-matcher) (grep-with-null-regexp-alist, grep-fallback-regexp-alist): New constants, replacing `grep-regexp-alist'. (grep-regex-alist): Mark the variable obsolete, add a new function of the same name to replace it. (grep-compute-defaults): Compute default for `grep-use-null-filename-separator'. (grep-mode): Set compilation-error-regexp-alist (buffer locally) to the value of `grep-with-null-regexp-alist' or `grep-fallback-regexp-alist' according to `grep-use-null-filename-separator'. * lisp/progmodes/xref.el (xref-collect-matches): Call `grep-regex-alist' instead of the obsolete variable. Don't hardcode grep-regexp-alist match groups. --- lisp/progmodes/grep.el | 103 +++++++++++++++++++++++++++++++++++-------------- lisp/progmodes/xref.el | 33 ++++++++-------- 2 files changed, 92 insertions(+), 44 deletions(-) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index b3d8a51cee..a4b85bbbe4 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -47,8 +47,8 @@ (defvar grep-host-defaults-alist nil (defun grep-apply-setting (symbol value) "Set SYMBOL to VALUE, and update `grep-host-defaults-alist'. SYMBOL should be one of `grep-command', `grep-template', -`grep-use-null-device', `grep-find-command', -`grep-find-template', `grep-find-use-xargs', or +`grep-use-null-device', `grep-find-command' `grep-find-template', +`grep-find-use-xargs', `grep-use-null-filename-separator', or `grep-highlight-matches'." (when grep-host-defaults-alist (let* ((host-id @@ -160,6 +160,15 @@ (defcustom grep-use-null-device 'auto-detect :set 'grep-apply-setting :group 'grep) +(defcustom grep-use-null-filename-separator 'auto-detect + "If non-nil, use `grep's `--null' option. +This is done to disambiguate file names in `grep's output." + :type '(choice (const :tag "Do Not Use `--null'" nil) + (const :tag "Use `--null'" t) + (other :tag "Not Set" auto-detect)) + :set 'grep-apply-setting + :group 'grep) + ;;;###autoload (defcustom grep-find-command nil "The default find command for \\[grep-find]. @@ -357,33 +366,53 @@ (defvar grep-last-buffer nil Notice that using \\[next-error] or \\[compile-goto-error] modifies `compilation-last-buffer' rather than `grep-last-buffer'.") -;;;###autoload -(defconst grep-regexp-alist - '( - ;; Use a tight regexp to handle weird file names (with colons +(defconst grep--regexp-alist-column + ;; Calculate column positions (col . end-col) of first grep match on a line + (cons + (lambda () + (when grep-highlight-matches + (let* ((beg (match-end 0)) + (end (save-excursion (goto-char beg) (line-end-position))) + (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face))) + (when mbeg + (- mbeg beg))))) + (lambda () + (when grep-highlight-matches + (let* ((beg (match-end 0)) + (end (save-excursion (goto-char beg) (line-end-position))) + (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face)) + (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end)))) + (when mend + (- mend beg))))))) +(defconst grep--regexp-alist-bin-matcher + '("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) +(defconst grep-with-null-regexp-alist + `(("^\\([^\0]+\\)\\(\0\\)\\([0-9]+\\):" 1 3 ,grep--regexp-alist-column nil nil + (2 '(face unspecified display ":"))) + ,grep--regexp-alist-bin-matcher) + "Regexp used to match grep hits. +See `compilation-error-regexp-alist'.") +(defconst grep-fallback-regexp-alist + `(;; Use a tight regexp to handle weird file names (with colons ;; in them) as well as possible. E.g., use [1-9][0-9]* rather ;; than [0-9]+ so as to accept ":034:" in file names. ("^\\(.*?[^/\n]\\):[ \t]*\\([1-9][0-9]*\\)[ \t]*:" - 1 2 - ;; Calculate column positions (col . end-col) of first grep match on a line - ((lambda () - (when grep-highlight-matches - (let* ((beg (match-end 0)) - (end (save-excursion (goto-char beg) (line-end-position))) - (mbeg (text-property-any beg end 'font-lock-face grep-match-face))) - (when mbeg - (- mbeg beg))))) - . - (lambda () - (when grep-highlight-matches - (let* ((beg (match-end 0)) - (end (save-excursion (goto-char beg) (line-end-position))) - (mbeg (text-property-any beg end 'font-lock-face grep-match-face)) - (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end)))) - (when mend - (- mend beg))))))) - ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) - "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") + 1 2 ,grep--regexp-alist-column) + ,grep--regexp-alist-bin-matcher) + "Regexp used to match grep hits when `--null' is not supported. +See `compilation-error-regexp-alist'.") + +(defvaralias 'grep-regex-alist 'grep-with-null-regexp-alist) +(make-obsolete-variable + 'grep-regex-alist "Call `grep-regexp-alist' instead." "26.1") + +;;;###autoload +(defun grep-regexp-alist () + "Return a regexp alist to match grep hits. +The regexp used depends on `grep-use-null-filename-separator'. +See `compilation-error-regexp-alist' for format details." + (if grep-use-null-filename-separator + grep-with-null-regexp-alist grep-fallback-regexp-alist)) (defvar grep-first-column 0 ; bug#10594 "Value to use for `compilation-first-column' in grep buffers.") @@ -538,6 +567,7 @@ (defun grep-compute-defaults () (grep-use-null-device ,grep-use-null-device) (grep-find-command ,grep-find-command) (grep-find-template ,grep-find-template) + (grep-use-null-filename-separator ,grep-use-null-filename-separator) (grep-find-use-xargs ,grep-find-use-xargs) (grep-highlight-matches ,grep-highlight-matches))))) (let* ((host-id @@ -550,7 +580,8 @@ (defun grep-compute-defaults () ;; computed for every host once. (dolist (setting '(grep-command grep-template grep-use-null-device grep-find-command - grep-find-template grep-find-use-xargs + grep-use-null-filename-separator + grep-find-template grep-find-use-xargs grep-highlight-matches)) (set setting (cadr (or (assq setting host-defaults) @@ -576,6 +607,21 @@ (defun grep-compute-defaults () (concat (regexp-quote hello-file) ":[0-9]+:English"))))))))) + (when (eq grep-use-null-filename-separator 'auto-detect) + (setq grep-use-null-filename-separator + (with-temp-buffer + (let* ((hello-file (expand-file-name "HELLO" data-directory)) + (args `("--null" "-ne" "^English" ,hello-file))) + (if grep-use-null-device + (setq args (append args (list null-device))) + (push "-H" args)) + (and (grep-probe grep-program `(nil t nil ,@args)) + (progn + (goto-char (point-min)) + (looking-at + (concat (regexp-quote hello-file) + "\0[0-9]+:English")))))))) + (when (eq grep-highlight-matches 'auto-detect) (setq grep-highlight-matches (with-temp-buffer @@ -591,6 +637,7 @@ (defun grep-compute-defaults () grep-template grep-find-template) (let ((grep-options (concat (if grep-use-null-device "-n" "-nH") + (if grep-use-null-filename-separator " --null") (if (grep-probe grep-program `(nil nil nil "-e" "foo" ,null-device) nil 1) @@ -733,7 +780,7 @@ (define-compilation-mode grep-mode "Grep" (set (make-local-variable 'compilation-error-face) grep-hit-face) (set (make-local-variable 'compilation-error-regexp-alist) - grep-regexp-alist) + (grep-regexp-alist)) ;; compilation-directory-matcher can't be nil, so we set it to a regexp that ;; can never match. (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`")) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index b8ec50f14a..cc9b794c5a 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -917,20 +917,21 @@ (defun xref-collect-matches (regexp files dir ignores) (grep-compute-defaults) (defvar grep-find-template) (defvar grep-highlight-matches) - (let* ((grep-find-template (replace-regexp-in-string "" " -E" - grep-find-template t t)) - (grep-highlight-matches nil) - ;; TODO: Sanitize the regexp to remove Emacs-specific terms, - ;; so that Grep can search for the "relaxed" version. Can we - ;; do that reliably enough, without creating false negatives? - (command (xref--rgrep-command (xref--regexp-to-extended regexp) - files - (expand-file-name dir) - ignores)) - (buf (get-buffer-create " *xref-grep*")) - (grep-re (caar grep-regexp-alist)) - status - hits) + (pcase-let* + ((grep-find-template (replace-regexp-in-string "" " -E" + grep-find-template t t)) + (grep-highlight-matches nil) + ;; TODO: Sanitize the regexp to remove Emacs-specific terms, + ;; so that Grep can search for the "relaxed" version. Can we + ;; do that reliably enough, without creating false negatives? + (command (xref--rgrep-command (xref--regexp-to-extended regexp) + files + (expand-file-name dir) + ignores)) + (buf (get-buffer-create " *xref-grep*")) + (`(,grep-re ,file-group ,line-group . ,_) (car (grep-regexp-alist))) + (status nil) + (hits nil)) (with-current-buffer buf (erase-buffer) (setq status @@ -944,8 +945,8 @@ (defun xref-collect-matches (regexp files dir ignores) (not (looking-at grep-re))) (user-error "Search failed with status %d: %s" status (buffer-string))) (while (re-search-forward grep-re nil t) - (push (list (string-to-number (match-string 2)) - (match-string 1) + (push (list (string-to-number (match-string line-group)) + (match-string file-group) (buffer-substring-no-properties (point) (line-end-position))) hits))) (xref--convert-hits (nreverse hits) regexp))) -- 2.11.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 19 20:03:19 2017 Received: (at 7378) by debbugs.gnu.org; 20 Jul 2017 00:03:20 +0000 Received: from localhost ([127.0.0.1]:48320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXyw3-0000dx-L7 for submit@debbugs.gnu.org; Wed, 19 Jul 2017 20:03:19 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:35052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXyw1-0000dd-Ag; Wed, 19 Jul 2017 20:03:17 -0400 Received: by mail-it0-f67.google.com with SMTP id v127so989010itd.2; Wed, 19 Jul 2017 17:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ES8QYVKTrMzeHrYBmKI9XHDLTMpXfzxh3lH8wwOcLFw=; b=hlq4+PFqr25P/9xgoPpnJ+qCZiUzj4Lt8PLGYvmeATmWvQj8yRNOIHv1lK6Kwj7jwt pB0FouSjHiktk4HtT+PJqzAQZbx1xTygPAcZq47L/ybBrooCartCNOuzi2oWfPqDrJh9 hJM6bl8NlmRTmdjmWTqn9y+aaVhJIxfgMCyf3WjxYjX80frFtrkYlSatrTmrfNbUgpCY wFgbexfFc/GBslu/dD/amdGExWsFRLS1WP4Vba3ffUkY7UXpzBDv8yUx3fzMUIIekycJ nBTxP6fqDEu0ep32mj7drgMQZ0GQSRVFbEOJsPxKZAVNUguuiiw/OyO+9jqLr907fPu8 PyRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=ES8QYVKTrMzeHrYBmKI9XHDLTMpXfzxh3lH8wwOcLFw=; b=EbkPOmBK24/k6/7vOSYdokbFEXl3LAboTMBDCibcW0YD4wQtFXOH3GhmYqIkt6ki2k kLAPImu+lDUH7+VY67dDUwR7zIefn1W7cuEi+yZAmHs0NEYjFIaDvZ71c2IMWfVsv1iQ bZUODyO7wZJ1EdvgA0z2ReBVY8S6MJVrAtJVYodR8B/l3U6jbXLIFuYt4Knto54SXFKY jPkknw5EvRtco0mIeFT8MWQKW3r/6TuAfsoDhEExqAEtCInRzSTiIUGqUtprGaGQOQIc lYH7bI+EzGAcsa3uauox4s1gRnSsvl5cKxTlGKnS30hmsUaX63GclHR6kByJpV2ufCxj reDw== X-Gm-Message-State: AIVw110MRpOTMdulzXjvClx5PjDhACpFKv85fLjbLTc/Q/i5kjDq/RrP LYoL1lSXalxpEb/O X-Received: by 10.36.207.70 with SMTP id y67mr1641268itf.128.1500508991597; Wed, 19 Jul 2017 17:03:11 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id v65sm537381itc.32.2017.07.19.17.03.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Jul 2017 17:03:10 -0700 (PDT) From: npostavs@users.sourceforge.net To: Stefan Monnier Subject: Re: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character References: <87fwv7a8pj.wl%greenrd@greenrd.org> <877hgha7fm.wl%greenrd@greenrd.org> <87obyvkgw9.fsf@mail.jurta.org> <87r2y4midm.fsf@users.sourceforge.net> Date: Wed, 19 Jul 2017 20:04:45 -0400 In-Reply-To: <87r2y4midm.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Wed, 28 Jun 2017 08:00:53 -0400") Message-ID: <87vamo9dnm.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 7378 Cc: Juri Linkov , 7378@debbugs.gnu.org, 6843@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) tags 7378 fixed close 7378 26.1 quit npostavs@users.sourceforge.net writes: > > GNU grep also supports --null to output NUL bytes following file names, > I haven't measured but it should be no slower and possibly faster since > the regexp is simpler. Pushed to master. [1: 644cdd1aa0]: 2017-07-19 20:03:00 -0400 Use grep's --null option (Bug#6843) http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=644cdd1aa0a10dbfffa3b9b4c7a97f8cddded0b8 From unknown Mon Jun 23 16:45:55 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 30 Aug 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator