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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60562 in the body.
You can then email your comments to 60562 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Wed, 04 Jan 2023 22:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to lux <lx <at> shellcodes.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 04 Jan 2023 22:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

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 1 (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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Fri, 06 Jan 2023 09:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: lux <lx <at> shellcodes.org>
Cc: 60562 <at> debbugs.gnu.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Fri, 06 Jan 2023 10:48:43 +0100
>>>>> On Thu, 5 Jan 2023 06:56:05 +0800, lux <lx <at> shellcodes.org> said:

    lux> * lisp/htmlfontify.el (hfy-list-files): Specify separator (\n\r).
    lux> ---
    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.  Is that right??
    lux>    (cd directory)
    lux> -  (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) (match-string 1 F) F))
    lux> -          (split-string (shell-command-to-string hfy-find-cmd))) )
    lux> +  (remove-if #'string-empty-p
    lux> +             (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) (match-string 1 F) F))
    lux> +                     (split-string (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' (which is annoyingly
hard to remember, since the obvious search leads to
`list-directory'. Perhaps we should add `list-directory-recursively'
as an alias?)

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 09:30:02 GMT) Full text and rfc822 format available.

Message #11 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 60562 <at> debbugs.gnu.org, lx <at> shellcodes.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space in
 the filename.
Date: Sat, 07 Jan 2023 11:29:58 +0200
> Cc: 60562 <at> debbugs.gnu.org
> From: Robert Pluim <rpluim <at> gmail.com>
> Date: Fri, 06 Jan 2023 10:48:43 +0100
> 
> >>>>> On Thu, 5 Jan 2023 06:56:05 +0800, lux <lx <at> shellcodes.org> said:
> 
>     lux> * lisp/htmlfontify.el (hfy-list-files): Specify separator (\n\r).
>     lux> ---
>     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.  Is that right??
>     lux>    (cd directory)
>     lux> -  (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) (match-string 1 F) F))
>     lux> -          (split-string (shell-command-to-string hfy-find-cmd))) )
>     lux> +  (remove-if #'string-empty-p
>     lux> +             (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) (match-string 1 F) F))
>     lux> +                     (split-string (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?

> (which is annoyingly
> hard to remember, since the obvious search leads to
> `list-directory'. Perhaps we should add `list-directory-recursively'
> as an alias?)

How did you search for it?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 09:43:01 GMT) Full text and rfc822 format available.

Message #14 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: lux <lx <at> shellcodes.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 60562 <at> debbugs.gnu.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Sat, 7 Jan 2023 17:42:35 +0800
On Fri, 06 Jan 2023 10:48:43 +0100
Robert Pluim <rpluim <at> gmail.com> wrote:

> >>>>> On Thu, 5 Jan 2023 06:56:05 +0800, lux <lx <at> shellcodes.org>
> >>>>> 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.  Is
>     lux> 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 (shell-command-to-string
>     lux> hfy-find-cmd) "[\n\r]+")) ))  
> 
> You can avoid the issue (and improve portability) by using
> `directory-files-recursively' instead of `find'

But `hfy-find-cmd' is a configurable variable:

(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))

I don't know if using `directory-files-recursively' has other effects.








Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 10:49:02 GMT) Full text and rfc822 format available.

Message #17 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: lux <lx <at> shellcodes.org>
Cc: 60562 <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, 07 Jan 2023 12:48:24 +0200
> Cc: 60562 <at> debbugs.gnu.org
> Date: Sat, 7 Jan 2023 17:42:35 +0800
> From: lux <lx <at> shellcodes.org>
> 
> On Fri, 06 Jan 2023 10:48:43 +0100
> Robert Pluim <rpluim <at> gmail.com> wrote:
> 
> > You can avoid the issue (and improve portability) by using
> > `directory-files-recursively' instead of `find'
> 
> But `hfy-find-cmd' is a configurable variable:
> 
> (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))

We can convert that to a customizable regexp, and maybe to a predicate
function if a simple regexp won't do.

> I don't know if using `directory-files-recursively' has other effects.

Why would that bother us?  This is used to find the files under a
given directory, avoiding some files which we know will not be wanted.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 11:18:01 GMT) Full text and rfc822 format available.

Message #20 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60562 <at> debbugs.gnu.org, lx <at> shellcodes.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Sat, 07 Jan 2023 12:16:55 +0100
>>>>> On Sat, 07 Jan 2023 11:29:58 +0200, Eli Zaretskii <eliz <at> gnu.org> said:

    Eli> Right.  Would you like to rewrite the patch using
    Eli> directory-files-recursively?

I donʼt have time for that at the moment, unfortunately

    >> (which is annoyingly
    >> hard to remember, since the obvious search leads to
    >> `list-directory'. Perhaps we should add `list-directory-recursively'
    >> as an alias?)

    Eli> How did you search for it?

I use helm, which does subword searching, so

C-h f list dir

since "Iʼm trying to list the contents of a directory, the verb is
'list', the object is 'directory'"

If Iʼd done 'dir files' instead I would have gotten there
quicker. (the same process with 'i' in the elisp info manual leads to
similar results).

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 11:38:02 GMT) Full text and rfc822 format available.

Message #23 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 60562 <at> debbugs.gnu.org, lx <at> shellcodes.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Sat, 07 Jan 2023 13:37:54 +0200
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: lx <at> shellcodes.org,  60562 <at> debbugs.gnu.org
> Date: Sat, 07 Jan 2023 12:16:55 +0100
> 
> >>>>> On Sat, 07 Jan 2023 11:29:58 +0200, Eli Zaretskii <eliz <at> gnu.org> said:
> 
>     >> (which is annoyingly
>     >> hard to remember, since the obvious search leads to
>     >> `list-directory'. Perhaps we should add `list-directory-recursively'
>     >> as an alias?)
> 
>     Eli> How did you search for it?
> 
> I use helm, which does subword searching, so
> 
> C-h f list dir

I was about to suggest "M-x apropos-documentation RET list dir RET",
but I see now that for some strange reason (bug?) it doesn't catch
directory-files-recursively, although its doc string does match.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 13:57:02 GMT) Full text and rfc822 format available.

Message #26 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: rpluim <at> gmail.com
Cc: 60562 <at> debbugs.gnu.org, lx <at> shellcodes.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space in
 the filename.
Date: Sat, 07 Jan 2023 15:56:20 +0200
> Cc: 60562 <at> debbugs.gnu.org, lx <at> shellcodes.org
> Date: Sat, 07 Jan 2023 13:37:54 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> I was about to suggest "M-x apropos-documentation RET list dir RET",
> but I see now that for some strange reason (bug?) it doesn't catch
> directory-files-recursively, although its doc string does match.

The issue with "C-h d" is now bug#60628.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 14:53:02 GMT) Full text and rfc822 format available.

Message #29 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: lux <lx <at> shellcodes.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60562 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>
Subject: Re: 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 part 1 (text/plain, inline)]
On Sat, 07 Jan 2023 11:29:58 +0200
Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Cc: 60562 <at> debbugs.gnu.org
> > From: Robert Pluim <rpluim <at> gmail.com>
> > Date: Fri, 06 Jan 2023 10:48:43 +0100
> >   
> > >>>>> On Thu, 5 Jan 2023 06:56:05 +0800, lux <lx <at> shellcodes.org>
> > >>>>> 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.

[0001-Replace-hfy-find-cmd-with-directory-files-recursivel.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 23:16:02 GMT) Full text and rfc822 format available.

Message #32 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ruijie Yu <ruijie <at> netyu.xyz>
To: lux <lx <at> shellcodes.org>
Cc: 60562 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, bug-gnu-emacs <at> gnu.org,
 Robert Pluim <rpluim <at> gmail.com>
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Sat, 07 Jan 2023 17:00:02 -0600
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sat, 07 Jan 2023 23:16:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sun, 08 Jan 2023 07:25:02 GMT) Full text and rfc822 format available.

Message #38 received at submit <at> debbugs.gnu.org (full text, mbox):

From: lux <lx <at> shellcodes.org>
To: Ruijie Yu <ruijie <at> netyu.xyz>
Cc: 60562 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, bug-gnu-emacs <at> gnu.org,
 Robert Pluim <rpluim <at> gmail.com>
Subject: Re: 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 part 1 (text/plain, inline)]
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.
[0001-Replace-hfy-find-cmd-with-directory-files-recursivel.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sun, 08 Jan 2023 07:25:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Mon, 09 Jan 2023 14:29:02 GMT) Full text and rfc822 format available.

Message #44 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Ruijie Yu <ruijie <at> netyu.xyz>
Cc: 60562 <at> debbugs.gnu.org, lux <lx <at> shellcodes.org>, eliz <at> gnu.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Mon, 09 Jan 2023 15:28:30 +0100
    >> 
    >> 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?
    >>

`directory-files-recursively' by default only returns files (and the
latest patch explicitly passes `nil' for INCLUDE-DIRECTORIES anyway)

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Mon, 09 Jan 2023 14:57:02 GMT) Full text and rfc822 format available.

Message #47 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: lux <lx <at> shellcodes.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: Ruijie Yu <ruijie <at> netyu.xyz>, 60562 <at> debbugs.gnu.org, eliz <at> gnu.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space
 in the filename.
Date: Mon, 09 Jan 2023 22:55:58 +0800
Robert Pluim <rpluim <at> gmail.com> writes:

>     >>
>     >> 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?
>     >>
>
> `directory-files-recursively' by default only returns files (and the
> latest patch explicitly passes `nil' for INCLUDE-DIRECTORIES anyway)
>

"-type f" will return all regular files, `directory-files-recursively'
contains all types of files (socket, block, etc..), so I latest patch
added `file-regular-p' to check the file type.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 14 Jan 2023 09:13:02 GMT) Full text and rfc822 format available.

Notification sent to lux <lx <at> shellcodes.org>:
bug acknowledged by developer. (Sat, 14 Jan 2023 09:13:02 GMT) Full text and rfc822 format available.

Message #52 received at 60562-done <at> debbugs.gnu.org (full text, mbox):

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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sun, 15 Jan 2023 12:35:02 GMT) Full text and rfc822 format available.

Message #55 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andy Moreton <andrewjmoreton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space in
 the filename.
Date: Sun, 15 Jan 2023 12:33:49 +0000
On Sat 07 Jan 2023, Eli Zaretskii wrote:

>> Cc: 60562 <at> debbugs.gnu.org
>> Date: Sat, 7 Jan 2023 17:42:35 +0800
>> From: lux <lx <at> shellcodes.org>
>> 
>> On Fri, 06 Jan 2023 10:48:43 +0100
>> Robert Pluim <rpluim <at> gmail.com> wrote:
>> 
>> > You can avoid the issue (and improve portability) by using
>> > `directory-files-recursively' instead of `find'
>> 
>> But `hfy-find-cmd' is a configurable variable:
>> 
>> (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))
>
> We can convert that to a customizable regexp, and maybe to a predicate
> function if a simple regexp won't do.
>
>> I don't know if using `directory-files-recursively' has other effects.
>
> Why would that bother us?  This is used to find the files under a
> given directory, avoiding some files which we know will not be wanted.

The fixes for this problem now cause bootstrap to fail, due to the
defcustom for hfy-exclude-file-rules containing a version tag that is
not a string.

    AndyM





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60562; Package emacs. (Sun, 15 Jan 2023 14:08:01 GMT) Full text and rfc822 format available.

Message #58 received at 60562 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 60562 <at> debbugs.gnu.org
Subject: Re: bug#60562: [PATCH] Fix split-string error if there is a space in
 the filename.
Date: Sun, 15 Jan 2023 16:07:09 +0200
> From: Andy Moreton <andrewjmoreton <at> gmail.com>
> Date: Sun, 15 Jan 2023 12:33:49 +0000
> 
> On Sat 07 Jan 2023, Eli Zaretskii wrote:
> 
> The fixes for this problem now cause bootstrap to fail, due to the
> defcustom for hfy-exclude-file-rules containing a version tag that is
> not a string.

That was fixed yesterday, so please update from Git, and sorry for the
trouble.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 13 Feb 2023 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 44 days ago.

Previous Next


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