Subject: bug#64619: [PATCH] Add toggle-window-dedicated command

From: Drew Adams <[email-masked]>
Date: Sat, 15 Jul 2023 21:30:17 +0000

> > 1. Why _weakly_ dedicated?
> 
> AFAIK, the difference is that if you explicitly try to switch buffer
> with e.g. C-x b, you succeed when the dedication is weak, and fail with
> an error when the dedication is strong.  I find that if I explicitly hit
> C-x b, I want to actually switch buffers in the current window, I never
> want the switch to fail.  Making it fail seems useful for Lisp programs,
> sometimes, but not so much interactive usage.

Thanks for providing your reasons/rationale.
That's the behavior you prefer, as one user.
Other users can prefer strong, not weak.  (But
I see, below, that you're considering providing
both.)

Let's not forget that "weak" dedication was
added as an additional, optional behavior,
decades after ordinary (aka strong) dedication
was in use.

> > 2. Why not just this?
> >
> > (let ((before  (window-dedicated-p window)))
> >   (set-window-dedicated-p window (not before))
> >   (when interactive
> >     (message "Window is %s dedicated to buffer %s"
> >              (if before "no longer" "now")
> >              (current-buffer))))
> >
> > If someone might not know what it means for a
> > window to be dedicated, put that info in the
> > doc string, not in the message.
> 
> Will do.

Maybe you won't want that toggling to `t' instead
of `dedicated', given your preference expressed
above?  (`not' nil returns `t'.)

> > 3. The toggle, as OP proposed it, imposes weak
> > dedication, and the toggle as I wrote it above
> > imposes strong dedication.  What if you want
> > a toggle that respects whatever non-nil FLAG
> > (weak or strong) might have already been used
> > for the window?
> >
> > IOW, what if the window is dedicated to start
> > with, before you first use the toggle, and you
> > want to get back that same dedicated behavior
> > (weak or strong) when you toggle it back again?
> > The toggle (either definition) doesn't do that.
> 
> That would be nice, but I don't see a way to do it.  At the same time, I
> think it's probably fine for the user to explicitly choose whether they
> want it to be weak or strong.  After all, this way it allows the user to
> change the dedicated mode.

Yes, that's where I was heading with that: not
easy to do, and we can just let users choose
which behavior they want.

> > Shouldn't the doc make clear that the toggling
> > behavior is always between weak & undedicated
> > (OP version) or always between strong &
> > undedicated (my version, above)?  IOW, let a
> > user know that any original dedicated behavior
> > is lost, once you use the toggle.
> >
> > Or if you want to let a user specify whether
> > to use weak or strong, maybe do that with a
> > prefix arg?
> 
> Good point, I'll add a prefix arg for strong dedication.

Thx.  (Though I'd prefer it the other way 'round. ;-))