all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#59756: [PATCH] Use file-name-nondirectory to determine project-name
@ 2022-12-02  3:34 Randy Taylor
  2022-12-02  8:08 ` Eli Zaretskii
  2022-12-02 15:24 ` Dmitry Gutov
  0 siblings, 2 replies; 5+ messages in thread
From: Randy Taylor @ 2022-12-02  3:34 UTC (permalink / raw)
  To: 59756; +Cc: dgutov


[-- Attachment #1.1: Type: text/plain, Size: 231 bytes --]

X-Debbugs-CC: dgutov@yandex.ru

If a project is named something like ".emacs.d", file-name-base will return ".emacs" instead of ".emacs.d" as expected (or at least as I expect it).

Therefore, we use file-name-nondirectory instead.

[-- Attachment #1.2: Type: text/html, Size: 1053 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-file-name-nondirectory-to-determine-project-name.patch --]
[-- Type: text/x-patch; name=0001-Use-file-name-nondirectory-to-determine-project-name.patch, Size: 989 bytes --]

From 046b1726e17e07d4800e2d3458c60942a579b67e Mon Sep 17 00:00:00 2001
From: Randy Taylor <dev@rjt.dev>
Date: Thu, 1 Dec 2022 22:12:07 -0500
Subject: [PATCH] Use file-name-nondirectory to determine project-name

* lisp/progmodes/project.el (project-name): Use file-name-nondirectory
instead of file-name-base.
---
 lisp/progmodes/project.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 3f4a5fb04bc..4eed599d86c 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -278,7 +278,7 @@ project-external-roots
 (cl-defgeneric project-name (project)
   "A human-readable name for the project.
 Nominally unique, but not enforced."
-  (file-name-base (directory-file-name (project-root project))))
+  (file-name-nondirectory (directory-file-name (project-root project))))
 
 (cl-defgeneric project-ignores (_project _dir)
   "Return the list of glob patterns to ignore inside DIR.
-- 
2.38.1


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

* bug#59756: [PATCH] Use file-name-nondirectory to determine project-name
  2022-12-02  3:34 bug#59756: [PATCH] Use file-name-nondirectory to determine project-name Randy Taylor
@ 2022-12-02  8:08 ` Eli Zaretskii
  2022-12-02 12:47   ` Stefan Kangas
  2022-12-02 14:37   ` Dmitry Gutov
  2022-12-02 15:24 ` Dmitry Gutov
  1 sibling, 2 replies; 5+ messages in thread
From: Eli Zaretskii @ 2022-12-02  8:08 UTC (permalink / raw)
  To: Randy Taylor; +Cc: dgutov, 59756

> Cc: dgutov@yandex.ru
> Date: Fri, 02 Dec 2022 03:34:30 +0000
> From: Randy Taylor <dev@rjt.dev>
> 
> If a project is named something like ".emacs.d", file-name-base will return ".emacs" instead of ".emacs.d" as
> expected (or at least as I expect it).
> 
> Therefore, we use file-name-nondirectory instead.

Why do we want to support such project names?

I could also name my project /foo/bar/baz, and defeat file-name-nondirectory
as well.  Where does it end?

My suggestion is to require that project names don't include slashes,
backslashes, periods and maybe also colon characters.





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

* bug#59756: [PATCH] Use file-name-nondirectory to determine project-name
  2022-12-02  8:08 ` Eli Zaretskii
@ 2022-12-02 12:47   ` Stefan Kangas
  2022-12-02 14:37   ` Dmitry Gutov
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Kangas @ 2022-12-02 12:47 UTC (permalink / raw)
  To: Eli Zaretskii, Randy Taylor; +Cc: 59756, dgutov

Eli Zaretskii <eliz@gnu.org> writes:

>> If a project is named something like ".emacs.d", file-name-base will
>> return ".emacs" instead of ".emacs.d" as expected (or at least as I
>> expect it).
>>
>> Therefore, we use file-name-nondirectory instead.
>
> Why do we want to support such project names?

Because people put their configuration files under version control, and
they want to use project commands there.  For example "~/.emacs.d",
which is what I use.

> I could also name my project /foo/bar/baz, and defeat file-name-nondirectory
> as well.  Where does it end?
>
> My suggestion is to require that project names don't include slashes,
> backslashes, periods and maybe also colon characters.

It's fine to disallow slashes, backslashes, and colons, but banning
periods would break some of my most important use-cases.  So I hope we
won't do that.





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

* bug#59756: [PATCH] Use file-name-nondirectory to determine project-name
  2022-12-02  8:08 ` Eli Zaretskii
  2022-12-02 12:47   ` Stefan Kangas
@ 2022-12-02 14:37   ` Dmitry Gutov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2022-12-02 14:37 UTC (permalink / raw)
  To: Eli Zaretskii, Randy Taylor; +Cc: 59756

On 02/12/2022 10:08, Eli Zaretskii wrote:
>> Cc: dgutov@yandex.ru
>> Date: Fri, 02 Dec 2022 03:34:30 +0000
>> From: Randy Taylor <dev@rjt.dev>
>>
>> If a project is named something like ".emacs.d", file-name-base will return ".emacs" instead of ".emacs.d" as
>> expected (or at least as I expect it).
>>
>> Therefore, we use file-name-nondirectory instead.
> 
> Why do we want to support such project names?

The bug's description is not very good.

The goal of the code in question is to produce an automatic version of 
the project name from its root directory, allowing individual project 
backends to override that logic.

This fix is an update for the same (logic to produce the default name), 
restoring what I'm sure was the original intent. The directories just 
don't often have extensions, so it passed by the initial testing.

> I could also name my project /foo/bar/baz, and defeat file-name-nondirectory
> as well.  Where does it end?

This is not about the user naming a project something.

ELISP> (file-name-nondirectory (directory-file-name "/foo/bar/baz/"))
"baz"

This is correct.

This custom name (e.g. set through project-vc-name) does not pass 
through this conversion. You can use whatever special characters you 
want, why not? Newlines might break some UI, but if the user wants that...





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

* bug#59756: [PATCH] Use file-name-nondirectory to determine project-name
  2022-12-02  3:34 bug#59756: [PATCH] Use file-name-nondirectory to determine project-name Randy Taylor
  2022-12-02  8:08 ` Eli Zaretskii
@ 2022-12-02 15:24 ` Dmitry Gutov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2022-12-02 15:24 UTC (permalink / raw)
  To: Randy Taylor, 59756-done

On 02/12/2022 05:34, Randy Taylor wrote:
> X-Debbugs-CC: dgutov@yandex.ru <mailto:dgutov@yandex.ru>
> 
> If a project is named something like ".emacs.d", file-name-base will 
> return ".emacs" instead of ".emacs.d" as expected (or at least as I 
> expect it).
> 
> Therefore, we use file-name-nondirectory instead.

Applied, thanks!





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

end of thread, other threads:[~2022-12-02 15:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02  3:34 bug#59756: [PATCH] Use file-name-nondirectory to determine project-name Randy Taylor
2022-12-02  8:08 ` Eli Zaretskii
2022-12-02 12:47   ` Stefan Kangas
2022-12-02 14:37   ` Dmitry Gutov
2022-12-02 15:24 ` Dmitry Gutov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.