From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60562: [PATCH] Fix split-string error if there is a space in the filename. Date: Sat, 07 Jan 2023 17:00:02 -0600 Message-ID: References: <87zgawgfic.fsf@gmail.com> <834jt2u1yh.fsf@gnu.org> Reply-To: Ruijie Yu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28698"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.13; emacs 29.0.60 Cc: 60562@debbugs.gnu.org, eliz@gnu.org, rpluim@gmail.com To: lux Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 08 00:16:29 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 1pEIQP-0007Kq-KK for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Jan 2023 00:16:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEIQ5-0005aV-Ha; Sat, 07 Jan 2023 18:16:09 -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 1pEIPy-0005Xe-Nt for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 18:16: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 1pEIPy-0002Xx-Cf for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 18:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pEIPy-0001Q4-8H for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 18:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ruijie Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Jan 2023 23:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60562 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-Cc: 60562@debbugs.gnu.org, Eli Zaretskii , bug-gnu-emacs@gnu.org, Robert Pluim Original-Received: via spool by submit@debbugs.gnu.org id=B.16731333271506 (code B ref -1); Sat, 07 Jan 2023 23:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Jan 2023 23:15:27 +0000 Original-Received: from localhost ([127.0.0.1]:59234 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIPP-0000Ng-0F for submit@debbugs.gnu.org; Sat, 07 Jan 2023 18:15:27 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:49268) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIPN-0000I9-4f for submit@debbugs.gnu.org; Sat, 07 Jan 2023 18:15:25 -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 1pEIPH-0005Ny-Rb for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 18:15:24 -0500 Original-Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEIPG-0001wa-1t; Sat, 07 Jan 2023 18:15:19 -0500 Original-Received: from fw.net.yu.netyu.xyz (99-87-204-218.lightspeed.irvnca.sbcglobal.net [99.87.204.218]) by netyu.xyz (OpenSMTPD) with ESMTPSA id e8e243e6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 7 Jan 2023 23:15:12 +0000 (UTC) In-reply-to: Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FROM_SUSPICIOUS_NTLD=0.499, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:252841 Archived-At: 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. Best, RY