GNU bug report logs -
#32790
27.0.50; point jumps unexpectedly after delete-window
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Thu, 20 Sep 2018 23:57:01 UTC
Severity: minor
Found in version 27.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Here <H-left> drags the character under the cursor by one character to
> the left and <H-up> drags the current line up by one line. I use
> <M-S-left> for selecting the window on the left. <C-M-S-left> either
> deletes the window on the left of the selected window provided there
> is one or makes a new window on the left of the selected window
> provided the selected window is already on the left of the frame.
Making a new window is especially good idea. So I implemented
this feature in windmove.el:
diff --git a/lisp/windmove.el b/lisp/windmove.el
index 42e10b591f..69f2a9665a 100644
--- a/lisp/windmove.el
+++ b/lisp/windmove.el
@@ -149,6 +149,15 @@ windmove-wrap-around
:type 'boolean
:group 'windmove)
+(defcustom windmove-create-window nil
+ "Whether movement off the edge of the frame creates a new window.
+If this variable is set to t, moving left from the leftmost window in
+a frame will create a new window on the left, and similarly for the other
+directions."
+ :type 'boolean
+ :group 'windmove
+ :version "27.1")
+
;; If your Emacs sometimes places an empty column between two adjacent
;; windows, you may wish to set this delta to 2.
(defcustom windmove-window-distance-delta 1
@@ -471,8 +480,15 @@ windmove-find-other-window
(defun windmove-do-window-select (dir &optional arg window)
"Move to the window at direction DIR.
DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'.
-If no window is at direction DIR, an error is signaled."
+If no window is at direction DIR, an error is signaled.
+If `windmove-create-window' is non-nil, instead of signalling an error
+it creates a new window at direction DIR ."
(let ((other-window (windmove-find-other-window dir arg window)))
+ (when (and windmove-create-window
+ (or (null other-window)
+ (and (window-minibuffer-p other-window)
+ (not (minibuffer-window-active-p other-window)))))
+ (setq other-window (split-window window nil dir)))
(cond ((null other-window)
(user-error "No window %s from selected window" dir))
((and (window-minibuffer-p other-window)
@@ -493,7 +509,8 @@ windmove-left
\"left\" is relative to the position of point in the window; otherwise
it is relative to the top edge (for positive ARG) or the bottom edge
\(for negative ARG) of the current window.
-If no window is at the desired location, an error is signaled."
+If no window is at the desired location, an error is signaled
+unless `windmove-create-window' is non-nil."
(interactive "P")
(windmove-do-window-select 'left arg))
@@ -504,7 +521,8 @@ windmove-up
is relative to the position of point in the window; otherwise it is
relative to the left edge (for positive ARG) or the right edge (for
negative ARG) of the current window.
-If no window is at the desired location, an error is signaled."
+If no window is at the desired location, an error is signaled
+unless `windmove-create-window' is non-nil."
(interactive "P")
(windmove-do-window-select 'up arg))
@@ -515,7 +533,8 @@ windmove-right
\"right\" is relative to the position of point in the window;
otherwise it is relative to the top edge (for positive ARG) or the
bottom edge (for negative ARG) of the current window.
-If no window is at the desired location, an error is signaled."
+If no window is at the desired location, an error is signaled
+unless `windmove-create-window' is non-nil."
(interactive "P")
(windmove-do-window-select 'right arg))
@@ -526,7 +545,8 @@ windmove-down
\"down\" is relative to the position of point in the window; otherwise
it is relative to the left edge (for positive ARG) or the right edge
\(for negative ARG) of the current window.
-If no window is at the desired location, an error is signaled."
+If no window is at the desired location, an error is signaled
+unless `windmove-create-window' is non-nil."
(interactive "P")
(windmove-do-window-select 'down arg))
This bug report was last modified 5 years and 235 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.