GNU bug report logs -
#78099
[PATCH] Make 'project-remember-project' interactive
Previous Next
To reply to this bug, email your comments to 78099 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
dmitry <at> gutov.dev, bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Sun, 27 Apr 2025 20:19:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Elijah Gabe Pérez <eg642616 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
dmitry <at> gutov.dev, bug-gnu-emacs <at> gnu.org
.
(Sun, 27 Apr 2025 20:19:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tags: patch
Sometimes when creating a new project it is not added to project list.
AFAIK the only way to do it is using `project-remember-projects-under'
or `project-switch-project' but they are uncomfortable to use when you
just want to remember the current project you're in.
So I decided to make `project-remember-project' interactive in this
patch for archive this; this let to users use it in hooks (e.g
find-file-hook)
[0001-Make-project-remember-project-interactive.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Sun, 27 Apr 2025 22:56:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78099 <at> debbugs.gnu.org (full text, mbox):
Hi!
On 27/04/2025 23:18, Elijah Gabe Pérez wrote:
> Sometimes when creating a new project it is not added to project list.
> AFAIK the only way to do it is using `project-remember-projects-under'
> or `project-switch-project' but they are uncomfortable to use when you
> just want to remember the current project you're in.
Please clarify the usage scenario. Doesn't it help to visit it just once?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Mon, 28 Apr 2025 00:30:04 GMT)
Full text and
rfc822 format available.
Message #11 received at 78099 <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> Hi!
>
> On 27/04/2025 23:18, Elijah Gabe Pérez wrote:
>> Sometimes when creating a new project it is not added to project list.
>> AFAIK the only way to do it is using `project-remember-projects-under'
>> or `project-switch-project' but they are uncomfortable to use when you
>> just want to remember the current project you're in.
>
> Please clarify the usage scenario.
For example, visiting a new file (usually with `find-file') or importing
and opening a new project, you cannot be sure if it is already in the
project--list (or it was not added to project-list) unless you do
`project-switch-project' (which automatically index it), projectile have
a similar behavior (projectile-auto-update-cache), but it's very slow, so
one way i had to mimic this is this way.
A good use case would be adding it to `find-file-hook', so one would not
have to use `project-switch-project' for each new recent project.
Or for example if you are working in a remote project (not indexed) in
the current file you are in, instead using `project-remember-projects-under'
you can just type: M-x project-remember-project,
and in the current project you are working on gets indexed.
> Doesn't it help to visit it just once?
I don't understand this question well.
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Mon, 28 Apr 2025 00:36:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 78099 <at> debbugs.gnu.org (full text, mbox):
On 28/04/2025 03:29, Elijah Gabe Pérez wrote:
> For example, visiting a new file (usually with `find-file') or importing
> and opening a new project, you cannot be sure if it is already in the
> project--list (or it was not added to project-list) unless you do
> `project-switch-project' (which automatically index it), projectile have
> a similar behavior (projectile-auto-update-cache), but it's very slow, so
> one way i had to mimic this is this way.
You're right. For it to be added to the list, you'd have to invoke a
command in it which uses projects at least once (for example,
project-find-file, 'C-x p f').
Not necessary to use project-switch-project, any command that calls
(project-current t) will do.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Mon, 28 Apr 2025 04:35:03 GMT)
Full text and
rfc822 format available.
Message #17 received at 78099 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> On 28/04/2025 03:29, Elijah Gabe Pérez wrote:
> > For example, visiting a new file (usually with `find-file') or importing
> > and opening a new project, you cannot be sure if it is already in the
> > project--list (or it was not added to project-list) unless you do
> > `project-switch-project' (which automatically index it), projectile have
> > a similar behavior (projectile-auto-update-cache), but it's very slow, so
> > one way i had to mimic this is this way.
>
> You're right. For it to be added to the list, you'd have to invoke a
> command in it which uses projects at least once (for example,
> project-find-file, 'C-x p f').
>
> Not necessary to use project-switch-project, any command that calls
> (project-current t) will do.
>
Right, but all these commands will prompt for
select a project/file/directory, it is
exhausting to always have to press C-g to quit it.
In this case, the feature just display a message
whether if project was indexed or not (if called interactively)
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Mon, 28 Apr 2025 15:22:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 78099 <at> debbugs.gnu.org (full text, mbox):
> Sometimes when creating a new project it is not added to project list.
> AFAIK the only way to do it is using `project-remember-projects-under'
> or `project-switch-project' but they are uncomfortable to use when you
> just want to remember the current project you're in.
>
> So I decided to make `project-remember-project' interactive in this
> patch for archive this; this let to users use it in hooks (e.g
> find-file-hook)
For the same purpose I added an advice to functions like
'read-directory-name' and 'vc-dir' with the trick to
call 'project-current' that remembers a new project:
(define-advice vc-dir (:after (dir &optional _backend) add-project)
(when (featurep 'project)
;; Add current vc project dir to project list
(let ((default-directory dir))
(project-current))))
But maybe `project-remember-project' would be more correct to use here.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Tue, 29 Apr 2025 01:40:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 78099 <at> debbugs.gnu.org (full text, mbox):
On 27/04/2025 23:18, Elijah Gabe Pérez wrote:
> + (interactive)
Something like
(interactive (list (project-current t)))
should allow to keep PR a required argument.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Tue, 29 Apr 2025 01:42:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 78099 <at> debbugs.gnu.org (full text, mbox):
On 28/04/2025 07:34, Elijah Gabe Pérez wrote:
> Right, but all these commands will prompt for
> select a project/file/directory, it is
> exhausting to always have to press C-g to quit it.
So your scenario is to add a project but not do anything else
project-related with it, at that time?
That's fine, I suppose.
> In this case, the feature just display a message
> whether if project was indexed or not (if called interactively)
No problem with that.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Wed, 30 Apr 2025 00:39:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 78099 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> So your scenario is to add a project but not do anything else
> project-related with it, at that time?
Yes, so for not to break the default project-remember functionality.
In any case that's why exists the other project commands.
> On 27/04/2025 23:18, Elijah Gabe Pérez wrote:
>> + (interactive)
>
> Something like
>
> (interactive (list (project-current t)))
>
> should allow to keep PR a required argument.
Thanks, done:
[0001-Make-project-remember-project-interactive.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Wed, 14 May 2025 23:34:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 78099 <at> debbugs.gnu.org (full text, mbox):
On 30/04/2025 03:38, Elijah Gabe Pérez wrote:
>> On 27/04/2025 23:18, Elijah Gabe Pérez wrote:
>>> + (interactive)
>> Something like
>>
>> (interactive (list (project-current t)))
>>
>> should allow to keep PR a required argument.
> Thanks, done:
How about this? Modulo reindentation.
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 27b69277e81..e7ae7d282ab 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1933,12 +1933,18 @@ project-remember-project
If project PR satisfies `project-list-exclude', then nothing is done.
Save the result in `project-list-file' if the list of projects
has changed, and NO-WRITE is nil."
- (let ((root (project-root pr)))
- (unless (seq-some (lambda (r)
+ (interactive (list (project-current t)))
+ (let ((root (project-root pr))
+ (interact (called-interactively-p 'any)))
+ (if (seq-some (lambda (r)
(if (functionp r)
(funcall r pr)
(string-match-p r root)))
project-list-exclude)
+ (when interact
+ (message "Current project is blacklisted!"))
+ (when interact
+ (message "Current project remembered"))
(project--remember-dir root no-write))))
(defun project--remove-from-project-list (project-root report-message)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Thu, 15 May 2025 00:31:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 78099 <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> On 30/04/2025 03:38, Elijah Gabe Pérez wrote:
>>> On 27/04/2025 23:18, Elijah Gabe Pérez wrote:
>>>> + (interactive)
>>> Something like
>>>
>>> (interactive (list (project-current t)))
>>>
>>> should allow to keep PR a required argument.
>> Thanks, done:
>
> How about this? Modulo reindentation.
>
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 27b69277e81..e7ae7d282ab 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1933,12 +1933,18 @@ project-remember-project
> If project PR satisfies `project-list-exclude', then nothing is done.
> Save the result in `project-list-file' if the list of projects
> has changed, and NO-WRITE is nil."
> - (let ((root (project-root pr)))
> - (unless (seq-some (lambda (r)
> + (interactive (list (project-current t)))
> + (let ((root (project-root pr))
> + (interact (called-interactively-p 'any)))
> + (if (seq-some (lambda (r)
> (if (functionp r)
> (funcall r pr)
> (string-match-p r root)))
> project-list-exclude)
> + (when interact
> + (message "Current project is blacklisted!"))
> + (when interact
> + (message "Current project remembered"))
> (project--remember-dir root no-write))))
>
> (defun project--remove-from-project-list (project-root report-message)
>
LGTM, Maybe it is better to also add a message to indicate that the
project is already remembered, this would avoid having to re-remember
the project.
#+begin_src diff
@@ -1992,13 +1992,22 @@ project-remember-project
If project PR satisfies `project-list-exclude', then nothing is done.
Save the result in `project-list-file' if the list of projects
has changed, and NO-WRITE is nil."
- (let ((root (project-root pr)))
- (unless (seq-some (lambda (r)
- (if (functionp r)
- (funcall r pr)
- (string-match-p r root)))
- project-list-exclude)
- (project--remember-dir root no-write))))
+ (interactive (list (project-current t)))
+ (let ((root (project-root pr))
+ (interact (called-interactively-p 'any)))
+ (if (and (listp project--list) (assoc root project--list))
+ (when interact
+ (message "This project is already remembered"))
+ (if (seq-some (lambda (r)
+ (if (functionp r)
+ (funcall r pr)
+ (string-match-p r root)))
+ project-list-exclude)
+ (when interact
+ (message "Current project is blacklisted!"))
+ (when interact
+ (message "Current project remembered"))
+ (project--remember-dir root no-write)))))
(defun project--remove-from-project-list (project-root report-message)
"Remove directory PROJECT-ROOT of a missing project from the project list.
#+end_src
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Thu, 15 May 2025 23:06:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 78099 <at> debbugs.gnu.org (full text, mbox):
On 15/05/2025 03:30, Elijah Gabe Pérez wrote:
> LGTM, Maybe it is better to also add a message to indicate that the
> project is already remembered, this would avoid having to re-remember
> the project.
It's not a no-op, though: if you invoke the function on such a project,
it would move to the top of the list. Should be reject that?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78099
; Package
emacs
.
(Fri, 16 May 2025 02:57:06 GMT)
Full text and
rfc822 format available.
Message #41 received at 78099 <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> On 15/05/2025 03:30, Elijah Gabe Pérez wrote:
>> LGTM, Maybe it is better to also add a message to indicate that the
>> project is already remembered, this would avoid having to re-remember
>> the project.
>
> It's not a no-op, though: if you invoke the function on such a
> project, it would move to the top of the list. Should be reject that?
Well, I don't know if the order of the list matters. If it does,
then your previous patch is fine.
--
- E.G via GNU Emacs and Org.
Reply sent
to
Dmitry Gutov <dmitry <at> gutov.dev>
:
You have taken responsibility.
(Thu, 29 May 2025 19:32:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Elijah Gabe Pérez <eg642616 <at> gmail.com>
:
bug acknowledged by developer.
(Thu, 29 May 2025 19:32:02 GMT)
Full text and
rfc822 format available.
Message #46 received at 78099-done <at> debbugs.gnu.org (full text, mbox):
Version: 31.1
On 16/05/2025 05:56, Elijah Gabe Pérez wrote:
>> It's not a no-op, though: if you invoke the function on such a
>> project, it would move to the top of the list. Should be reject that?
> Well, I don't know if the order of the list matters. If it does,
> then your previous patch is fine.
I don't know either, but it might, for some.
I've installed that last version, let's wait and see if some will want
more from this feature.
This bug report was last modified 19 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.