From: Gregory Heytings <gregory@heytings.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Sean Whitton <spwhitton@spwhitton.name>,
Lars Ingebrigtsen <larsi@gnus.org>,
Juri Linkov <juri@linkov.net>, Robert Pluim <rpluim@gmail.com>,
emacs-devel@gnu.org, Hugo Heagren <hugo@heagren.com>
Subject: Re: master 6a2ee981c3: Add new functions for splitting the root window
Date: Tue, 13 Sep 2022 09:33:16 +0000 [thread overview]
Message-ID: <a993deec58315d57cc9e@heytings.org> (raw)
In-Reply-To: <jwvills5w0v.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1811 bytes --]
>
> While I understand the desire to follow the `C-x 2` and `C-x 3`
> tradition, these numbers don't actually carry much useful intuition. How
> 'bout `C-x w -` and `C-x w |` instead?
>
> Of course, it'd also be nice to bring together/closer the root and
> non-root variants of those operations, but I have no good suggestion
> here, other than to suggest to use a new command which doesn't accept a
> numeric argument at all and only uses `C-u` to choose between a root
> split and non-root split. That's because I personally never use that
> numeric argument, and prefer to resize the windows afterwards rather
> than try to guess sizes beforehand.
>
Fully agreed. I we're going to put window commands on C-x w, I thought I
might share the part of my configuration that deals with windows (see
attached), which I adapted to that new prefix.
C-x w | split-window-right
C-u C-x w | split-root-window-right
C-x w - split-window-below
C-u C-x w - split-root-window-below
C-x w d delete-window
C-x w o delete-other-windows (mnemonic "only")
C-x w h window-height-adjust with + - = (repeatable)
C-x w w window-width-adjust with + - = (repeatable)
C-x w f tear-off-window
C-x w m maximize-window-toggle
C-u C-x w m minimize-window
C-x w s window-toggle-side-windows
C-x w ! window-toggle-dedicated
C-x w b balance-windows
C-u C-x w b balance-windows-area
C-x w c window-configuration
left (winner-undo) right (winner-redo) (repeatable)
s (save in register) r (restore from register)
C-x w n/p select-next-window select-previous-window (repeatable)
C-x w up/down/left/right select-window-{up,down,left,right} (repeatable)
C-x w M-up/M-down/M-left/M-right swap-windows-{up,down,left,right} (repeatable)
[-- Attachment #2: window-commands.el --]
[-- Type: text/plain, Size: 5878 bytes --]
(defun split-window-or-root-window-right (&optional arg)
(interactive "P")
(if arg (split-root-window-right) (split-window-right)))
(defun split-window-or-root-window-below (&optional arg)
(interactive "P")
(if arg (split-root-window-below) (split-window-below)))
(global-set-key (kbd "C-x w |") 'split-window-or-root-window-right)
(global-set-key (kbd "C-x w -") 'split-window-or-root-window-below)
(global-set-key (kbd "C-x w d") 'delete-window)
(global-set-key (kbd "C-x w o") 'delete-other-windows)
(defun fit-window-to-buffer-horizontally ()
(interactive)
(let ((fit-window-to-buffer-horizontally 'only))
(fit-window-to-buffer)
(enlarge-window-horizontally 2)))
(defun window-width-adjust ()
(interactive)
(let ((map (make-sparse-keymap)))
(define-key map "+" 'enlarge-window-horizontally)
(define-key map "-" 'shrink-window-horizontally)
(define-key map "=" 'fit-window-to-buffer-horizontally)
(set-transient-map map t)))
(defun window-height-adjust ()
(interactive)
(let ((map (make-sparse-keymap)))
(define-key map "+" 'enlarge-window)
(define-key map "-" 'shrink-window)
(define-key map "=" 'fit-window-to-buffer)
(set-transient-map map t)))
(global-set-key (kbd "C-x w w") 'window-width-adjust)
(global-set-key (kbd "C-x w h") 'window-height-adjust)
(global-set-key (kbd "C-x w f") 'tear-off-window)
(defun maximize-window-toggle ()
(let* ((wc (frame-parameter nil 'window-maximized)))
(if wc
(progn
(set-window-configuration wc)
(set-frame-parameter nil 'window-maximized nil))
(set-frame-parameter nil 'window-maximized
(current-window-configuration))
(delete-other-windows))))
(defun maximize-or-minimize-window (&optional arg)
(interactive "P")
(if arg
(minimize-window)
(maximize-window-toggle)))
(global-set-key (kbd "C-x w m") 'maximize-or-minimize-window)
(global-set-key (kbd "C-x w s") 'window-toggle-side-windows)
(defun windows-balance (&optional arg)
(interactive "P")
(if arg
(balance-windows-area)
(balance-windows)))
(global-set-key (kbd "C-x w b") 'windows-balance)
(defun window-toggle-dedicated ()
(interactive)
(set-window-dedicated-p nil (not (window-dedicated-p)))
(message "Window is %sdedicated" (if (window-dedicated-p) "" "not ")))
(global-set-key (kbd "C-x w !") 'window-toggle-dedicated)
(defun window-configuration-from-register (register)
(interactive
(list (register-read-with-preview "Window configuration from register: ")))
(let ((contents (get-register register)))
(if (and (consp contents)
(window-configuration-p (car contents))
(markerp (cadr contents)))
(jump-to-register register)
(user-error "Register `%c' doesn't contain a window configuration"
register))))
(defun window-configuration ()
(interactive)
(if (and (boundp winner-mode) winner-mode)
(let ((map (make-sparse-keymap)))
(define-key map [left] 'winner-undo)
(define-key map [right] 'winner-redo)
(define-key map "s" 'window-configuration-to-register)
(define-key map "r" 'window-configuration-from-register)
(set-transient-map map t))
(user-error "Winner mode is not enabled")))
(global-set-key (kbd "C-x w c") 'window-configuration)
(defun select-next-window-do ()
(interactive)
(select-window (next-window)))
(defun select-previous-window-do ()
(interactive)
(select-window (previous-window)))
(defun select-window-enter ()
(let ((map (make-sparse-keymap)))
(define-key map "n" 'select-next-window-do)
(define-key map "p" 'select-previous-window-do)
(set-transient-map map t)))
(defun select-next-window ()
(interactive)
(select-next-window-do)
(select-window-enter))
(defun select-previous-window ()
(interactive)
(select-previous-window-do)
(select-window-enter))
(global-set-key (kbd "C-x w n") 'select-next-window)
(global-set-key (kbd "C-x w p") 'select-previous-window)
(defun windmove-enter (fun)
(if windmove-mode
(let ((map (make-sparse-keymap)))
(define-key map [up] 'windmove-up)
(define-key map [down] 'windmove-down)
(define-key map [left] 'windmove-left)
(define-key map [right] 'windmove-right)
(define-key map [M-up] 'windmove-swap-states-up)
(define-key map [M-down] 'windmove-swap-states-down)
(define-key map [M-left] 'windmove-swap-states-left)
(define-key map [M-right] 'windmove-swap-states-right)
(call-interactively fun)
(set-transient-map map t))
(user-error "Windmove mode is not enabled")))
(defun select-window-up (&optional arg)
(interactive "P")
(windmove-enter 'windmove-up))
(defun select-window-down (&optional arg)
(interactive "P")
(windmove-enter 'windmove-down))
(defun select-window-left (&optional arg)
(interactive "P")
(windmove-enter 'windmove-left))
(defun select-window-right (&optional arg)
(interactive "P")
(windmove-enter 'windmove-right))
(defun swap-windows-up (&optional arg)
(interactive)
(windmove-enter 'windmove-swap-states-up))
(defun swap-windows-down (&optional arg)
(interactive)
(windmove-enter 'windmove-swap-states-down))
(defun swap-windows-left (&optional arg)
(interactive)
(windmove-enter 'windmove-swap-states-left))
(defun swap-windows-right (&optional arg)
(interactive)
(windmove-enter 'windmove-swap-states-right))
(global-set-key (kbd "C-x w <up>") 'select-window-up)
(global-set-key (kbd "C-x w <down>") 'select-window-down)
(global-set-key (kbd "C-x w <left>") 'select-window-left)
(global-set-key (kbd "C-x w <right>") 'select-window-right)
(global-set-key (kbd "C-x w M-<up>") 'swap-windows-up)
(global-set-key (kbd "C-x w M-<down>") 'swap-windows-down)
(global-set-key (kbd "C-x w M-<left>") 'swap-windows-left)
(global-set-key (kbd "C-x w M-<right>") 'swap-windows-right)
next prev parent reply other threads:[~2022-09-13 9:33 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <166240424802.11417.12502552895310232639@vcs2.savannah.gnu.org>
[not found] ` <20220905185728.838CEC0088A@vcs2.savannah.gnu.org>
2022-09-06 16:17 ` master 6a2ee981c3: Add new functions for splitting the root window Juri Linkov
2022-09-07 0:32 ` Sean Whitton
2022-09-07 12:57 ` Lars Ingebrigtsen
2022-09-07 18:01 ` Juri Linkov
2022-09-08 11:50 ` Lars Ingebrigtsen
2022-09-08 12:09 ` Robert Pluim
2022-09-08 12:18 ` Lars Ingebrigtsen
2022-09-08 14:54 ` [External] : " Drew Adams
2022-09-10 19:27 ` Juri Linkov
2022-09-11 11:03 ` Lars Ingebrigtsen
2022-09-11 17:48 ` Sean Whitton
2022-09-11 18:31 ` chad
2022-09-12 10:00 ` Lars Ingebrigtsen
2022-09-12 14:10 ` Sean Whitton
2022-09-13 11:11 ` Lars Ingebrigtsen
2022-09-13 13:52 ` Sean Whitton
2022-09-13 13:56 ` Lars Ingebrigtsen
2022-09-13 14:12 ` Sean Whitton
2022-09-14 12:29 ` Lars Ingebrigtsen
2022-09-14 13:49 ` Eli Zaretskii
2022-09-14 16:37 ` Sean Whitton
2022-09-14 16:37 ` Sean Whitton
2022-09-12 14:29 ` Visuwesh
2022-09-12 10:04 ` Lars Ingebrigtsen
2022-09-12 14:35 ` Sean Whitton
2022-09-13 4:08 ` Richard Stallman
2022-09-13 14:29 ` [External] : " Drew Adams
2022-09-12 17:34 ` Juri Linkov
2022-09-12 18:57 ` Sean Whitton
2022-09-12 19:31 ` Juri Linkov
2022-09-13 14:01 ` Sean Whitton
2022-09-13 18:29 ` Juri Linkov
2022-09-13 22:12 ` Sean Whitton
2022-09-14 6:53 ` Juri Linkov
2022-09-14 16:52 ` Sean Whitton
2022-09-14 19:22 ` Juri Linkov
2022-09-14 23:06 ` Sean Whitton
2022-09-15 5:45 ` Eli Zaretskii
2022-09-15 16:14 ` Sean Whitton
2022-09-12 17:50 ` Stefan Monnier
2022-09-12 18:55 ` Sean Whitton
2022-09-12 19:29 ` Juri Linkov
2022-09-12 23:40 ` Sean Whitton
2022-09-13 6:50 ` Juri Linkov
2022-09-13 13:54 ` Sean Whitton
2022-09-13 9:33 ` Gregory Heytings [this message]
2022-09-13 11:14 ` Lars Ingebrigtsen
2022-09-13 13:51 ` Sean Whitton
2022-09-13 14:01 ` Gregory Heytings
2022-09-13 14:19 ` Sean Whitton
2022-09-13 14:26 ` Gregory Heytings
2022-09-13 15:22 ` Yuri Khan
2022-09-13 16:33 ` Gregory Heytings
2022-09-13 17:09 ` Yuri Khan
2022-09-13 18:16 ` Juri Linkov
2022-09-13 19:28 ` Gregory Heytings
2022-09-14 6:47 ` Juri Linkov
2022-09-14 8:13 ` Gregory Heytings
2022-09-14 9:21 ` Yuri Khan
2022-09-14 10:51 ` Gregory Heytings
2022-09-14 12:11 ` Yuri Khan
2022-09-15 7:19 ` Augusto Stoffel
2022-09-16 14:30 ` Gregory Heytings
2022-09-16 15:03 ` Augusto Stoffel
2022-09-19 6:53 ` Emanuel Berg
2022-09-08 12:22 ` Gregory Heytings
2022-09-08 14:54 ` [External] : " Drew Adams
2022-09-08 17:25 ` Juri Linkov
2022-09-09 17:07 ` Lars Ingebrigtsen
2022-09-09 17:25 ` Visuwesh
2022-09-09 17:36 ` Lars Ingebrigtsen
2022-09-11 3:37 ` Richard Stallman
2022-09-19 23:55 ` Emanuel Berg
2022-09-20 6:50 ` Juri Linkov
2022-09-20 7:47 ` Emanuel Berg
2022-09-20 16:06 ` Juri Linkov
2022-09-20 21:24 ` Emanuel Berg
2022-09-21 18:41 ` Juri Linkov
2022-09-21 21:16 ` Emanuel Berg
2022-09-09 17:53 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a993deec58315d57cc9e@heytings.org \
--to=gregory@heytings.org \
--cc=emacs-devel@gnu.org \
--cc=hugo@heagren.com \
--cc=juri@linkov.net \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
--cc=rpluim@gmail.com \
--cc=spwhitton@spwhitton.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).