From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#60562: [PATCH] Fix split-string error if there is a space in the filename. Date: Sat, 14 Jan 2023 11:12:05 +0200 Message-ID: <838ri58opm.fsf@gnu.org> References: <87zgawgfic.fsf@gmail.com> <834jt2u1yh.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24372"; mail-complaints-to="usenet@ciao.gmane.io" Cc: ruijie@netyu.xyz, 60562-done@debbugs.gnu.org, rpluim@gmail.com To: lux Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 14 10:13:19 2023 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 1pGcbH-0006Da-5s for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Jan 2023 10:13:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGcb2-0002s0-Fw; Sat, 14 Jan 2023 04:13:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGcb0-0002rR-TR for bug-gnu-emacs@gnu.org; Sat, 14 Jan 2023 04:13:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pGcb0-0007J9-LH for bug-gnu-emacs@gnu.org; Sat, 14 Jan 2023 04:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pGcb0-0004sZ-Cj for bug-gnu-emacs@gnu.org; Sat, 14 Jan 2023 04:13:02 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Jan 2023 09:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 60562 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 60562@debbugs.gnu.org, eliz@gnu.org, lx@shellcodes.org Original-Received: via spool by 60562-done@debbugs.gnu.org id=D60562.167368753218693 (code D ref 60562); Sat, 14 Jan 2023 09:13:02 +0000 Original-Received: (at 60562-done) by debbugs.gnu.org; 14 Jan 2023 09:12:12 +0000 Original-Received: from localhost ([127.0.0.1]:53366 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGcaC-0004rQ-4j for submit@debbugs.gnu.org; Sat, 14 Jan 2023 04:12:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGca9-0004rC-2A for 60562-done@debbugs.gnu.org; Sat, 14 Jan 2023 04:12:10 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGca3-0007Bl-HR; Sat, 14 Jan 2023 04:12:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=THDV0o788KO5UTWqreZpgZoSZrO1ywkzmfCGiNTZB3E=; b=h9aflflV3UJV n51zUoFqm9DiOHHd4A6FR7058fNs9kODJYcAQra6fAOMFPBvW0z2AOV1pU+tXlkXgv7yAfs0RjM0A 5Rr4XNS7Q1ZapsZksJQaIW/4MOVNTbL1+gdwS+IIH4PPnQrscdBwLg4Fx2HB9d854poVHiKPYGBOO iA1hJfg/hR2apzwlPfW4qKARRr7k5nCaLIYjefVZ7NY7hmW6Fy5HFmxXECvyP5ogSMupDb0CXvvYr WQzrc3w4+Ozlv3ICfZqd9zNB4nJxlvqsQ+MaeLbcQZQOF5GzVjE61q8/CzxOJkJQUx8Jlkt78Hkq6 /9rTT624fMTj711scABHFQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGca2-0007rh-SY; Sat, 14 Jan 2023 04:12:03 -0500 In-Reply-To: (message from lux on Sun, 8 Jan 2023 15:23:45 +0800) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253343 Archived-At: > Date: Sun, 8 Jan 2023 15:23:45 +0800 > From: lux > Cc: Eli Zaretskii , 60562@debbugs.gnu.org, Robert Pluim > , bug-gnu-emacs@gnu.org > > On Sat, 07 Jan 2023 17:00:02 -0600 > Ruijie Yu wrote: > > > Hi, > > > > >-(defcustom hfy-find-cmd > > >- "find . -type f \\! -name \\*~ \\! -name \\*.flc \\! -path > > >\\*/CVS/\\*" > > >- "Find command used to harvest a list of files to attempt to > > >fontify." > > >- :tag "find-command" > > >- :type '(string)) > > >+(defcustom hfy-exclude-file-rules > > >+ '("\\.flc$" > > >+ "/CVS/.*" > > >+ ".*~" > > >+ "\\.git/.*") > > >+ "Define some regular expressions to exclude files" > > >+ :tag "exclude-rules" > > >+ :type '(list string)) > > > > For the third entry, shouldn't it be ".*~$" instead, to indicate that > > "~" is the last character? > > > > For the fourth entry, currently it would match against the file name > > "ROOT/hello.git/foo". In addition, for git submodules, ".git" is a > > regular file instead of a directory. Maybe something like this is > > what you want: > > > > (rx "/.git" (opt "/" (0+ any)) line-end) > > > > or in raw regexp: "/\\.git\\(?:/.*\\)?$" > > > > Also, in this change, we are dropping the requirement that the found > > file are actually files, whereas we used to say "-type f". Is this > > change fine? > > > > > (defun hfy-list-files (directory) > > > "Return a list of files under DIRECTORY. > > > Strips any leading \"./\" from each filename." > > >- ;;(message "hfy-list-files");;DBUG > > >+ ;;(message "hfy-list-files");;DEBUG > > > ;; FIXME: this changes the dir of the current buffer. Is that > > > right?? (cd directory) > > >- (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) > > >(match-string 1 F) F)) > > >- (split-string (shell-command-to-string hfy-find-cmd))) ) > > >+ (remove-if (lambda (f) (seq-some (lambda (r) > > >+ (string-match r f)) > > >hfy-exclude-file-rules)) > > >+ (directory-files-recursively "." ".*"))) > > > > We should change `remove-if' into `cl-remove-if' because both "cl.el" > > and the alias `remove-if' are deprecated. > > > > Thank you, I updated the patch file. Thanks, installed on the emacs-29 branch, and closing the bug.