mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
feat(windows): use new windmove-swap-* functions on Emacs 27 and later
Fallback onto buffer-move package for Emacs versions prior to 27.
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(when (version< emacs-version "27.0")
|
||||
(require 'siren-buffer-move))
|
||||
|
||||
(use-package windmove
|
||||
:straight (:type built-in)
|
||||
|
||||
@@ -14,6 +17,10 @@
|
||||
("M-k" . siren-windmove-down)
|
||||
("M-j" . siren-windmove-left)
|
||||
("M-l" . siren-windmove-right)
|
||||
("M-K" . siren-windmove-swap-down)
|
||||
("M-I" . siren-windmove-swap-up)
|
||||
("M-J" . siren-windmove-swap-left)
|
||||
("M-L" . siren-windmove-swap-right)
|
||||
|
||||
:custom
|
||||
(siren-windmove-tmux-fallback (if (getenv "TMUX") t nil))
|
||||
@@ -41,7 +48,21 @@
|
||||
(interactive)
|
||||
(if (and (not (ignore-errors (windmove-right)))
|
||||
siren-windmove-tmux-fallback)
|
||||
(shell-command "tmux select-pane -R"))))
|
||||
(shell-command "tmux select-pane -R")))
|
||||
|
||||
(defun siren-windmove-swap-defun (direction)
|
||||
"Define window swap function for DIRECTION.
|
||||
On Emacs 27.0 or later use windmove, on earlier use buffer-move package."
|
||||
`(defun ,(intern (format "siren-windmove-swap-%s" direction)) ()
|
||||
(interactive)
|
||||
(,(intern (format (if (version< emacs-version "27.0")
|
||||
"buf-move-%s"
|
||||
"windmove-swap-states-%s")
|
||||
direction)))))
|
||||
|
||||
(defmacro siren-windmove-swap-defuns (directions)
|
||||
`(progn ,@(mapcar 'siren-windmove-swap-defun directions)))
|
||||
|
||||
(siren-windmove-swap-defuns (up down left right)))
|
||||
(provide 'siren-windmove)
|
||||
;;; siren-windmove.el ends here
|
||||
|
||||
Reference in New Issue
Block a user