GNU bug report logs - #60188
30.0.50; zerop cpd-length are not all handled in project--read-file-cpd-relative

Previous Next

Package: emacs;

Reported by: Shuguang Sun <shuguang79 <at> qq.com>

Date: Mon, 19 Dec 2022 05:14:01 UTC

Severity: normal

Found in version 30.0.50

Full log


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

From: Shuguang Sun <shuguang79 <at> qq.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; zerop cpd-length are not all handled in
 project--read-file-cpd-relative
Date: Mon, 19 Dec 2022 13:12:09 +0800
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




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

Previous Next


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