all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* patch gud-gdb to respect other-frame-window?
@ 2018-07-29 17:22 Stephen Leake
  2018-07-29 17:30 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Stephen Leake @ 2018-07-29 17:22 UTC (permalink / raw)
  To: emacs-devel

Currently, 'gud-gdb' has its own notion of where to put the *gud-<exec name>*
buffer. Since I use other-frame-window (a GNU ELPA package), I'd like to
override that. This patch works for me:

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 6826674a94..1b5cf46231 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -2608,9 +2608,11 @@ gud-common-init
     (select-window
      (display-buffer
       (get-buffer-create (concat "*gud" filepart "*"))
-      '(display-buffer-reuse-window
-        display-buffer-in-previous-window
-        display-buffer-same-window display-buffer-pop-up-window)))
+      (if (featurep 'other-frame-window)
+          '(display-buffer-same-window)
+        '(display-buffer-reuse-window
+          display-buffer-in-previous-window
+          display-buffer-same-window display-buffer-pop-up-window))))
     (when (and existing-buffer (get-buffer-process existing-buffer))
       (error "This program is already being debugged"))
     ;; Set the dir, in case the buffer already existed with a different dir.

A similar pattern can be used for other commands that do not currently
respect other-frame-window.

Ok to commit to master?

-- 
-- Stephe



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-29 17:22 patch gud-gdb to respect other-frame-window? Stephen Leake
@ 2018-07-29 17:30 ` Eli Zaretskii
  2018-07-30  6:56   ` Stephen Leake
  2018-07-30  6:23 ` martin rudalics
  2018-07-30 17:17 ` Stefan Monnier
  2 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2018-07-29 17:30 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel

> From: Stephen Leake <stephen_leake@stephe-leake.org>
> Date: Sun, 29 Jul 2018 12:22:55 -0500
> 
> diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
> index 6826674a94..1b5cf46231 100644
> --- a/lisp/progmodes/gud.el
> +++ b/lisp/progmodes/gud.el
> @@ -2608,9 +2608,11 @@ gud-common-init
>      (select-window
>       (display-buffer
>        (get-buffer-create (concat "*gud" filepart "*"))
> -      '(display-buffer-reuse-window
> -        display-buffer-in-previous-window
> -        display-buffer-same-window display-buffer-pop-up-window)))
> +      (if (featurep 'other-frame-window)
> +          '(display-buffer-same-window)
> +        '(display-buffer-reuse-window
> +          display-buffer-in-previous-window
> +          display-buffer-same-window display-buffer-pop-up-window))))
>      (when (and existing-buffer (get-buffer-process existing-buffer))
>        (error "This program is already being debugged"))
>      ;; Set the dir, in case the buffer already existed with a different dir.
> 
> A similar pattern can be used for other commands that do not currently
> respect other-frame-window.
> 
> Ok to commit to master?

Isn't there a more elegant way of doing this, without asking about a
feature explicitly?  Maybe other-frame-window needs some enhancement
to allow such protocols, otherwise we will need to test for each
similar feature by name, and that is both inelegant and a maintenance
burden, as both Emacs and those packages continue to evolve.

Thanks.



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-29 17:22 patch gud-gdb to respect other-frame-window? Stephen Leake
  2018-07-29 17:30 ` Eli Zaretskii
@ 2018-07-30  6:23 ` martin rudalics
  2018-07-30 17:17 ` Stefan Monnier
  2 siblings, 0 replies; 13+ messages in thread
From: martin rudalics @ 2018-07-30  6:23 UTC (permalink / raw)
  To: Stephen Leake, emacs-devel

 > A similar pattern can be used for other commands that do not currently
 > respect other-frame-window.
 >
 > Ok to commit to master?

No.  If a user and/or 'other-frame-window' can't fix that
systematically on their side, we have a more deeply rooted bug in
'display-buffer'.  In the latter case your patch would only cover that
up.

Please explain why the various 'display-buffer' customization
facilities are not sufficient for handling the problem.

Thanks, martin



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-29 17:30 ` Eli Zaretskii
@ 2018-07-30  6:56   ` Stephen Leake
  2018-07-30  7:34     ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Leake @ 2018-07-30  6:56 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Stephen Leake <stephen_leake@stephe-leake.org>
>> Date: Sun, 29 Jul 2018 12:22:55 -0500
>> 
>> diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
>> index 6826674a94..1b5cf46231 100644
>> --- a/lisp/progmodes/gud.el
>> +++ b/lisp/progmodes/gud.el
>> @@ -2608,9 +2608,11 @@ gud-common-init
>>      (select-window
>>       (display-buffer
>>        (get-buffer-create (concat "*gud" filepart "*"))
>> -      '(display-buffer-reuse-window
>> -        display-buffer-in-previous-window
>> -        display-buffer-same-window display-buffer-pop-up-window)))
>> +      (if (featurep 'other-frame-window)
>> +          '(display-buffer-same-window)
>> +        '(display-buffer-reuse-window
>> +          display-buffer-in-previous-window
>> +          display-buffer-same-window display-buffer-pop-up-window))))
>>      (when (and existing-buffer (get-buffer-process existing-buffer))
>>        (error "This program is already being debugged"))
>>      ;; Set the dir, in case the buffer already existed with a different dir.
>> 
>> A similar pattern can be used for other commands that do not currently
>> respect other-frame-window.
>> 
>> Ok to commit to master?
>
> Isn't there a more elegant way of doing this, without asking about a
> feature explicitly?  

Never mind; I realized I can set 'display-buffer-overriding-action' to
'display-buffer-same-window in my ~/.emacs; that overrides this code,
and still lets other-frame-window do its thing. So this patch, and
others like it, it unecessary.

I'll add this to the documentation in other-frame-window.

-- 
-- Stephe



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-30  6:56   ` Stephen Leake
@ 2018-07-30  7:34     ` martin rudalics
  2018-07-30 16:49       ` Stephen Leake
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2018-07-30  7:34 UTC (permalink / raw)
  To: Stephen Leake, emacs-devel

 > Never mind; I realized I can set 'display-buffer-overriding-action' to
 > 'display-buffer-same-window in my ~/.emacs; that overrides this code,
 > and still lets other-frame-window do its thing.

Please don't.

If 'other-frame-window' sets 'display-buffer-overriding-action'
itself, then it should _not_ be overridden by the user.  It's a simple
statement that 'other-frame-window' thinks that it is always right in
its decision and the user has to either take it or leave it.  If
'other-frame-window' does not set 'display-buffer-overriding-action'
itself, then customizing 'display-buffer-alist' should suffice.
That's the variable intended for users.  If this doesn't help we have
a bug we must investigate.

Thanks, martin



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-30  7:34     ` martin rudalics
@ 2018-07-30 16:49       ` Stephen Leake
  2018-07-31  6:37         ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Leake @ 2018-07-30 16:49 UTC (permalink / raw)
  To: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

>> Never mind; I realized I can set 'display-buffer-overriding-action' to
>> 'display-buffer-same-window in my ~/.emacs; that overrides this code,
>> and still lets other-frame-window do its thing.
>
> Please don't.
>
> If 'other-frame-window' sets 'display-buffer-overriding-action'
> itself, then it should _not_ be overridden by the user.  

It's not quite that simple.

The current design of 'other-frame-window' only defines the behavior
when the other-frame or other-window prefixes are invoked; the behavior
with no prefix is left to the default Emacs code, or to a user-provided
'display-buffer-overriding-action'.

I don't remember if that was a concious decision, but in retrospect it
looks like the right one.

In more detail, 'other-frame-window' pushes overriding values in front
of user-set values in 'display-buffer-overriding-action' when the
other-window and other-frame prefixes are invoked, and pops them off
when the command is done, leaving the user-set values intact.

> It's a simple statement that 'other-frame-window' thinks that it is
> always right in its decision and the user has to either take it or
> leave it. 

Not quite; it is only right when the prefixes are invoked.

We could change 'other-frame-window' to set the no-prefix
'display-buffer-overriding-action' as well, but I think it is better to
leave that to the user; some might like the current Emacs default
behavior (I did, until I ran into this gud-gdb behavior).

-- 
-- Stephe



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-29 17:22 patch gud-gdb to respect other-frame-window? Stephen Leake
  2018-07-29 17:30 ` Eli Zaretskii
  2018-07-30  6:23 ` martin rudalics
@ 2018-07-30 17:17 ` Stefan Monnier
  2018-07-30 20:23   ` Stephen Leake
  2 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2018-07-30 17:17 UTC (permalink / raw)
  To: emacs-devel

> Currently, 'gud-gdb' has its own notion of where to put the *gud-<exec name>*
> buffer. Since I use other-frame-window (a GNU ELPA package), I'd like to
> override that.

Could you explain in more detail what's the problem you're seeing?

> Never mind; I realized I can set 'display-buffer-overriding-action' to
> 'display-buffer-same-window in my ~/.emacs; that overrides this code,

[ ... Trying to infer what was the problem, based on this apparently
  working workaround ... Nope, sorry, I still don't see what is the
  problem you're trying to solve.  ]

Just a wild guess: maybe the better solution would be for
other-frame-window to provide another command to force displaying the
buffer in the current window?


        Stefan




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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-30 17:17 ` Stefan Monnier
@ 2018-07-30 20:23   ` Stephen Leake
  2018-07-30 20:28     ` Stefan Monnier
  2018-07-30 20:30     ` Stephen Leake
  0 siblings, 2 replies; 13+ messages in thread
From: Stephen Leake @ 2018-07-30 20:23 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Currently, 'gud-gdb' has its own notion of where to put the *gud-<exec name>*
>> buffer. Since I use other-frame-window (a GNU ELPA package), I'd like to
>> override that.
>
> Could you explain in more detail what's the problem you're seeing?

Sorry, I was not very clear.

If I type "M-x gud-gdb ...", the window in which the *gdb-<exec>* buffer
is shown is usually not the currently selected window, but sometimes it
is, depending on what buffer/window is currently selected. There is a
logic to it, but it's not what I want.

Since I'm used to other-frame-window, I expect newly created buffers to
appear in the currently selected window; that's what happens for
find-file and most other commands.

>> Never mind; I realized I can set 'display-buffer-overriding-action' to
>> 'display-buffer-same-window in my ~/.emacs; that overrides this code,
>
> [ ... Trying to infer what was the problem, based on this apparently
>   working workaround ... Nope, sorry, I still don't see what is the
>   problem you're trying to solve.  ]
>
> Just a wild guess: maybe the better solution would be for
> other-frame-window to provide another command to force displaying the
> buffer in the current window?

As I said in my response to Martin, I think setting the default value of
'display-buffer-overriding-action' to 'display-buffer-same-window is the
appropriate solution. That variable is intended to allow the user to
override Emac's choices about buffer display, and other-frame-window's
use of it is consistent with that intent.


On further examining the list of available display-buffer actions,
perhaps this would be a better default:

'(display-buffer-reuse-window
  display-buffer--maybe-same-window
  display-buffer-use-some-window)

I'll try that.


It might make sense for other-frame-window to set this as the default
for 'display-buffer-overriding-action' when it is loaded, but only if
the user has not already set it. 

-- 
-- Stephe



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-30 20:23   ` Stephen Leake
@ 2018-07-30 20:28     ` Stefan Monnier
  2018-07-30 20:30     ` Stephen Leake
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2018-07-30 20:28 UTC (permalink / raw)
  To: emacs-devel

>> Just a wild guess: maybe the better solution would be for
>> other-frame-window to provide another command to force displaying the
>> buffer in the current window?
>
> As I said in my response to Martin, I think setting the default value of
> 'display-buffer-overriding-action' to 'display-buffer-same-window is the
> appropriate solution. That variable is intended to allow the user to
> override Emac's choices about buffer display, and other-frame-window's
> use of it is consistent with that intent.

No.  That's what `display-buffer-alist` is for.

`display-buffer-overriding-action` is intended for use of Elisp packages
like other-frame-window (notice it's not a defcustom, for example).


        Stefan




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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-30 20:23   ` Stephen Leake
  2018-07-30 20:28     ` Stefan Monnier
@ 2018-07-30 20:30     ` Stephen Leake
  2018-07-30 21:22       ` Stephen Leake
  1 sibling, 1 reply; 13+ messages in thread
From: Stephen Leake @ 2018-07-30 20:30 UTC (permalink / raw)
  To: emacs-devel

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>> Currently, 'gud-gdb' has its own notion of where to put the *gud-<exec name>*
>>> buffer. Since I use other-frame-window (a GNU ELPA package), I'd like to
>>> override that.
>>
>> Could you explain in more detail what's the problem you're seeing?
>
> Sorry, I was not very clear.
>
> If I type "M-x gud-gdb ...", the window in which the *gdb-<exec>* buffer
> is shown is usually not the currently selected window, but sometimes it
> is, depending on what buffer/window is currently selected. There is a
> logic to it, but it's not what I want.
>
> Since I'm used to other-frame-window, I expect newly created buffers to
> appear in the currently selected window; that's what happens for
> find-file and most other commands.


I just typed "C-h k ...", and the *Help* window appeared in a window
that is not the selected window. So there's more work to do ...

-- 
-- Stephe



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-30 20:30     ` Stephen Leake
@ 2018-07-30 21:22       ` Stephen Leake
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Leake @ 2018-07-30 21:22 UTC (permalink / raw)
  To: emacs-devel


Another data point. In a package I'm working on,
'wisi-show-parse-errors' shows errors found by the indent parser in a
small window at the bottom of the screen, using a display action of:

(cons #'display-buffer-at-bottom
			      (list (cons 'window-height
                              #'shrink-window-if-larger-than-buffer))).

But the default setting of 'display-buffer-overriding-action' overrides
that, and now the window takes half the screen.

So sometimes I want the default value that Emacs provides
(for wisi-show-parse-errors etc), and sometimes I don't (for gud-gdb etc).

So I need an exception mechanism; apply my default value for
display-buffer-overriding-action, except in the following buffers/modes.

Or invert that, only apply a default value for the following
buffers/modes/commands.

Ah; that's what 'display-buffer-alist is for. I'll try that.



Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>
>>>> Currently, 'gud-gdb' has its own notion of where to put the *gud-<exec name>*
>>>> buffer. Since I use other-frame-window (a GNU ELPA package), I'd like to
>>>> override that.
>>>
>>> Could you explain in more detail what's the problem you're seeing?
>>
>> Sorry, I was not very clear.
>>
>> If I type "M-x gud-gdb ...", the window in which the *gdb-<exec>* buffer
>> is shown is usually not the currently selected window, but sometimes it
>> is, depending on what buffer/window is currently selected. There is a
>> logic to it, but it's not what I want.
>>
>> Since I'm used to other-frame-window, I expect newly created buffers to
>> appear in the currently selected window; that's what happens for
>> find-file and most other commands.
>
>
> I just typed "C-h k ...", and the *Help* window appeared in a window
> that is not the selected window. So there's more work to do ...

-- 
-- Stephe



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

* Re: patch gud-gdb to respect other-frame-window?
  2018-07-30 16:49       ` Stephen Leake
@ 2018-07-31  6:37         ` martin rudalics
  2018-07-31  9:21           ` [SPAM UNSURE] " Stephen Leake
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2018-07-31  6:37 UTC (permalink / raw)
  To: Stephen Leake, emacs-devel

 > The current design of 'other-frame-window' only defines the behavior
 > when the other-frame or other-window prefixes are invoked;

In that case the special behavior specified by 'other-frame-window' is
supposed to prevail any preferences stored in 'display-buffer-alist'.
This is precisely one of the cases 'display-buffer-overriding-action'
has been added for.

 > the behavior
 > with no prefix is left to the default Emacs code,

Which means that in such case 'other-frame-window' should refrain from
touching 'display-buffer-overriding-action' and leave the decision of
what to do to 'display-buffer-alist'.

 > or to a user-provided
 > 'display-buffer-overriding-action'.

There should be no such thing.  If someone sees an absolute need for
it, we have a design bug.

 >> It's a simple statement that 'other-frame-window' thinks that it is
 >> always right in its decision and the user has to either take it or
 >> leave it.
 >
 > Not quite; it is only right when the prefixes are invoked.

Then 'other-frame-window' does something it should not do when no
prefixes are invoked.

martin



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

* Re: [SPAM UNSURE] Re: patch gud-gdb to respect other-frame-window?
  2018-07-31  6:37         ` martin rudalics
@ 2018-07-31  9:21           ` Stephen Leake
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Leake @ 2018-07-31  9:21 UTC (permalink / raw)
  To: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

>> or to a user-provided
>> 'display-buffer-overriding-action'.
>
> There should be no such thing.  If someone sees an absolute need for
> it, we have a design bug.

Right; that's what 'display-buffer-alist' is for; I was unaware of that
until now.


-- 
-- Stephe



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

end of thread, other threads:[~2018-07-31  9:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-29 17:22 patch gud-gdb to respect other-frame-window? Stephen Leake
2018-07-29 17:30 ` Eli Zaretskii
2018-07-30  6:56   ` Stephen Leake
2018-07-30  7:34     ` martin rudalics
2018-07-30 16:49       ` Stephen Leake
2018-07-31  6:37         ` martin rudalics
2018-07-31  9:21           ` [SPAM UNSURE] " Stephen Leake
2018-07-30  6:23 ` martin rudalics
2018-07-30 17:17 ` Stefan Monnier
2018-07-30 20:23   ` Stephen Leake
2018-07-30 20:28     ` Stefan Monnier
2018-07-30 20:30     ` Stephen Leake
2018-07-30 21:22       ` Stephen Leake

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.