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

From: martin rudalics <[email-masked]>
Date: Mon, 22 Oct 2018 11:07:25 +0200

> other-frame-window is limited to the coarse choice, i.e. to display the
 > buffer in a random window on the same frame, or in another frame.

It would indeed be nice to fix that there in some way.

 > Whereas the needed feature is to allow the user to point out exactly
 > in which window the buffer should be displayed.  This can be achieved
 > with something like this:
 >
 > (let ((modifiers '(hyper)))
 >    (dolist (key '(left right up down))
 >      (define-key global-map (vector (append modifiers (list key)))
 >                  'display-buffer-directionally)))
 >
 > (defun display-buffer-directionally ()
 >    "Specify in which direction the buffer should be displayed."
 >    (interactive "P")
 >    (let* ((dir (event-basic-type (aref (this-command-keys) 0)))
 > 	 (win (window-in-direction dir)))
 >      (unless win
 >        (setq win (split-window nil nil dir)))
 >      (let ((hook (list 'lambda)))
 >        (setcdr hook `((window)
 > 		     (when (eq window ,win)
 > 		       ;; When a new buffer was displayed in that window,
 > 		       ;; we can restore a previous value.
 > 		       (setq display-buffer-overriding-action
 > 			     ',display-buffer-overriding-action)
 > 		       (remove-hook 'window-state-change-functions ',hook))))
 >        (add-hook 'window-state-change-functions hook))
 >      (setq display-buffer-overriding-action
 > 	  `((lambda (buffer alist)
 > 	      (window--display-buffer buffer ,win 'reuse alist))))))
 >
 > Do you think conceptually this is the right direction of development?

Good idea.  But IIUC we can't use 'hyper' in Emacs because it is not
supposed to be generally present and must be bound to a key first.  So
we'd need some other mechanism.

martin