;; windmove-up will move to the minibuffer if it is active, or to
;; either B or C depending on the prefix argument.
;;
-;;
-;; A set of default keybindings is supplied: shift-{left,up,right,down}
-;; invoke the corresponding Windmove function. See the installation
-;; section if you wish to use these keybindings.
-
-
-;; Installation:
-;;
-;; Put the following line in your init file:
-;;
-;; (windmove-default-keybindings) ; shifted arrow keys
-;;
-;; or
-;;
-;; (windmove-default-keybindings 'hyper) ; etc.
-;;
-;; to use another modifier key.
-;;
-;;
;; If you wish to enable wrap-around, also add a line like:
;;
;; (setq windmove-wrap-around t)
(interactive "P")
(windmove-do-window-select 'down (and arg (prefix-numeric-value arg))))
-
-;;; set up keybindings
-;; Idea for this function is from iswitchb.el, by Stephen Eglen
-;; (stephen@cns.ed.ac.uk).
-;; I don't think these bindings will work on non-X terminals; you
-;; probably want to use different bindings in that case.
-
-(defvar-keymap windmove-mode-map
- :doc "Map used by `windmove-install-defaults'.")
-
-;;;###autoload
-(define-minor-mode windmove-mode
- "Global minor mode for default windmove commands."
- :keymap windmove-mode-map
- :init-value t
- :global t)
-
-(defun windmove-install-defaults (prefix modifiers alist &optional uninstall)
- "Install keys as specified by ALIST.
-Every element of ALIST has the form (FN KEY), where KEY is
-appended to MODIFIERS, adding PREFIX to the beginning, before
-installing the key. Previous bindings of FN are unbound.
-If UNINSTALL is non-nil, just remove the keys from ALIST."
- (dolist (bind alist)
- (dolist (old (where-is-internal (car bind) windmove-mode-map))
- (define-key windmove-mode-map old nil))
- (unless uninstall
- (let ((key (vconcat (if (or (equal prefix [ignore])
- (eq prefix 'none))
- nil prefix)
- (list (append modifiers (cdr bind))))))
- (when (eq (key-binding key) #'self-insert-command)
- (warn "Command %S is shadowing self-insert-key" (car bind)))
- (let ((old-fn (lookup-key windmove-mode-map key)))
- (when (functionp old-fn)
- (warn "Overriding %S with %S" old-fn (car bind))))
- (define-key windmove-mode-map key (car bind))))))
-
-;;;###autoload
-(defun windmove-default-keybindings (&optional modifiers)
- "Set up keybindings for `windmove'.
-Keybindings are of the form MODIFIERS-{left,right,up,down},
-where MODIFIERS is either a list of modifiers or a single modifier.
-If MODIFIERS is `none', the keybindings will be directly bound to
-the arrow keys.
-Default value of MODIFIERS is `shift'."
- (interactive)
- (unless modifiers (setq modifiers 'shift))
- (when (eq modifiers 'none) (setq modifiers nil))
- (setq modifiers (ensure-list modifiers))
- (windmove-install-defaults nil modifiers
- '((windmove-left left)
- (windmove-right right)
- (windmove-up up)
- (windmove-down down))))
-
\f
;;; Directional window display and selection
(interactive "P")
(windmove-display-in-direction 'new-tab arg))
-;;;###autoload
-(defun windmove-display-default-keybindings (&optional modifiers)
- "Set up keybindings for directional buffer display.
-Keys are bound to commands that display the next buffer in the specified
-direction. Keybindings are of the form MODIFIERS-{left,right,up,down},
-where MODIFIERS is either a list of modifiers or a single modifier.
-If MODIFIERS is `none', the keybindings will be directly bound to
-the arrow keys.
-Default value of MODIFIERS is `shift-meta'."
- (interactive)
- (unless modifiers (setq modifiers '(shift meta)))
- (when (eq modifiers 'none) (setq modifiers nil))
- (setq modifiers (ensure-list modifiers))
- (windmove-install-defaults nil modifiers
- '((windmove-display-left left)
- (windmove-display-right right)
- (windmove-display-up up)
- (windmove-display-down down)
- (windmove-display-same-window ?0)
- (windmove-display-new-frame ?f)
- (windmove-display-new-tab ?t))))
-
\f
;;; Directional window deletion
(interactive "P")
(windmove-delete-in-direction 'down arg))
-;;;###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.
-If PREFIX is `none', no prefix is used. If MODIFIERS is `none',
-the keybindings are directly bound to the arrow keys.
-Default value of PREFIX is \\`C-x' and MODIFIERS is `shift'."
- (interactive)
- (unless prefix (setq prefix '(?\C-x)))
- (when (eq prefix 'none) (setq prefix nil))
- (setq prefix (ensure-list prefix))
- (unless modifiers (setq modifiers '(shift)))
- (when (eq modifiers 'none) (setq modifiers nil))
- (setq modifiers (ensure-list modifiers))
- (windmove-install-defaults prefix modifiers
- '((windmove-delete-left left)
- (windmove-delete-right right)
- (windmove-delete-up up)
- (windmove-delete-down down))))
-
\f
;;; Directional window swap states
(interactive)
(windmove-swap-states-in-direction 'right))
-;;;###autoload
-(defun windmove-swap-states-default-keybindings (&optional modifiers)
- "Set up keybindings for directional window swap states.
-Keys are bound to commands that swap the states of the selected window
-with the window in the specified direction. Keybindings are of the form
-MODIFIERS-{left,right,up,down}, where MODIFIERS is either a list of modifiers
-or a single modifier.
-If MODIFIERS is `none', the keybindings will be directly bound to the
-arrow keys.
-Default value of MODIFIERS is `shift-super'."
- (interactive)
- (unless modifiers (setq modifiers '(shift super)))
- (when (eq modifiers 'none) (setq modifiers nil))
- (setq modifiers (ensure-list modifiers))
- (windmove-install-defaults nil modifiers
- '((windmove-swap-states-left left)
- (windmove-swap-states-right right)
- (windmove-swap-states-up up)
- (windmove-swap-states-down down))))
-
-\f
-
-(defconst windmove--default-keybindings-type
- `(choice (const :tag "Don't bind" nil)
- (cons :tag "Bind using"
- (choice (key-sequence :tag "Prefix")
- (const :tag "No Prefix" nil))
- (set :tag "Modifier"
- :greedy t
- ;; See `(elisp) Keyboard Events'
- (const :tag "Meta" meta)
- (const :tag "Control" control)
- (const :tag "Shift" shift)
- (const :tag "Hyper" hyper)
- (const :tag "Super" super)
- (const :tag "Alt" alt))))
- "Customization type for windmove modifiers.")
-
-(defcustom windmove-default-keybindings nil
- "Default keybindings for regular windmove commands.
-See `windmove-default-keybindings' for more detail."
- :set (lambda (sym val)
- (windmove-install-defaults
- (car val) (cdr val)
- '((windmove-left left)
- (windmove-right right)
- (windmove-up up)
- (windmove-down down))
- (null val))
- (set-default sym val))
- :type windmove--default-keybindings-type
- :version "28.1")
-
-(defcustom windmove-display-default-keybindings nil
- "Default keybindings for windmove directional buffer display commands.
-See `windmove-display-default-keybindings' for more detail."
- :set (lambda (sym val)
- (windmove-install-defaults
- (car val) (cdr val)
- '((windmove-display-left left)
- (windmove-display-right right)
- (windmove-display-up up)
- (windmove-display-down down)
- (windmove-display-same-window ?0)
- (windmove-display-new-frame ?f)
- (windmove-display-new-tab ?t))
- (null val))
- (set-default sym val))
- :type windmove--default-keybindings-type
- :version "28.1")
-
-(defcustom windmove-delete-default-keybindings nil
- "Default keybindings for windmove directional window deletion commands.
-See `windmove-delete-default-keybindings' for more detail."
- :set (lambda (sym val)
- (windmove-install-defaults
- (car val) (cdr val)
- '((windmove-delete-left left)
- (windmove-delete-right right)
- (windmove-delete-up up)
- (windmove-delete-down down))
- (null val))
- (set-default sym val))
- :type windmove--default-keybindings-type
- :version "28.1")
-
-(defcustom windmove-swap-states-default-keybindings nil
- "Default keybindings for windmove's directional window swap-state commands.
-See `windmove-swap-states-default-keybindings' for more detail."
- :set (lambda (sym val)
- (windmove-install-defaults
- (car val) (cdr val)
- '((windmove-swap-states-left left)
- (windmove-swap-states-right right)
- (windmove-swap-states-up up)
- (windmove-swap-states-down down))
- (null val))
- (set-default sym val))
- :type windmove--default-keybindings-type
- :version "28.1")
-
\f
(provide 'windmove)