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: Sat, 7 Jan 2023 22:52:09 +0800 Message-ID: References: <87zgawgfic.fsf@gmail.com> <834jt2u1yh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/SAsy=Yf0ZIdxGLDjO4bqf2g" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37954"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60562@debbugs.gnu.org, Robert Pluim To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 07 15:53:30 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 1pEAZe-0009gX-93 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Jan 2023 15:53:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEAZD-0000VF-Mr; Sat, 07 Jan 2023 09:53:03 -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 1pEAZC-0000Uj-Pe for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 09:53: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 1pEAZC-0002VZ-HL for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 09:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pEAZC-0004CQ-Ce for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2023 09:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: lux Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Jan 2023 14:53: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 Original-Received: via spool by 60562-submit@debbugs.gnu.org id=B60562.167310314816103 (code B ref 60562); Sat, 07 Jan 2023 14:53:02 +0000 Original-Received: (at 60562) by debbugs.gnu.org; 7 Jan 2023 14:52:28 +0000 Original-Received: from localhost ([127.0.0.1]:56791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEAYe-0004Bd-1l for submit@debbugs.gnu.org; Sat, 07 Jan 2023 09:52:28 -0500 Original-Received: from out203-205-221-210.mail.qq.com ([203.205.221.210]:55829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEAYY-0004BK-Rs for 60562@debbugs.gnu.org; Sat, 07 Jan 2023 09:52:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1673103133; bh=/K6neVocismEeD1PvbfTRcgNqYvpyoqv+vjOooNXuzo=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=rEeYl10Ak/2bzhVmA7VBV2WckJZV4EZA/Eh/4O6Mur/7ScQM4u/sGTm5xMHF9ef0q 7zYQbrG0UrhyeeraWe8soI65R7IsTR/c2PMqOSXrNc/3v5ZUSd8XSGAhE9PJD5r4qp CUxs9+yG7MkyYL3h5NXbe14ZOrZAxxqoO/XkZDpg= Original-Received: from lx-pc ([240e:399:e6f:ee32:f815:4044:ba50:97f9]) by newxmesmtplogicsvrszc2-1.qq.com (NewEsmtp) with SMTP id D0BACAE3; Sat, 07 Jan 2023 22:52:11 +0800 X-QQ-mid: xmsmtpt1673103131t304nj6ko X-QQ-XMAILINFO: MB5+LsFw85NoJmsunD8zoy4sgtzS3s7x1ikIayZXnpMGw+KYWskYOF1vsJbDe7 FXt00Ou6X3cGRurOQaCNILb8x2f1+gvBRaKRV9Z3QUqqYkyoBi2rFsbXmr+jom7Gw1BkHA7gJOKy d8Rmu6EHvuPwXiZbfAp9iCAdyFgkGinRs/CSNUaHUtXzi8S7R6H9RsPvUAN0ff2gg/TdbirdJYFW Ezu/LGTDQ9S7UdCnwIHAtF637EY/UsEg4XhUMq9E2IvccVQyFBveGa+rbxMRoIU7vF/8kKFlszfM HDvx3yoE67StFDQSufczpHZjOKz1PA0PxpsYi86MltjA5Unl1NpgpF0izY2XZMtY0sHqi4SRDB18 4UrIvmm8wIYoi4AL+PweN19BRu89q0XFmqbQUNKApfb/8ROFBKFNa8Zoi2rxrnTVO6hl4oAHgORY cgfLVo3Il/TXVHLbP0avxN0Zn04HoVtym+UYQalxapvlCHyc4fUuN58Dv3zRl7KHeHdGmdNEf/O7 HY25wpSDA0bCgLB9vInH0vTHMaKtfGloVxP5MxBmpinct18AWndNWTOpjTbp8B5x6SMZzAJW0Hi+ HABvCpQYjqv1DEE7P3wEB+xVelujb5VDP3H9UKi0yXNohTMYJMQU+wrQT1pCUFGucVuIPgjTzRrT vKJfY7Fj9dMKimCAX3wsB8sTENgEMhVhRaZnC2Q5+mI9E6iEsuord6TdZyroHYg8dTbMgKzzcCQL /vC0hH5LOqxH5EJG/Gq/1JyDqZtoSpP31OgblqXtNBlcE2AhlOMaIV7Q/EPXQ0k3u30xNv9+R18P xMdymaxK6r5o+n9xeneDbIBJS/EDgr9ZKLSumJrd X-OQ-MSGID: <20230107225209.51193889@lx-pc> In-Reply-To: <834jt2u1yh.fsf@gnu.org> 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:252807 Archived-At: --MP_/SAsy=Yf0ZIdxGLDjO4bqf2g Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sat, 07 Jan 2023 11:29:58 +0200 Eli Zaretskii wrote: > > Cc: 60562@debbugs.gnu.org > > From: Robert Pluim > > Date: Fri, 06 Jan 2023 10:48:43 +0100 > > > > >>>>> On Thu, 5 Jan 2023 06:56:05 +0800, lux > > >>>>> said: > > > > lux> * lisp/htmlfontify.el (hfy-list-files): Specify separator > > lux> (\n\r). --- > > lux> lisp/htmlfontify.el | 5 +++-- > > lux> 1 file changed, 3 insertions(+), 2 deletions(-) > > > > lux> diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el > > lux> index c989a12d205..be020b6b1c5 100644 > > lux> --- a/lisp/htmlfontify.el > > lux> +++ b/lisp/htmlfontify.el > > lux> @@ -1826,8 +1826,9 @@ hfy-list-files > > lux> ;;(message "hfy-list-files");;DBUG > > lux> ;; FIXME: this changes the dir of the current buffer. > > lux> Is that right?? (cd directory) > > lux> - (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) > > lux> (match-string 1 F) F)) > > lux> - (split-string (shell-command-to-string > > lux> hfy-find-cmd))) ) > > lux> + (remove-if #'string-empty-p > > lux> + (mapcar (lambda (F) (if (string-match > > lux> "^./\\(.*\\)" F) (match-string 1 F) F)) > > lux> + (split-string > > lux> (shell-command-to-string hfy-find-cmd) "[\n\r]+")) )) > > > > You can avoid the issue (and improve portability) by using > > `directory-files-recursively' instead of `find' > > Right. Would you like to rewrite the patch using > directory-files-recursively? > I try rewrite the patch using directory-files-recursively. --MP_/SAsy=Yf0ZIdxGLDjO4bqf2g Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Replace-hfy-find-cmd-with-directory-files-recursivel.patch >From 1e00b856ca423bb7e4491b9999cd3de80223d0bd 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 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el index c989a12d205..0746b5e3a36 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 @@ -1823,11 +1826,12 @@ htmlfontify-buffer (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 "." ".*"))) ;; strip the filename off, return a directory name ;; not a particularly thorough implementation, but it will be -- 2.39.0 --MP_/SAsy=Yf0ZIdxGLDjO4bqf2g--