GNU bug report logs - #60562
[PATCH] Fix split-string error if there is a space in the filename.

Previous Next

Package: emacs;

Reported by: lux <lx <at> shellcodes.org>

Date: Wed, 4 Jan 2023 22:58:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#60562: closed ([PATCH] Fix split-string error if there is a
 space in the filename.)
Date: Sat, 14 Jan 2023 09:13:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 14 Jan 2023 11:12:05 +0200
with message-id <838ri58opm.fsf <at> gnu.org>
and subject line Re: bug#60562: [PATCH] Fix split-string error if there is a space in the filename.
has caused the debbugs.gnu.org bug report #60562,
regarding [PATCH] Fix split-string error if there is a space in the filename.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
60562: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60562
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: lux <lx <at> shellcodes.org>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix split-string error if there is a space in the filename.
Date: Thu, 5 Jan 2023 06:56:05 +0800
[Message part 3 (text/plain, inline)]
If a space in filename, hfy-list-files function error. For example:

$ mkdir /tmp/test 
$ cd /tmp/test
$ touch 'hello world.py'
$ touch hi.py
$ ls
hello world.py  hi.py

In Emacs:

(hfy-list-files "/tmp/test")
("hi.py" "hello" "world.py")

As shown above, "hello world.py" is split into two files.
[0001-Fix-split-string-error-if-there-is-a-space-in-the-fi.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: lux <lx <at> shellcodes.org>
Cc: ruijie <at> netyu.xyz, 60562-done <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Sat, 14 Jan 2023 11:12:05 +0200
> Date: Sun, 8 Jan 2023 15:23:45 +0800
> From: lux <lx <at> shellcodes.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 60562 <at> debbugs.gnu.org, Robert Pluim
>  <rpluim <at> gmail.com>, bug-gnu-emacs <at> gnu.org
> 
> On Sat, 07 Jan 2023 17:00:02 -0600
> Ruijie Yu <ruijie <at> netyu.xyz> 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.


This bug report was last modified 2 years and 205 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.