[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subprojects in project.el

From: João Távora
Subject: Re: Subprojects in project.el
Date: Tue, 29 Nov 2022 10:17:59 +0000
User-agent: Gnus/5.13 (Gnus v5.13)

Dmitry Gutov <dgutov@yandex.ru> writes:

>> Hysterical raisins.
>> But 'C-x p f' and 'C-x p g' call 'project-current' directly. What's
>> that about some new command?

> Don't know what you are talking aboutIt seems very reasonable to do
> this instead:

>diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
>index c7b2c386ccd..02f5d25e054 100644
>--- a/lisp/progmodes/project.el
>+++ b/lisp/progmodes/project.el
>@@ -1151,11 +1151,11 @@ project-compilation-buffer-name-function
>                  (function :tag "Custom function")))
> ;;;###autoload
>-(defun project-compile ()
>+(defun project-compile (project)
>   "Run `compile' in the project root."
>   (declare (interactive-only compile))
>-  (interactive)
>-  (let ((default-directory (project-root (project-current t)))
>+  (interactive (project-current t))

Sorry I hit "send" before I wanted to.  This line of course be

  (interactive (list (project-current t)))

And the docstring should be

  "Run `compile' in PROJECT's root."

'project-current', when called with MAYBE-PROMPT, is running in an
interactive setting.  It could then consult the value of the prefix
argument and decide to prompt the user about which project to use
(including super-projects).

You can use this technique to a add PROJECT argument to all the other
relevant project-* operations without breaking backward compatibility,
even for non-interactive Lisp uses.

In cases where a "P" prefix argument is already in use, like C-x p f,
we'd have to repurpose the "negative prefix" part to _not_ mean
INCLUDE-ALL.  You'd affect only the people who are currently using M--
C-x p f instead of C-u C-x p f.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]