From: Spencer Baugh <sbaugh@janestreet.com>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: sbaugh@catern.com, Eli Zaretskii <eliz@gnu.org>, 62974@debbugs.gnu.org
Subject: bug#62974: 29.0.60; New buffers created with project-switch-to-buffer aren't in the project
Date: Fri, 21 Apr 2023 12:25:49 -0400 [thread overview]
Message-ID: <ier7cu5yzg2.fsf@janestreet.com> (raw)
In-Reply-To: <06aff731-1196-5c27-b66d-01f79117283e@gutov.dev> (Dmitry Gutov's message of "Fri, 21 Apr 2023 18:56:46 +0300")
Dmitry Gutov <dmitry@gutov.dev> writes:
> On 21/04/2023 16:17, sbaugh@catern.com wrote:
>> Eli Zaretskii<eliz@gnu.org> writes:
>>>> From: Spencer Baugh<sbaugh@janestreet.com>
>>>> Date: Fri, 21 Apr 2023 07:46:14 -0400
>>>> Cc: Dmitry Gutov<dmitry@gutov.dev>,62974@debbugs.gnu.org
>>>>
>>>> But if it is in a subdirectory of the root, it also belongs to the
>>>> project, doesn't it? Exactly like the buffer from which this command
>>>> is invoked, whose default-directory was a subdirectory of the root.
>>>> No?
>>>>
>>>> That's fine, I wouldn't want to change that behavior, the behavior I'd want to change is when invoking
>>>> the command from a buffer which is not in a project, or by invoking it after C-x p p to switch projects.
>>> The recipe you posted didn't include "C-x p p", though.
>> My recipe was an example of "command from a buffer which is not in a
>> project". Here's a recipe for the issue using C-x p p:
>> 1. (setq project-switch-use-entire-map t)
>> 2. Be in a buffer in project A
>> 3. C-x p p b to switch to project B and select a buffer in project B
>> 4. Type a buffer name which doesn't exist
>> 5. The resulting buffer is in project A, not B
>
> Thanks.
>
> How does this look?
>
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index a18b918db62..94c7f8f547a 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1314,13 +1314,17 @@ project--read-project-buffer
> (and (memq (cdr buffer) buffers)
> (not
> (project--buffer-check
> - (cdr buffer) project-ignore-buffer-conditions))))))
> - (read-buffer
> - "Switch to buffer: "
> - (when (funcall predicate (cons other-name other-buffer))
> - other-name)
> - nil
> - predicate)))
> + (cdr buffer) project-ignore-buffer-conditions)))))
> + (buffer (read-buffer
> + "Switch to buffer: "
> + (when (funcall predicate (cons other-name other-buffer))
> + other-name)
> + nil
> + predicate)))
> + (if (get-buffer buffer)
> + buffer
> + (let ((default-directory (project-root pr)))
> + (get-buffer-create buffer)))))
>
> ;;;###autoload
> (defun project-switch-to-buffer (buffer-or-name)
That looks good and it fixes all the bug cases I mentioned.
But what about the case where the old buffer was already in the project?
1. In a buffer visiting project-a/some/dir/file.el
2. C-x p b nonexisting-buffer RET
Existing behavior, and possibly desirable behavior:
3. default-directory in new buffer: project-a/some/dir/
With your change:
3. default-directory in new buffer: project-a/
next prev parent reply other threads:[~2023-04-21 16:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 18:37 bug#62974: 29.0.60; New buffers created with project-switch-to-buffer aren't in the project Spencer Baugh
2023-04-20 18:55 ` Eli Zaretskii
2023-04-20 23:55 ` Dmitry Gutov
2023-04-21 5:43 ` Eli Zaretskii
2023-04-21 11:46 ` Spencer Baugh
2023-04-21 12:00 ` Eli Zaretskii
2023-04-21 13:17 ` sbaugh
2023-04-21 15:56 ` Dmitry Gutov
2023-04-21 16:25 ` Spencer Baugh [this message]
2023-04-21 23:31 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ier7cu5yzg2.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=62974@debbugs.gnu.org \
--cc=dmitry@gutov.dev \
--cc=eliz@gnu.org \
--cc=sbaugh@catern.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).