unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative
@ 2022-12-19  5:12 Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-19 19:50 ` Juri Linkov
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-19  5:12 UTC (permalink / raw)
  To: 60188

Dear all,

When I call C-x p d (project-find-dir), it reports the error message:
`project--read-file-cpd-relative: Wrong type argument: stringp, nil`

Finaly I found it is due the the zero length of
`common-parent-directory` in `project--read-file-cpd-relative` as I
using `fd` to provide the list of dirs which does not include the common
project root in the returnd dirs.

In `project--read-file-cpd-relative`, the zero length of
`common-parent-directory` is handled for `prompt` but not for `abbr-cpd`
which will be used as parameter of `string-prefix-p`.

Below is the diff and a working patch. But no sure for the impact of HIST.

```
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 559da6dd649..8c4ea8eeca0 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1039,7 +1039,9 @@ project--read-file-cpd-relative
          (_ (when included-cpd
               (setq substrings (cons "./" substrings))))
          (new-collection (project--file-completion-table substrings))
-         (abbr-cpd (abbreviate-file-name common-parent-directory))
+         (abbr-cpd (if (zerop cpd-length)
+                       ""
+                     (abbreviate-file-name common-parent-directory)))
          (relname (cl-letf ((history-add-new-input nil)
                             ((symbol-value hist)
                              (mapcan
```

Best Regards,
Shuguang Sun

In GNU Emacs 30.0.50 (build 1, x86_64-w64-mingw32) of 2022-12-18 built
 on YJ190169
Repository revision: 2c2ecb46b0ad3e841ac9551e3a80d02893cdf6ec
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.22621
System Description: Microsoft Windows 10 Home China (v10.0.2009.22621.963)

Configured using:
 'configure --without-pop --with-native-image-api
 --with-native-compilation --with-tree-sitter --without-compress-install
 '--program-transform-name=s/^ctags$/ctags.emacs/''

Configured features:
ACL DBUS GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES
NATIVE_COMP NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative
  2022-12-19  5:12 bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-19 19:50 ` Juri Linkov
  2022-12-21  8:48   ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-19 21:55 ` Dmitry Gutov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2022-12-19 19:50 UTC (permalink / raw)
  To: Shuguang Sun; +Cc: 60188

> When I call C-x p d (project-find-dir), it reports the error message:
> `project--read-file-cpd-relative: Wrong type argument: stringp, nil`
>
> Finaly I found it is due the the zero length of
> `common-parent-directory` in `project--read-file-cpd-relative` as I
> using `fd` to provide the list of dirs which does not include the common
> project root in the returnd dirs.
>
> In `project--read-file-cpd-relative`, the zero length of
> `common-parent-directory` is handled for `prompt` but not for `abbr-cpd`
> which will be used as parameter of `string-prefix-p`.
>
> Below is the diff and a working patch. But no sure for the impact of HIST.
>
> ```
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 559da6dd649..8c4ea8eeca0 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1039,7 +1039,9 @@ project--read-file-cpd-relative
>           (_ (when included-cpd
>                (setq substrings (cons "./" substrings))))
>           (new-collection (project--file-completion-table substrings))
> -         (abbr-cpd (abbreviate-file-name common-parent-directory))
> +         (abbr-cpd (if (zerop cpd-length)
> +                       ""
> +                     (abbreviate-file-name common-parent-directory)))

Strange, I can't reproduce the problem.  When cpd-length is 0,
then for the empty string (abbreviate-file-name "") returns "".





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative
  2022-12-19  5:12 bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-19 19:50 ` Juri Linkov
@ 2022-12-19 21:55 ` Dmitry Gutov
  2022-12-19 23:45 ` bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-19 23:48 ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  3 siblings, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2022-12-19 21:55 UTC (permalink / raw)
  To: Shuguang Sun, 60188

On 19/12/2022 07:12, Shuguang Sun via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> Finaly I found it is due the the zero length of
> `common-parent-directory` in `project--read-file-cpd-relative` as I
> using `fd` to provide the list of dirs which does not include the common
> project root in the returnd dirs.

Does that mean that it returns relative file names?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative
  2022-12-19  5:12 bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-19 19:50 ` Juri Linkov
  2022-12-19 21:55 ` Dmitry Gutov
@ 2022-12-19 23:45 ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-20  8:41   ` Juri Linkov
  2022-12-19 23:48 ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  3 siblings, 1 reply; 8+ messages in thread
From: Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-19 23:45 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 60188

[-- Attachment #1: Type: text/plain, Size: 1621 bytes --]

In my case, common-parent-directory is nil.






------------------ Original ------------------

> When I call C-x p d (project-find-dir), it reports the error message:
> `project--read-file-cpd-relative: Wrong type argument: stringp, nil`
>
> Finaly I found it is due the the zero length of
> `common-parent-directory` in `project--read-file-cpd-relative` as I
> using `fd` to provide the list of dirs which does not include the common
> project root in the returnd dirs.
>
> In `project--read-file-cpd-relative`, the zero length of
> `common-parent-directory` is handled for `prompt` but not for `abbr-cpd`
> which will be used as parameter of `string-prefix-p`.
>
> Below is the diff and a working patch. But no sure for the impact of HIST.
>
> ```
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 559da6dd649..8c4ea8eeca0 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1039,7 +1039,9 @@ project--read-file-cpd-relative
>           (_ (when included-cpd
>                (setq substrings (cons "./" substrings))))
>           (new-collection (project--file-completion-table substrings))
> -         (abbr-cpd (abbreviate-file-name common-parent-directory))
> +         (abbr-cpd (if (zerop cpd-length)
> +                       ""
> +                     (abbreviate-file-name common-parent-directory)))

Strange, I can't reproduce the problem.  When cpd-length is 0,
then for the empty string (abbreviate-file-name "") returns "".

[-- Attachment #2: Type: text/html, Size: 2082 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative
  2022-12-19  5:12 bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
                   ` (2 preceding siblings ...)
  2022-12-19 23:45 ` bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-19 23:48 ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-20  0:55   ` Dmitry Gutov
  3 siblings, 1 reply; 8+ messages in thread
From: Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-19 23:48 UTC (permalink / raw)
  To: Dmitry Gutov, 60188

[-- Attachment #1: Type: text/plain, Size: 541 bytes --]

Yes. It is relative file names and common-parent-directory is nil.


------------------ Original ------------------


On 19/12/2022 07:12, Shuguang Sun via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> Finaly I found it is due the the zero length of
> `common-parent-directory` in `project--read-file-cpd-relative` as I
> using `fd` to provide the list of dirs which does not include the common
> project root in the returnd dirs.

Does that mean that it returns relative file names?

[-- Attachment #2: Type: text/html, Size: 766 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative
  2022-12-19 23:48 ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-20  0:55   ` Dmitry Gutov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2022-12-20  0:55 UTC (permalink / raw)
  To: Shuguang Sun, 60188

On 20/12/2022 01:48, Shuguang Sun wrote:
> Yes. It is relative file names and common-parent-directory is nil.
> 
> 
> ------------------ Original ------------------
> 
> On 19/12/2022 07:12, Shuguang Sun via Bug reports for GNU Emacs, the
> Swiss army knife of text editors wrote:
>  > Finaly I found it is due the the zero length of
>  > `common-parent-directory` in `project--read-file-cpd-relative` as I
>  > using `fd` to provide the list of dirs which does not include the common
>  > project root in the returnd dirs.
> 
> Does that mean that it returns relative file names?

I think the easiest solution is to make sure the returned file names are 
absolute ones (you'll need to do a bunch of 'concat' calls, but that has 
limited overhead). I want to work on that inefficency in project-files a 
little later, but now it's how it is.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative
  2022-12-19 23:45 ` bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-20  8:41   ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2022-12-20  8:41 UTC (permalink / raw)
  To: Shuguang Sun; +Cc: 60188

>> Strange, I can't reproduce the problem. When cpd-length is 0,
>> then for the empty string (abbreviate-file-name "") returns "".

> In my case, common-parent-directory is nil.

I see.  This is because common-parent-directory is defined as:

  (if (> (length common-prefix) 0)
      (file-name-directory common-prefix))

But maybe it should also have the 'else' branch like:

  (if (> (length common-prefix) 0)
      (file-name-directory common-prefix)
    "")





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative
  2022-12-19 19:50 ` Juri Linkov
@ 2022-12-21  8:48   ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 8+ messages in thread
From: Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-21  8:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 60188

Juri Linkov <juri@linkov.net> writes:

>> When I call C-x p d (project-find-dir), it reports the error message:
>> `project--read-file-cpd-relative: Wrong type argument: stringp, nil`
>>
>> Finaly I found it is due the the zero length of
>> `common-parent-directory` in `project--read-file-cpd-relative` as I
>> using `fd` to provide the list of dirs which does not include the common
>> project root in the returnd dirs.
>>
>> In `project--read-file-cpd-relative`, the zero length of
>> `common-parent-directory` is handled for `prompt` but not for `abbr-cpd`
>> which will be used as parameter of `string-prefix-p`.
>>
>> Below is the diff and a working patch. But no sure for the impact of HIST.
>>
>> ```
>> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
>> index 559da6dd649..8c4ea8eeca0 100644
>> --- a/lisp/progmodes/project.el
>> +++ b/lisp/progmodes/project.el
>> @@ -1039,7 +1039,9 @@ project--read-file-cpd-relative
>>           (_ (when included-cpd
>>                (setq substrings (cons "./" substrings))))
>>           (new-collection (project--file-completion-table substrings))
>> -         (abbr-cpd (abbreviate-file-name common-parent-directory))
>> +         (abbr-cpd (if (zerop cpd-length)
>> +                       ""
>> +                     (abbreviate-file-name common-parent-directory)))
>
> Strange, I can't reproduce the problem.  When cpd-length is 0,
> then for the empty string (abbreviate-file-name "") returns "".
>
>
>
>

Actually in my case, it is `(abbreviate-file-name nil)`. As `fd` returns
relative path, common-parent-directory is nil.

-- 
Best Regards
Shuguang Sun





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-21  8:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19  5:12 bug#60188: 30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-19 19:50 ` Juri Linkov
2022-12-21  8:48   ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-19 21:55 ` Dmitry Gutov
2022-12-19 23:45 ` bug#60188: 30.0.50; zerop cpd-length are not all handled inproject--read-file-cpd-relative Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-20  8:41   ` Juri Linkov
2022-12-19 23:48 ` Shuguang Sun via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-20  0:55   ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).