unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54228: 29.0.50; project.el: Support local projects
@ 2022-03-03  7:15 Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-03 12:36 ` Rudolf Schlatte
  2022-03-04 17:48 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 7+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-03  7:15 UTC (permalink / raw)
  To: 54228

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

Hi,

I attached a small patch which simply adds to project.el some code I
have been using for a while for projects that I do not intend to handle with Git.

The gist of it is that adding a `.project` (empty) file to the root
directory of your project make it possible for commands such as 'C-x p f' to 
work on it.

Is this of any interest?

-- 
Manuel Uberti
www.manueluberti.eu

[-- Attachment #2: 0001-Support-local-projects.patch --]
[-- Type: text/x-patch, Size: 1245 bytes --]

From 63b29ff98c4914ab55d828146e44d318cc8c0b62 Mon Sep 17 00:00:00 2001
From: Manuel Uberti <manuel.uberti@inventati.org>
Date: Thu, 3 Mar 2022 08:08:16 +0100
Subject: [PATCH] Support local projects

* lisp/progmodes/project.el (project-try-local):
New function.
(project-find-functions):
Use it.
---
 lisp/progmodes/project.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index b44f4618be..4f19e2aaf4 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -165,7 +165,8 @@ project
   :version "28.1"
   :group 'tools)
 
-(defvar project-find-functions (list #'project-try-vc)
+(defvar project-find-functions (list #'project-try-vc
+                                     #'project-try-local)
   "Special hook to find the project containing a given directory.
 Each functions on this hook is called in turn with one
 argument, the directory in which to look, and should return
@@ -680,6 +681,12 @@ project-buffers
         (push buf bufs)))
     (nreverse bufs)))
 
+(cl-defmethod project-root ((project string))
+  project)
+
+(defun project-try-local (dir)
+  (locate-dominating-file dir ".project"))
+
 \f
 ;;; Project commands
 
-- 
2.25.1


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

* bug#54228: 29.0.50; project.el: Support local projects
  2022-03-03  7:15 bug#54228: 29.0.50; project.el: Support local projects Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-03 12:36 ` Rudolf Schlatte
  2022-03-04 17:48 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 7+ messages in thread
From: Rudolf Schlatte @ 2022-03-03 12:36 UTC (permalink / raw)
  To: 54228

Manuel Uberti via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:

> Hi,
>
> I attached a small patch which simply adds to project.el some code I
> have been using for a while for projects that I do not intend to handle with Git.
>
> The gist of it is that adding a `.project` (empty) file to the root
> directory of your project make it possible for commands such as 'C-x p f' to
> work on it.

The eclipse IDE uses files named `.project' for something-or-other.
Maybe naming the file `.emacs-project-root' or something similarly
unique is safer.

Rudi






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

* bug#54228: 29.0.50; project.el: Support local projects
  2022-03-03  7:15 bug#54228: 29.0.50; project.el: Support local projects Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-03 12:36 ` Rudolf Schlatte
@ 2022-03-04 17:48 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-04 18:15   ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-05 16:15   ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 2 replies; 7+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-04 17:48 UTC (permalink / raw)
  To: 54228; +Cc: manuel.uberti

Manuel Uberti via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:

> Hi,
>
> I attached a small patch which simply adds to project.el some code I
> have been using for a while for projects that I do not intend to handle with Git.
>
> The gist of it is that adding a `.project` (empty) file to the root
> directory of your project make it possible for commands such as 'C-x p
> f' to work on it.
>
> Is this of any interest?
>

I use similar code in my config.  It's specially useful for monorepos,
where there is only one big .git folder, but multiple projects that you
want to handle separately.

If we want to contribute this to project.el, I wonder if it makes sense
to generalize it a little bit by making ".project" the default value of
a customization variable.  That'd avoid the name clash with some Eclipse
files.  We could also detect files from common build systems, but I
don't know if that would be out of scope for the rather minimalist
project.el (vs projectile.el, for example).





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

* bug#54228: 29.0.50; project.el: Support local projects
  2022-03-04 17:48 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-04 18:15   ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-05  1:31     ` Dmitry Gutov
  2022-03-05 16:15   ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 7+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-04 18:15 UTC (permalink / raw)
  To: mardani29, 54228

On 04/03/22 18:48, Daniel Martín wrote:
> I use similar code in my config.  It's specially useful for monorepos,
> where there is only one big .git folder, but multiple projects that you
> want to handle separately.

In my case it's super useful for projects where I do not have VC involved, of 
which I have a few. I just can't live without project.el facilities in my daily 
Emacs any more. :)

> If we want to contribute this to project.el, I wonder if it makes sense
> to generalize it a little bit by making ".project" the default value of
> a customization variable.  That'd avoid the name clash with some Eclipse
> files.  We could also detect files from common build systems, but I
> don't know if that would be out of scope for the rather minimalist
> project.el (vs projectile.el, for example).

I did not think about making ".project" the value of a defcustom, because I do 
not use anything that relies on ".project" files. But if as you say there is a 
chance of name clashing, then yes, making customizable seems about right.

I'd wait for Dmitry to jump in on this. I'd like to hear his opinion as well.

-- 
Manuel Uberti
www.manueluberti.eu





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

* bug#54228: 29.0.50; project.el: Support local projects
  2022-03-04 18:15   ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-05  1:31     ` Dmitry Gutov
  2022-03-05  7:42       ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2022-03-05  1:31 UTC (permalink / raw)
  To: Manuel Uberti, mardani29, 54228, Rudolf Schlatte

Hey folks,

Check out https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41572, of which 
this is a duplicate.

If the discussion seems daunting (and it is overly long), you can start 
at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41572#82.

Comments welcome.

On 04.03.2022 20:15, Manuel Uberti via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> On 04/03/22 18:48, Daniel Martín wrote:
>> I use similar code in my config.  It's specially useful for monorepos,
>> where there is only one big .git folder, but multiple projects that you
>> want to handle separately.
> 
> In my case it's super useful for projects where I do not have VC 
> involved, of which I have a few. I just can't live without project.el 
> facilities in my daily Emacs any more. :)
> 
>> If we want to contribute this to project.el, I wonder if it makes sense
>> to generalize it a little bit by making ".project" the default value of
>> a customization variable.  That'd avoid the name clash with some Eclipse
>> files.  We could also detect files from common build systems, but I
>> don't know if that would be out of scope for the rather minimalist
>> project.el (vs projectile.el, for example).
> 
> I did not think about making ".project" the value of a defcustom, 
> because I do not use anything that relies on ".project" files. But if as 
> you say there is a chance of name clashing, then yes, making 
> customizable seems about right.
> 
> I'd wait for Dmitry to jump in on this. I'd like to hear his opinion as 
> well.






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

* bug#54228: 29.0.50; project.el: Support local projects
  2022-03-05  1:31     ` Dmitry Gutov
@ 2022-03-05  7:42       ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 7+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-05  7:42 UTC (permalink / raw)
  To: Dmitry Gutov, mardani29, 54228, Rudolf Schlatte

On 05/03/22 02:31, Dmitry Gutov wrote:
> Check out https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41572, of which this is 
> a duplicate.
> 
> If the discussion seems daunting (and it is overly long), you can start at 
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41572#82.
> 
> Comments welcome.

Thanks for the link, this ticket can be closed then.

As for #41572, I see that adding support for local/plain/novc projects is not as 
simple as I thought.

As mentioned in that bug, probably I didn't see the possible implications of 
this change because my novc projects are quite small and so, for instance, 
`find' performs just fine within them. Also, I do not need to ignore anything in 
particular in these projects, so I didn't take that into consideration either.

To be more specific: these projects are not related to a programming language, 
so no build tools are involved. Just plain Markdown files and PDFs. They may 
involve LaTeX sometimes, but supporting project.el here could be something 
AUCTeX can take care of?

I don't know how much I can add on #41572. It looks like what I need is a small 
subset of not so trivial changes. For my specific use case, then, it makes 
little sense to change project.el.

-- 
Manuel Uberti
www.manueluberti.eu





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

* bug#54228: 29.0.50; project.el: Support local projects
  2022-03-04 17:48 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-04 18:15   ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-05 16:15   ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 7+ messages in thread
From: Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-05 16:15 UTC (permalink / raw)
  To: Daniel Martín, 54228; +Cc: manuel.uberti

Daniel Martín via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:

> I use similar code in my config.  It's specially useful for monorepos,
> where there is only one big .git folder, but multiple projects that you
> want to handle separately.

+1 vote for this feature from me.  I, too, have similar code in my Emacs
config, and it enables me to survive at work where we have a big
repository in which I often need to "zoom in" to a sub-project.

> If we want to contribute this to project.el, I wonder if it makes
> sense to generalize it a little bit by making ".project" the default
> value of a customization variable.

+1 and I also think that the customization variable should exist as a
list so that one can specify more than one "project stamp" file name.

Rudy
-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."
-- Edsger W. Dijkstra, 1981

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia





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

end of thread, other threads:[~2022-03-05 16:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03  7:15 bug#54228: 29.0.50; project.el: Support local projects Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-03 12:36 ` Rudolf Schlatte
2022-03-04 17:48 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-04 18:15   ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-05  1:31     ` Dmitry Gutov
2022-03-05  7:42       ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-05 16:15   ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors

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