GNU bug report logs - #41879
28.0.50; [Patch]: Add project-switch-to-buffer in project.el

Previous Next

Package: emacs;

Reported by: Theodor Thornhill <theo <at> thornhill.no>

Date: Mon, 15 Jun 2020 17:52:01 UTC

Severity: normal

Tags: patch

Found in version 28.0.50

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41879 in the body.
You can then email your comments to 41879 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 15 Jun 2020 17:52:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Theodor Thornhill <theo <at> thornhill.no>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 15 Jun 2020 17:52:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; [Patch]: Add project-switch-to-buffer in project.el
Date: Mon, 15 Jun 2020 17:45:53 +0000
[Message part 1 (text/plain, inline)]
Hello!

This patch is directly dependent on https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41868
since I reused one of the functions added by Philip K.

For now I rely on that report to be resolved before this.

However, attached is a patch for project-switch-to-buffer, where only file-bound buffers are included. I believe the function should be kind of self explanatory.

I use this daily, but stole the buffer list function since it was better than my initial one, and seems to be accepted soon :)

I find this useful, and hope others will as well. I bind it myself to 'C-x p b'.

The 'project--list-buffers' will not be part of the final patch, but I wanted to provide it so that you have a working example.

Theodor

[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 15 Jun 2020 18:32:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Philip K." <philip <at> warpmail.net>
To: Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Mon, 15 Jun 2020 20:29:52 +0200
Cool! Just note that in the following patch I renamed the function to
project--buffer-list, so that it looks and acts more like
buffer-list. Sorry for the inconvenience though, didn't expect anyone
to pick the function up that quickly. 

-- 
	Philip K.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 15 Jun 2020 20:56:02 GMT) Full text and rfc822 format available.

Message #11 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Theodor Thornhill <theo <at> thornhill.no>, 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Mon, 15 Jun 2020 23:55:16 +0300
On 15.06.2020 20:45, Theodor Thornhill wrote:
> I find this useful, and hope others will as well. I bind it myself to 'C-x p b'.

Sounds good.

> The 'project--list-buffers' will not be part of the final patch, but I wanted to provide it so that you have a working example.

I see that the code uses project--completing-read-strict. I'm not 
entirely happy with that function, yet.

Have you tried calling read-buffer with a PREDICATE argument instead? 
That would require extracting some code from project--list-buffers 
(defined in Philip's patch), but it should be straightforward.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 15 Jun 2020 22:07:02 GMT) Full text and rfc822 format available.

Message #14 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Dmitry Gutov <dgutov <at> yandex.ru>, 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Mon, 15 Jun 2020 22:05:59 +0000
[Message part 1 (text/plain, inline)]
Hey,
"Dmitry Gutov" <dgutov <at> yandex.ru> writes:


[...]
> I see that the code uses project--completing-read-strict. I'm not
> entirely happy with that function, yet.
Ok, I just thought I'd use something already written :)

>
> Have you tried calling read-buffer with a PREDICATE argument instead?
> That would require extracting some code from project--list-buffers
> (defined in Philip's patch), but it should be straightforward.

The attached patch works fine, and is also not reliant on Philip's patch. I omitted the DEF argument, since then I had to do the filtering beforehand, and also in the PREDICATE function. Just seems a little redundant to me, but maybe it should be there

The complete patch is a lot smaller now as well!
What do you think?

Theo

[pr-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 15 Jun 2020 23:39:01 GMT) Full text and rfc822 format available.

Message #17 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Theodor Thornhill <theo <at> thornhill.no>, 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 02:38:21 +0300
Thank you.

On 16.06.2020 01:05, Theodor Thornhill wrote:
> What do you think?

A few more notes. :-)

> +      "Switch-to-buffer: " nil nil

The REQUIRE-MATCH argument should be t, I think.

> +      (lambda (buffer)
> +        (when-let* ((path (buffer-file-name (cdr buffer)))

The word "path" is reserved for something else (e.g. exec-path) in the 
GNU project.

Call it file or file-name.

> +                    (true (file-truename path)))

Do we need this conversion? It'll add some runtime overhead, and I'm not 
sure in which conditions the result will be different.

> +          (when (file-in-directory-p true (project-root pr))
> +            'buffer)))))))

Why 'buffer and not t?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 00:03:03 GMT) Full text and rfc822 format available.

Message #20 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 02:10:23 +0300
> However, attached is a patch for project-switch-to-buffer, where only
> file-bound buffers are included.  I believe the function should be
> kind of self explanatory.
>
> I find this useful, and hope others will as well. I bind it myself to 'C-x p b'.

Nice, I consider your new project-switch-to-buffer as an accompanying
command with the existing project-find-file (that could get a keybinding too,
the most natural would be 'C-x p f').




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 00:22:01 GMT) Full text and rfc822 format available.

Message #23 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>, Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 03:21:27 +0300
On 16.06.2020 02:10, Juri Linkov wrote:
> Nice, I consider your new project-switch-to-buffer as an accompanying
> command with the existing project-find-file (that could get a keybinding too,
> the most natural would be 'C-x p f')

Would you like to create a patch that adds a global keymap for project 
related commands?

I've been putting it off myself. The question I've been considering:

Do we keep it in project.el or somewhere outside? Maybe the latter, 
since project.el is also an ELPA package, and we generally don't want 
packages to alter Emacs' key bindings right after installation.

OTOH, if the prefix is customizable, that can also be fine.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 05:46:01 GMT) Full text and rfc822 format available.

Message #26 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Dmitry Gutov <dgutov <at> yandex.ru>, 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Tue, 16 Jun 2020 05:45:34 +0000
[Message part 1 (text/plain, inline)]
Thanks alot for your comments!

"Dmitry Gutov" <dgutov <at> yandex.ru> writes:

[...]
> The REQUIRE-MATCH argument should be t, I think.
Done.

>  > +      (lambda (buffer)
>  > +        (when-let* ((path (buffer-file-name (cdr buffer)))

[...]

> Call it file or file-name.
Done.


>  > +                    (true (file-truename path)))
>
> Do we need this conversion? It'll add some runtime overhead, and I'm not
> sure in which conditions the result will be different.
I removed it, seems to work fine :).


>  > +          (when (file-in-directory-p true (project-root pr))
>  > +            'buffer)))))))
>
> Why 'buffer and not t?
I just figured it as readable, but t is there now!

Theo

[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 06:12:02 GMT) Full text and rfc822 format available.

Message #29 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: "Philip K." <philip <at> warpmail.net>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 08:11:46 +0200
Theodor Thornhill <theo <at> thornhill.no> writes:

> +;;;###autoload
> +(defun project-switch-to-buffer ()
> +  "Switch to a buffer in the current project."
> +  (interactive)
> +  (let ((root (project-root (project-current t))))
> +    (switch-to-buffer
> +     (read-buffer
> +      "Switch-to-buffer: " nil t
> +      (lambda (buffer)
> +        (when-let ((file (buffer-file-name (cdr buffer))))
> +          (when (file-in-directory-p file root)
> +            t)))))))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Shouldn't this just be (file-in-directory-p file root), without the
(when ... t)?

-- 
	Philip K.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 06:50:01 GMT) Full text and rfc822 format available.

Message #32 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: "Philip K." <philip <at> warpmail.net>
Cc: 41879 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Tue, 16 Jun 2020 06:49:01 +0000
[Message part 1 (text/plain, inline)]
Hi!

"Philip K." <philip <at> warpmail.net> writes:

[...]

> Shouldn't this just be (file-in-directory-p file root), without the
> (when ... t)?
Yes! Thanks a lot :)


Theo

[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 10:27:02 GMT) Full text and rfc822 format available.

Message #35 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org, "Philip K." <philip <at> warpmail.net>,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 11:26:04 +0100
Theodor Thornhill <theo <at> thornhill.no> writes:

> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 218058b195..a61b29abe6 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -753,6 +753,18 @@ project-compile
>           (default-directory (project-root pr)))
>      (compile command comint)))
>  
> +;;;###autoload
> +(defun project-switch-to-buffer ()
> +  "Switch to a buffer in the current project."
> +  (interactive)
> +  (let ((root (project-root (project-current t))))
> +    (switch-to-buffer
> +     (read-buffer
> +      "Switch-to-buffer: " nil t

Nit: For consistency with switch-to-buffer,
this should be "Switch to buffer: " without the hyphens.

> +      (lambda (buffer)
> +        (when-let ((file (buffer-file-name (cdr buffer))))

Nit: Neither the manual nor read-buffer's docstring documents what
(cdr buffer) is here, so a comment mentioning Vbuffer_alist or something
along those lines would be nice.

> +          (file-in-directory-p file root)))))))
> +

Otherwise LGTM, thanks,

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 13:30:02 GMT) Full text and rfc822 format available.

Message #38 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 41879 <at> debbugs.gnu.org, "Philip K." <philip <at> warpmail.net>,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Tue, 16 Jun 2020 13:29:19 +0000
Hello!

"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:


[...]
> Nit: For consistency with switch-to-buffer,
> this should be "Switch to buffer: " without the hyphens.

Yes, absolutely!

>> +      (lambda (buffer)
>> +        (when-let ((file (buffer-file-name (cdr buffer))))
>
> Nit: Neither the manual nor read-buffer's docstring documents what
> (cdr buffer) is here, so a comment mentioning Vbuffer_alist or something
> along those lines would be nice.
It kind of does, though indirectly? But sure, I can add a small comment.

Documentation states that:

 "It will be called with each potential candidate, in the form of either a
string or a cons cell whose ‘car’ is a string, and should return non-nil to
accept the candidate for completion, nil otherwise."

[...]
> Otherwise LGTM, thanks,
Nice





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 14:03:02 GMT) Full text and rfc822 format available.

Message #41 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org, "Philip K." <philip <at> warpmail.net>,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 15:02:13 +0100
Theodor Thornhill <theo <at> thornhill.no> writes:

>>> +      (lambda (buffer)
>>> +        (when-let ((file (buffer-file-name (cdr buffer))))
>>
>> Nit: Neither the manual nor read-buffer's docstring documents what
>> (cdr buffer) is here, so a comment mentioning Vbuffer_alist or something
>> along those lines would be nice.
> It kind of does, though indirectly? But sure, I can add a small comment.
>
> Documentation states that:
>
>  "It will be called with each potential candidate, in the form of either a
> string or a cons cell whose ‘car’ is a string, and should return non-nil to
> accept the candidate for completion, nil otherwise."

I know, but this says nothing about the cdr.

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 16:54:01 GMT) Full text and rfc822 format available.

Message #44 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 41879 <at> debbugs.gnu.org, "Philip K." <philip <at> warpmail.net>,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Tue, 16 Jun 2020 16:53:01 +0000
[Message part 1 (text/plain, inline)]
Hello,

"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> I know, but this says nothing about the cdr.

Maybe like this?

Theo

[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 18:20:01 GMT) Full text and rfc822 format available.

Message #47 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org, "Philip K." <philip <at> warpmail.net>,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 19:19:41 +0100
Theodor Thornhill <theo <at> thornhill.no> writes:

> +;;;###autoload
> +(defun project-switch-to-buffer ()
> +  "Switch to a buffer in the current project."
> +  (interactive)
> +  (let ((root (project-root (project-current t))))
> +    (switch-to-buffer
> +     (read-buffer
> +      "Switch to buffer: " nil t
> +      (lambda (buffer)
> +        ;; buffer is a alist of ("filename" . #<buffer filename>)

That's not right: BUFFER is a flat cons cell, not an alist.  Please also
start sentences with a capital letter and end them with a full stop.
I'd write something like this:

  ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.

> +        (when-let ((file (buffer-file-name (cdr buffer))))
> +          (file-in-directory-p file root)))))))

Thanks,

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 18:59:01 GMT) Full text and rfc822 format available.

Message #50 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Tue, 16 Jun 2020 18:58:33 +0000
[Message part 1 (text/plain, inline)]
Hi!
Thanks for your keen eye :)

> I'd write something like this:
>
>   ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
>

Got it. I stole your comment - I hope that is OK?


Theo
[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 20:38:01 GMT) Full text and rfc822 format available.

Message #53 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 21:37:26 +0100
Theodor Thornhill <theo <at> thornhill.no> writes:

> Thanks for your keen eye :)

Thanks for all your useful contributions!

>> I'd write something like this:
>>
>>   ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
>>
>
> Got it. I stole your comment - I hope that is OK?

Of course.
In decreasing order of preference: improved > stolen > ignored. ;)

> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index f3df44fa7b..52e8ef4ff9 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -744,6 +744,19 @@ project-compile
>           (default-directory (project-root pr)))
>      (compile command comint)))
>  
> +;;;###autoload
> +(defun project-switch-to-buffer ()
> +  "Switch to a buffer in the current project."
> +  (interactive)
> +  (let ((root (project-root (project-current t))))
> +    (switch-to-buffer
> +     (read-buffer
> +      "Switch to buffer: " nil t
> +      (lambda (buffer)
> +        ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
> +        (when-let ((file (buffer-file-name (cdr buffer))))
> +          (file-in-directory-p file root)))))))

LGTM, thanks.

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 21:41:01 GMT) Full text and rfc822 format available.

Message #56 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org, "Philip K." <philip <at> warpmail.net>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Wed, 17 Jun 2020 00:40:25 +0300
On 16.06.2020 21:19, Basil L. Contovounesios wrote:
>    ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.

I don't think we can/should refer to C level variables from Lisp 
documentation.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 21:59:02 GMT) Full text and rfc822 format available.

Message #59 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org, "Philip
 K." <philip <at> warpmail.net>, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Tue, 16 Jun 2020 22:58:12 +0100
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 16.06.2020 21:19, Basil L. Contovounesios wrote:
>>    ;; BUFFER is an entry (BUF-NAME . BUF-OBJ) of Vbuffer_alist.
>
> I don't think we can/should refer to C level variables from Lisp documentation.

This is a source comment, not public documentation, and the relevant
code relies on an undocumented C-level implementation detail (the use of
Vbuffer_alist as a completion collection in read-buffer) so I think the
comment (or something along those lines; feel free to suggest
improvements) is appropriate.

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 22:12:01 GMT) Full text and rfc822 format available.

Message #62 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 41879 <at> debbugs.gnu.org, "Philip K." <philip <at> warpmail.net>,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Wed, 17 Jun 2020 01:11:34 +0300
On 17.06.2020 00:58, Basil L. Contovounesios wrote:
> This is a source comment, not public documentation, and the relevant
> code relies on an undocumented C-level implementation detail (the use of
> Vbuffer_alist as a completion collection in read-buffer) so I think the
> comment (or something along those lines; feel free to suggest
> improvements) is appropriate.

I see. All right then.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Tue, 16 Jun 2020 22:40:02 GMT) Full text and rfc822 format available.

Message #65 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Theodor Thornhill <theo <at> thornhill.no>,
 "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Wed, 17 Jun 2020 01:39:42 +0300
On 16.06.2020 21:58, Theodor Thornhill wrote:
> Got it. I stole your comment - I hope that is OK?

Looking good, thanks.

I'll install it tomorrow or so.




Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Wed, 17 Jun 2020 23:12:01 GMT) Full text and rfc822 format available.

Notification sent to Theodor Thornhill <theo <at> thornhill.no>:
bug acknowledged by developer. (Wed, 17 Jun 2020 23:12:02 GMT) Full text and rfc822 format available.

Message #70 received at 41879-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Theodor Thornhill <theo <at> thornhill.no>,
 "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 41879-done <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 02:10:52 +0300
On 16.06.2020 21:58, Theodor Thornhill wrote:
> Got it. I stole your comment - I hope that is OK?

Also installed. Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 09:42:01 GMT) Full text and rfc822 format available.

Message #73 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 12:41:30 +0300
Hi Theodor,

> However, attached is a patch for project-switch-to-buffer, where only
> file-bound buffers are included. I believe the function should be kind
> of self explanatory.

Can you please tell why only file-bound buffers are included?  I have
some buffers with inferior python process in each project, would be nice
to switch to them with project-switch-to-buffer.

Also consider to provide default value like:

    (buffer-name (other-buffer (current-buffer)))

This way one can switch to recent project buffer with just RET, same way
as switch-to-buffer.

Thanks for your work!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 10:12:02 GMT) Full text and rfc822 format available.

Message #76 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Thu, 18 Jun 2020 10:11:19 +0000
> Hi Theodor,
Hi!

> Can you please tell why only file-bound buffers are included?  I have
> some buffers with inferior python process in each project, would be nice
> to switch to them with project-switch-to-buffer.

Well, I tried a few different ways of including other buffers as well, but emacs seemed to want to include earlier used minibuffers and all sorts of 'junk'.  I agree that these inferior processes should be interesting to include, though.  I can try to find some way to filter out the cruft a bit better!  Do you have a specific idea in mind to go from?  

> Also consider to provide default value like:
>
>     (buffer-name (other-buffer (current-buffer)))
>
> This way one can switch to recent project buffer with just RET, same way
> as switch-to-buffer.

This seems smart! I'll look into that as well :) Thanks!

Theo





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 10:32:02 GMT) Full text and rfc822 format available.

Message #79 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Thu, 18 Jun 2020 10:31:28 +0000
[Message part 1 (text/plain, inline)]
That was a lousy diff, sorry...

Theo

[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 10:32:02 GMT) Full text and rfc822 format available.

Message #82 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Thu, 18 Jun 2020 10:26:05 +0000
[Message part 1 (text/plain, inline)]
On the other hand, what do you think about this one?

Now you will get buffers such as '*xref*' and I assume your inferior buffers as well. Could you try this? I added your 'other-buffer' thing also for good measure :)

Theo

[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 10:49:02 GMT) Full text and rfc822 format available.

Message #85 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 13:48:12 +0300
Theodor Thornhill <theo <at> thornhill.no> writes:

> That was a lousy diff, sorry...

Much better!

Few more things:

- Check if other-buffer is passes the predicate function.  The buffer
  from another project must not be the default.
- Exclude the current buffer from the buffers list to switch to.

Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 11:08:01 GMT) Full text and rfc822 format available.

Message #88 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>,
 Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 14:07:39 +0300
On 18.06.2020 13:48, Andrii Kolomoiets wrote:
> Much better!
> 
> Few more things:
> 
> - Check if other-buffer is passes the predicate function.  The buffer
>    from another project must not be the default.
> - Exclude the current buffer from the buffers list to switch to.

Perhaps a good idea is to follow the example of 
internal-complete-buffer-except (called from read-buffer-to-switch).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 11:31:01 GMT) Full text and rfc822 format available.

Message #91 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 14:30:32 +0300
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 18.06.2020 13:48, Andrii Kolomoiets wrote:
>> Much better!
>> Few more things:
>> - Check if other-buffer is passes the predicate function.  The
>> buffer
>>    from another project must not be the default.
>> - Exclude the current buffer from the buffers list to switch to.
>
> Perhaps a good idea is to follow the example of
> internal-complete-buffer-except (called from read-buffer-to-switch).

Isn't it enough to check `(not (eq (cdr buffer) (current-buffer)))` in
the predicate function?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 11:36:02 GMT) Full text and rfc822 format available.

Message #94 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 14:35:13 +0300
On 18.06.2020 14:30, Andrii Kolomoiets wrote:
> Isn't it enough to check `(not (eq (cdr buffer) (current-buffer)))` in
> the predicate function?

It should also filter out the buffers where the names start with 
whitespace. Unless there are no other completions.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 11:49:01 GMT) Full text and rfc822 format available.

Message #97 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 14:47:50 +0300
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 18.06.2020 14:30, Andrii Kolomoiets wrote:
>> Isn't it enough to check `(not (eq (cdr buffer) (current-buffer)))` in
>> the predicate function?
>
> It should also filter out the buffers where the names start with
> whitespace. Unless there are no other completions.

No, it shouldn't.  read-buffer already shows normal buffers as
completions on TAB and shows hidden buffers as completions after SPC
is entered.  See internal-complete-buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 13:01:02 GMT) Full text and rfc822 format available.

Message #100 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 16:00:38 +0300
On 18.06.2020 14:47, Andrii Kolomoiets wrote:
> No, it shouldn't.  read-buffer already shows normal buffers as
> completions on TAB and shows hidden buffers as completions after SPC
> is entered.  See internal-complete-buffer.

Ah, you're right. internal-complete-buffer is used either way.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 18:04:01 GMT) Full text and rfc822 format available.

Message #103 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 21:03:13 +0300
[Message part 1 (text/plain, inline)]
Hi Theodor,

Please take a look at the attached patch.  It's based on your patch and
resolves this:

> - Check if other-buffer is passes the predicate function.  The buffer
>   from another project must not be the default.
> - Exclude the current buffer from the buffers list to switch to.

Thanks!

[project-switch-to-buffer.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 18:51:01 GMT) Full text and rfc822 format available.

Message #106 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Thu, 18 Jun 2020 18:49:52 +0000
> Hi Theodor,
Hi!

> Please take a look at the attached patch.  
That's very cool! I was sitting right now doing something similar, but you beat me to it.  Sorry for not getting to it faster - life happened :)

I was struggling a little with the default buffer part, which you solved by kinda not solving it.  I was trying to determine in some way what buffer would be reasonable to offer as default value if that predicate fails.  Maybe it is best to just return nil there as you do. 

Maybe just one thing.  Eli addressed the docstring in one of the other functions as being a little ambiguous.  Maybe update it to something like:

"Switch to an open buffer in the current project."

In addition, maybe adding a small comment above the default value predicate, explaining the relation to the undocumentet structure used in this function.  Or not, maybe it is clear enough given the preceeding comment. 

Thank you for bringing this up - and fixing it!

Theo





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Thu, 18 Jun 2020 19:37:01 GMT) Full text and rfc822 format available.

Message #109 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org, Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Thu, 18 Jun 2020 20:35:59 +0100
Theodor Thornhill <theo <at> thornhill.no> writes:

> Maybe just one thing.  Eli addressed the docstring in one of the other functions
> as being a little ambiguous.  Maybe update it to something like:
>
> "Switch to an open buffer in the current project."

FWIW, it is unclear what "open" means in this context, as it is not a
term commonly used to describe buffers.  Possible alternatives include
whether it's displayed somewhere or buried, whether it's live or killed,
etc.

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Fri, 19 Jun 2020 00:44:01 GMT) Full text and rfc822 format available.

Message #112 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org, Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Fri, 19 Jun 2020 03:43:19 +0300
On 18.06.2020 22:35, Basil L. Contovounesios wrote:
> FWIW, it is unclear what "open" means in this context, as it is not a
> term commonly used to describe buffers.  Possible alternatives include
> whether it's displayed somewhere or buried, whether it's live or killed,
> etc.

And it's not like any command is going to help you switch to a killed 
buffer.

"Open" sounds like a tautology indeed.

Here's a option from me: "Switch to another buffer belonging to the 
current project".

But personally, I think the current docstring is easy to understand already.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Fri, 19 Jun 2020 00:46:02 GMT) Full text and rfc822 format available.

Message #115 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>,
 Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Fri, 19 Jun 2020 03:45:44 +0300
On 18.06.2020 21:03, Andrii Kolomoiets wrote:
> Please take a look at the attached patch.  It's based on your patch and
> resolves this:
> 
>> - Check if other-buffer is passes the predicate function.  The buffer
>>    from another project must not be the default.
>> - Exclude the current buffer from the buffers list to switch to.
> Thanks!

Thanks! Pushed.

Something to consider: switch-to-buffer still allows you to choose the 
current buffer. And the new command doesn't.

I'm not sure of the original logic behind this, though.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Fri, 19 Jun 2020 04:51:01 GMT) Full text and rfc822 format available.

Message #118 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Fri, 19 Jun 2020 07:50:30 +0300
Theodor Thornhill <theo <at> thornhill.no> writes:

> you beat me to it.  Sorry for not getting to it faster - life happened
> :)

No problem at all.

> I was struggling a little with the default buffer part, which you
> solved by kinda not solving it.  I was trying to determine in some way
> what buffer would be reasonable to offer as default value if that
> predicate fails.  Maybe it is best to just return nil there as you do.

Or we can pass the predicate function to the `other-buffer` function so
it will return only buffer from the current project too!  We just need
to make `other-buffer` accept predicate first :)

> Thank you for bringing this up - and fixing it!

And thank you for the original command! One local function less ;)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Fri, 19 Jun 2020 05:00:02 GMT) Full text and rfc822 format available.

Message #121 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Fri, 19 Jun 2020 07:59:17 +0300
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> Something to consider: switch-to-buffer still allows you to choose the
> current buffer. And the new command doesn't.

Furthermore, by not requiring a match, switch-to-buffer allows to create
buffers.

> I'm not sure of the original logic behind this, though.

Theodor, can you please tell the reason why is REQUIRE-MATCH set to t in
the read-buffer call?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Fri, 19 Jun 2020 05:29:02 GMT) Full text and rfc822 format available.

Message #124 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Theodor Thornhill <theo <at> thornhill.no>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>, Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Fri, 19 Jun 2020 05:27:49 +0000
[Message part 1 (text/plain, inline)]
> Theodor, can you please tell the reason why is REQUIRE-MATCH set to t in
> the read-buffer call?

I believe Dmitry told me to, actually. I can see if I can find the mail. I’m fine with it being nil, as it was in the first patch.

Theo

>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Fri, 19 Jun 2020 11:01:01 GMT) Full text and rfc822 format available.

Message #127 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Fri, 19 Jun 2020 14:00:27 +0300
On 19.06.2020 07:59, Andrii Kolomoiets wrote:
> Furthermore, by not requiring a match, switch-to-buffer allows to create
> buffers.

Right.

Do you need this ability? I would imagine switch-to-buffer is always 
available for that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Sat, 20 Jun 2020 08:37:01 GMT) Full text and rfc822 format available.

Message #130 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Sat, 20 Jun 2020 11:35:59 +0300
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 19.06.2020 07:59, Andrii Kolomoiets wrote:
>> Furthermore, by not requiring a match, switch-to-buffer allows to create
>> buffers.
>
> Right.
>
> Do you need this ability? I would imagine switch-to-buffer is always
> available for that.

Well, I rarely use this ability of switch-to-buffer.  I can't say I
really need this in project-switch-to-buffer.

But to keep consistency with switch-to-buffer, project-switch-to-buffer
should behave the same.

Also, in my understanding, match is should be required on e.g. killing
buffers when existing buffer is required.  Because switch-to-buffer is
able to create buffers, I can't see the reason why
project-switch-to-buffer should require the match.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Sun, 21 Jun 2020 01:06:01 GMT) Full text and rfc822 format available.

Message #133 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Sun, 21 Jun 2020 04:04:57 +0300
On 20.06.2020 11:35, Andrii Kolomoiets wrote:
> Dmitry Gutov <dgutov <at> yandex.ru> writes:
> 
>> On 19.06.2020 07:59, Andrii Kolomoiets wrote:
>>> Furthermore, by not requiring a match, switch-to-buffer allows to create
>>> buffers.
>>
>> Right.
>>
>> Do you need this ability? I would imagine switch-to-buffer is always
>> available for that.
> 
> Well, I rarely use this ability of switch-to-buffer.  I can't say I
> really need this in project-switch-to-buffer.
> 
> But to keep consistency with switch-to-buffer, project-switch-to-buffer
> should behave the same.

There are other differences, too. The arglist, for example.

> Also, in my understanding, match is should be required on e.g. killing
> buffers when existing buffer is required.  Because switch-to-buffer is
> able to create buffers, I can't see the reason why
> project-switch-to-buffer should require the match.

To better protect from typos? It's not a very strong argument, of 
course. But "just for consistency" isn't one either.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 22 Jun 2020 09:32:01 GMT) Full text and rfc822 format available.

Message #136 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Mon, 22 Jun 2020 12:30:55 +0300
Dmitry Gutov <dgutov <at> yandex.ru> writes:

>> But to keep consistency with switch-to-buffer,
>> project-switch-to-buffer
>> should behave the same.
>
> There are other differences, too. The arglist, for example.

Well, NORECORD and FORCE-SAME-WINDOW can be passed to switch-to-buffer
easily if there is the need to.

>> buffers when existing buffer is required.  Because switch-to-buffer is
>> able to create buffers, I can't see the reason why
>> project-switch-to-buffer should require the match.
>
> To better protect from typos? It's not a very strong argument, of
> course. But "just for consistency" isn't one either.

How about "To be able to create buffers"? ;)  This way there are no need
to use switch-to-buffer for those who will use project-switch-to-buffer
solely.
Imagine project-switch-to-buffer is in your muscle memory. You need to
perform additional steps to create the buffer (C-g C-x b
type-buffer-name-again) just because the project-switch-to-buffer can't
create buffers with no reason.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 22 Jun 2020 13:47:01 GMT) Full text and rfc822 format available.

Message #139 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Mon, 22 Jun 2020 16:46:03 +0300
On 22.06.2020 12:30, Andrii Kolomoiets wrote:

>>> But to keep consistency with switch-to-buffer,
>>> project-switch-to-buffer
>>> should behave the same.
>>
>> There are other differences, too. The arglist, for example.
> 
> Well, NORECORD and FORCE-SAME-WINDOW can be passed to switch-to-buffer
> easily if there is the need to.

Everything can be added later. Adding new function arguments could be a 
bit more problematic than a slight change in semantics like 
REQUIRE-MATCH=nil, though.

>>> buffers when existing buffer is required.  Because switch-to-buffer is
>>> able to create buffers, I can't see the reason why
>>> project-switch-to-buffer should require the match.
>>
>> To better protect from typos? It's not a very strong argument, of
>> course. But "just for consistency" isn't one either.
> 
> How about "To be able to create buffers"? ;)  This way there are no need
> to use switch-to-buffer for those who will use project-switch-to-buffer
> solely.
> Imagine project-switch-to-buffer is in your muscle memory. You need to
> perform additional steps to create the buffer (C-g C-x b
> type-buffer-name-again) just because the project-switch-to-buffer can't
> create buffers with no reason.

All right. I'll change it to nil now.

Not sure I understand the passion behind your argument, though, since 
you said you're not going to need this yourself. But perhaps I 
misunderstood.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 22 Jun 2020 13:55:01 GMT) Full text and rfc822 format available.

Message #142 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41879 <at> debbugs.gnu.org, Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50; [Patch]: Add project-switch-to-buffer in
 project.el
Date: Mon, 22 Jun 2020 16:54:15 +0300
Dmitry Gutov <dgutov <at> yandex.ru> writes:

>> Imagine project-switch-to-buffer is in your muscle memory. You need to
>> perform additional steps to create the buffer (C-g C-x b
>> type-buffer-name-again) just because the project-switch-to-buffer can't
>> create buffers with no reason.
>
> All right. I'll change it to nil now.
>
> Not sure I understand the passion behind your argument, though, since
> you said you're not going to need this yourself. But perhaps I 
> misunderstood.

I'm rarely use this feature, but when I'll need it it's great that
`project-switch-to-buffer` support it.

Thank you!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41879; Package emacs. (Mon, 22 Jun 2020 15:00:02 GMT) Full text and rfc822 format available.

Message #145 received at 41879 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Andrii Kolomoiets <andreyk.mad <at> gmail.com>
Cc: "41879 <at> debbugs.gnu.org" <41879 <at> debbugs.gnu.org>,
 Theodor Thornhill <theo <at> thornhill.no>
Subject: Re: bug#41879: 28.0.50;
 [Patch]: Add project-switch-to-buffer in project.el
Date: Mon, 22 Jun 2020 17:59:11 +0300
[Message part 1 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 21 Jul 2020 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 333 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.