[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Make `C-x {' and `C-x }' repeatable

From: Juri Linkov
Subject: Re: [PATCH] Make `C-x {' and `C-x }' repeatable
Date: Fri, 24 May 2013 01:04:40 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

>> I will give it a try, but I feel that functionality should be
>> built-in.
> Yes clearly, that is needed before we can consider it to make C-x
> [{}^] redundant.

If the goal is to replace `C-x [{}^]' with one global keybinding,
the currently free and intuitive key prefix for window related commands
would be `C-x w', so that a command to activate window-resizing
key sequence could be bound to `C-x w r'.

Until this is implemented, something like below could help
for experimenting with possible implementations:

(defvar window-resize-keymap
  (let ((map (make-sparse-keymap)))
    ;; Standard keys:
    (define-key map "0" 'delete-window)
    (define-key map "1" 'delete-other-windows)
    (define-key map "2" 'split-window-below)
    (define-key map "3" 'split-window-right)
    (define-key map "o" 'other-window)
    (define-key map "^" 'enlarge-window)
    (define-key map "}" 'enlarge-window-horizontally)
    (define-key map "{" 'shrink-window-horizontally)
    (define-key map "-" 'shrink-window-if-larger-than-buffer)
    (define-key map "+" 'balance-windows)
    ;; Additional keys:
    (define-key map "v"     'shrink-window)
    (define-key map [down]  'shrink-window)
    (define-key map [up]    'enlarge-window)
    (define-key map [left]  'shrink-window-horizontally)
    (define-key map [right] 'enlarge-window-horizontally)
  "Keymap to resize windows.")

(advice-add 'enlarge-window-horizontally :after (lambda (delta)
            (set-temporary-overlay-map window-resize-keymap)))
(advice-add 'shrink-window-horizontally :after (lambda (delta)
            (set-temporary-overlay-map window-resize-keymap)))
(advice-add 'enlarge-window :after (lambda (delta &optional horizontal)
            (set-temporary-overlay-map window-resize-keymap)))
(advice-add 'shrink-window :after (lambda (delta &optional horizontal)
            (set-temporary-overlay-map window-resize-keymap)))

(defun window-resize-init ()
  (message "Use window-resizing keys...")
  (set-temporary-overlay-map window-resize-keymap))

(define-key ctl-x-map "wr" 'window-resize-init)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]