From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: lux Newsgroups: gmane.emacs.bugs Subject: bug#60562: [PATCH] Fix split-string error if there is a space in the filename. Date: Sun, 8 Jan 2023 15:23:45 +0800 Message-ID: References: <87zgawgfic.fsf@gmail.com> <834jt2u1yh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/8BhM+VOZivfUP=Q6VtLghpG" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21730"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60562@debbugs.gnu.org, eliz@gnu.org, rpluim@gmail.com To: Ruijie Yu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 08 08:25:14 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 1pEQ3N-0005Sv-TG for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Jan 2023 08:25:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEQ3E-0002O7-IV; Sun, 08 Jan 2023 02:25: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 1pEQ3D-0002Nq-By for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2023 02:25:03 -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 1pEQ3C-0006jW-UV for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2023 02:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pEQ3C-00071N-QN for bug-gnu-emacs@gnu.org; Sun, 08 Jan 2023 02:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: lux Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Jan 2023 07:25: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 60562-submit@debbugs.gnu.org id=B60562.167316264226894 (code B ref 60562); Sun, 08 Jan 2023 07:25:02 +0000 Original-Received: (at 60562) by debbugs.gnu.org; 8 Jan 2023 07:24:02 +0000 Original-Received: from localhost ([127.0.0.1]:59756 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEQ2D-0006zR-CP for submit@debbugs.gnu.org; Sun, 08 Jan 2023 02:24:02 -0500 Original-Received: from out203-205-221-205.mail.qq.com ([203.205.221.205]:46270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEQ29-0006z4-Oi for 60562@debbugs.gnu.org; Sun, 08 Jan 2023 02:24:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1673162629; bh=sUBUkX/DQ/ky3tY5Vh7p/N5xHD7JppNa4zs96Ut1Vqw=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=JLDPUbOS4Bi79FUQMYj/7nxRwxLYUMrRj5eIyUhoq4IFnProxTJ3AUUqexk1RCaRW eA9nJrhenddwq5LxAyQzoZXxnfyfm8otEX8sZF/cAIzh4Opk4qUDXc9HrO5UwY2USN Vb3mddaKZz8/ZvS/6ww59GJmVWlmcu3hZfWWCaL0= Original-Received: from lx-pc ([240e:399:e6f:ee32:f815:4044:ba50:97f9]) by newxmesmtplogicsvrszc2-0.qq.com (NewEsmtp) with SMTP id 5EF856FB; Sun, 08 Jan 2023 15:23:47 +0800 X-QQ-mid: xmsmtpt1673162627t8uq7aam1 X-QQ-XMAILINFO: OZZSS56D9fAjqgqMF1y5atxGIQYyAJ6CH/ORt5UdLS7M1eaR/cmMWTuWJNWG/+ ChC0DsrzITDiKkfqrUEiZhh9JlSjJPQ/3Y5GcGBTppcRKw6v96TD6CZgH0hvYQncsUfZtcJ8XHAw 8tAfz+FuAbm8wLvL/oNw8JvCw+EdzaU3A0+c+69khgoOYzUYpjxPNXyF0wVq5Lve30plnzzQSPoj pGkev5Z2WD/id8mpSh5hrjHsreQHRHKGlXuqzaHVNUttKyOKOy+pMPGwcbOJCH+k3Q0iOZqSgZE7 i24ZwJyZYVtdju3kbvUfhASD2mfth6UrYBxQGq9VBiAOY62bLeHqy/P4KjNzmqTQ9xn2vowxk+ga WbsjhRP1LR8PUEHkb2xZHAZoqaH0C4rhNRQ0qEyu/Vrvy4x53Z3QwW6tkSmDerqS5ehoSHvJO9KT +ptTp/LsBlBYe2ONxzEL5lFB61Ryz11VD9joR0qSju1F1izD58rF/0FvkoOoAZrGMNWpk4glx286 5do2VfsJNOpEx6fyAqjD/3ZNkIJ1qqMYOZgHVN9CdPOgq1bOe01RHDrlxERIysrdzcUrt7FYbW5g f5Rrut2RZYi32+iqIrJjzaY75V11s/jQe77MvI/+EPb3CpM4GDH5BFB2sCKVjhxltLYwYFPCayH1 GxeNHZSu5R39XDcdTzEY/TgOJnlbqnfwwnwFe6P3CqUdbDZqXjrYI9bxApBCP5WRjjg8hDGG1d5Y jSj+Eox+ABbLmtfzs5HIwYXT6SWUtx3OTeFpCQlOmhhArWLt6af9FxLU99RplIkWl9NOMcg0ug4x rHzyyPRXTdyZ7vwb3yDzFHqoZ1oC9LQYU446OfcI X-OQ-MSGID: <20230108152345.619ff2fe@lx-pc> In-Reply-To: X-Mailer: Claws Mail 4.1.1 (GTK 3.24.36; x86_64-redhat-linux-gnu) 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:252876 Archived-At: --MP_/8BhM+VOZivfUP=Q6VtLghpG Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline 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. --MP_/8BhM+VOZivfUP=Q6VtLghpG Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Replace-hfy-find-cmd-with-directory-files-recursivel.patch >From 58fcb50eae760a6565e1703dfb8cea46a4ee5843 Mon Sep 17 00:00:00 2001 From: Xi Lu Date: Sat, 7 Jan 2023 22:46:40 +0800 Subject: [PATCH] Replace `hfy-find-cmd' with `directory-files-recursively'. --- lisp/htmlfontify.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el index c989a12d205..f05bc4e1e35 100644 --- a/lisp/htmlfontify.el +++ b/lisp/htmlfontify.el @@ -372,11 +372,14 @@ hfy-istext-command :tag "istext-command" :type '(string)) -(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)) (defcustom hfy-display-class nil "Display class to use to determine which display class to use when @@ -1826,8 +1829,12 @@ hfy-list-files ;;(message "hfy-list-files");;DBUG ;; 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))) ) + (cl-remove-if (lambda (f) + (or (null (file-regular-p f)) + (seq-some (lambda (r) + (string-match r f)) + hfy-exclude-file-rules))) + (directory-files-recursively "." ".*" nil t))) ;; strip the filename off, return a directory name ;; not a particularly thorough implementation, but it will be -- 2.39.0 --MP_/8BhM+VOZivfUP=Q6VtLghpG--