Subject: bug#32790: 27.0.50; point jumps unexpectedly after delete-window

From: martin rudalics <[email-masked]>
Date: Thu, 22 Nov 2018 08:40:47 +0100

> One possible solution is to implement directional window deletion.
 > The following patch allows using the prefix argument that will delete
 > the selected window and select the window at the given direction.

Delete and select - smart idea.

 > +;;; Directional window deletion
 > +
 > +(defun windmove-delete-in-direction (dir &optional arg)
 > +  "Delete the window at direction DIR.
 > +If prefix ARG is `C-u', delete the selected window and
 > +select the window at direction DIR."
 > +  (let ((other-window (window-in-direction dir nil nil arg
 > +                                           windmove-wrap-around t)))

So 'windmove-wrap-around' non-nil means that the other window could be
the selected one and we try to delete ourselves.  Right?

 > +          ((and (window-minibuffer-p other-window)
 > +                (not (minibuffer-window-active-p other-window)))
 > +           (user-error "Minibuffer is inactive"))

Should we try to delete the active minibuffer window?

 > +;;;###autoload
 > +(defun windmove-delete-default-keybindings (&optional prefix modifiers)
 > +  "Set up keybindings for directional window deletion.
 > +Keys are bound to commands that delete windows in the specified
 > +direction.  Keybindings are of the form PREFIX MODIFIERS-{left,right,up,down},
 > +where PREFIX is a prefix key and MODIFIERS is either a list of modifiers or
 > +a single modifier.  Default value of PREFIX is `C-x' and MODIFIERS is `shift'."
 > +  (interactive)
 > +  (unless prefix (setq prefix '(?\C-x)))
 > +  (unless (listp prefix) (setq prefix (list prefix)))
 > +  (unless modifiers (setq modifiers '(shift)))
 > +  (unless (listp modifiers) (setq modifiers (list modifiers)))
 > +  (global-set-key (vector prefix (append modifiers '(left)))  'windmove-delete-left)
 > +  (global-set-key (vector prefix (append modifiers '(right))) 'windmove-delete-right)
 > +  (global-set-key (vector prefix (append modifiers '(up)))    'windmove-delete-up)
 > +  (global-set-key (vector prefix (append modifiers '(down)))  'windmove-delete-down))

Feel free to install.  But note that eventually we should document
the keybinding stuff with a few, good examples.

Thanks, martin