diff options
| -rw-r--r-- | init.el | 67 | ||||
| -rw-r--r-- | lib/eos/jao-buffers.el | 23 | ||||
| -rw-r--r-- | lib/eos/jao-themes.el | 1 |
3 files changed, 55 insertions, 36 deletions
@@ -978,20 +978,6 @@ (global-set-key (kbd "C-x _") #'delete-other-windows-vertically) -;;;; first window -(defvar jao-first-window--from nil) - -(defun jao-first-window () - "Go to previous windows in frame, remembering where we were." - (interactive) - (let ((cb (current-buffer))) - (if (eq (get-buffer-window cb) (select-window (frame-first-window))) - (when jao-first-window--from (pop-to-buffer jao-first-window--from)) - (setq jao-first-window--from cb)))) - -(global-set-key (kbd "s-a") #'jao-first-window) -(global-set-key (kbd "M-a") #'jao-first-window) - ;;;; window navigation (custom) (defun jao-nth-window (n) (if (zerop n) @@ -1022,7 +1008,36 @@ (global-set-key (format "\C-c%s" (1+ n)) (jao-nth-window n))) '(0 1 2 3 4 5 6 7 8)) +;;;;; last window +(defvar jao-previous-window nil) + +(defun jao-save-current-window (&rest _ignore) + (unless (active-minibuffer-window) + (setq jao-previous-window (get-buffer-window (current-buffer))))) + +(defun jao-switch-goto-previous-window () + (interactive) + (let ((previous-window jao-previous-window)) + (jao-save-current-window) + (if (window-live-p previous-window) + (select-window previous-window) + (other-window 1)))) + +(advice-add 'other-window :before #'jao-save-current-window) + (global-set-key "\C-xp" 'jao-prev-window) +(global-set-key (kbd "M-o") #'jao-switch-goto-previous-window) + +;;;;; first window +(defun jao-first-window () + (interactive) + (if (eq (selected-window) (frame-first-window)) + (jao-switch-goto-previous-window) + (jao-save-current-window) + (select-window (frame-first-window)))) + +(global-set-key (kbd "s-a") #'jao-first-window) +(global-set-key (kbd "M-a") #'jao-first-window) ;;;; window navigation (switch-window) (use-package switch-window @@ -1053,25 +1068,15 @@ (interactive) (jao-switch-window--then "Switch to buffer" 'consult-buffer)) - :bind (("M-o" . switch-window) + (advice-add 'switch-window :before #'jao-save-current-window) + + :bind (("C-M-o" . switch-window) + ("C-x o" . switch-window) ("C-x 4 d" . jao-switch-window-then-dired) ("C-x 4 f" . jao-switch-window-then-find-file) - ("C-x 4 b" . jao-switch-window-then-consult-buffer))) - -;;;; transposing windows -(defun transpose-windows (arg) - "Transpose the buffers shown in two windows." - (interactive "p") - (let ((selector (if (>= arg 0) 'next-window 'previous-window))) - (while (/= arg 0) - (let ((this-win (window-buffer)) - (next-win (window-buffer (funcall selector)))) - (set-window-buffer (selected-window) next-win) - (set-window-buffer (funcall selector) this-win) - (select-window (funcall selector))) - (setq arg (if (> arg 0) (1- arg) (1+ arg)))))) - -(define-key ctl-x-4-map (kbd "t") 'transpose-windows) + ("C-x 4 b" . jao-switch-window-then-consult-buffer) + ("C-x 4 t" . switch-window-then-swap-buffer) + ("C-x 4 T" . transpose-windows))) ;;;; winner mode (winner-mode 1) diff --git a/lib/eos/jao-buffers.el b/lib/eos/jao-buffers.el index c3f4063..3339d33 100644 --- a/lib/eos/jao-buffers.el +++ b/lib/eos/jao-buffers.el @@ -18,11 +18,11 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see <https://www.gnu.org/licenses/>. -;;; Code: +;;; deps (require 'eldoc) -;;;; lines +;;; lines ;;;###autoload (defun jao-goto-visible-line (n) @@ -30,7 +30,20 @@ (goto-char (point-min)) (forward-visible-line n)) -;;;; attached buffers +;;; windows +;;;###autoload +(defun transpose-windows (arg) + "Transpose the buffers shown in two windows." + (interactive "p") + (let ((selector (if (>= arg 0) 'next-window 'previous-window))) + (while (/= arg 0) + (let ((this-win (window-buffer)) + (next-win (window-buffer (funcall selector)))) + (set-window-buffer (selected-window) next-win) + (set-window-buffer (funcall selector) this-win) + (select-window (funcall selector))) + (setq arg (if (> arg 0) (1- arg) (1+ arg)))))) +;;; attached buffers (defun jao-display-buffer-below-selected (buffer alist) (delete-other-windows-vertically) (display-buffer-below-selected buffer alist)) @@ -57,7 +70,7 @@ (add-to-list 'display-buffer-alist (jao-attached-buffer-entry name-rx height))) -;;;; eldoc +;;; eldoc ;;;###autoload (defun jao-eldoc-toggle () "Toggle eldoc's documentation buffer." @@ -89,7 +102,7 @@ (display-buffer-reuse-window jao-display-below-eldoc) (height . (or ,h 0.5))))) -;;;; same mode +;;; same mode ;;;###autoload (defun jao-buffer-same-mode (&optional mode pre-fn switch-fn) (interactive) diff --git a/lib/eos/jao-themes.el b/lib/eos/jao-themes.el index a1d22c1..ed4d038 100644 --- a/lib/eos/jao-themes.el +++ b/lib/eos/jao-themes.el @@ -1096,6 +1096,7 @@ (sunshine-forecast-date-face (~ default)) (sunshine-forecast-day-divider-face (p dimm)) (sunshine-forecast-headline-face (~ header-line)) + (switch-window-label-face (p keyword) :height 2.0) (symbol-overlay-face-1 (c nil "brown1")) (symbol-overlay-face-2 (c nil "lightsalmon1")) (symbol-overlay-face-3 (c nil "tomato1")) |
