[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/crux 5938c84 036/112: Merge pull request #21 from dgtized/
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/crux 5938c84 036/112: Merge pull request #21 from dgtized/transpose-windows |
Date: |
Wed, 11 Aug 2021 09:57:48 -0400 (EDT) |
branch: elpa/crux
commit 5938c84930543ed1d8baa870784c78d258f3d6c3
Merge: a71669e e6c7421
Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Merge pull request #21 from dgtized/transpose-windows
Add crux-transpose-windows for swapping the buffers between two windows
---
README.md | 2 +-
crux.el | 33 +++++++++++++++++----------------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index 840f85f..f36dd87 100644
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ Command | Suggested
Keybinding(s) |
`crux-recentf-ido-find-file` | <kbd>C-c f</kbd> or
<kbd>Super-r</kbd> | Open recently visited file.
`crux-view-url` | <kbd>C-c u</kbd> | Open a new
buffer containing the contents of URL.
`crux-eval-and-replace` | <kbd>C-c e</kbd> | Eval a bit of
Emacs Lisp code and replace it with its result.
-`crux-swap-windows` | <kbd>C-c s</kbd> | Swap two
active windows.
+`crux-tranpose-windows` | <kbd>C-x 4 t</kbd> | Transpose
the buffers between two windows.
`crux-delete-file-and-buffer` | <kbd>C-c D</kbd> | Delete
current file and buffer.
`crux-rename-file-and-buffer` | <kbd>C-c r</kbd> | Rename the
current buffer and its visiting file if any.
`crux-visit-term-buffer` | <kbd>C-c t</kbd> | Open a
terminal emulator (`ansi-term`).
diff --git a/crux.el b/crux.el
index f7c1ec8..a0a9cb8 100644
--- a/crux.el
+++ b/crux.el
@@ -329,22 +329,23 @@ buffer is not visiting a file."
(when file
(find-file file))))
-(defun crux-swap-windows ()
- "If you have 2 windows, it swaps them."
- (interactive)
- (if (/= (count-windows) 2)
- (message "You need exactly 2 windows to do this.")
- (let* ((w1 (car (window-list)))
- (w2 (cadr (window-list)))
- (b1 (window-buffer w1))
- (b2 (window-buffer w2))
- (s1 (window-start w1))
- (s2 (window-start w2)))
- (set-window-buffer w1 b2)
- (set-window-buffer w2 b1)
- (set-window-start w1 s2)
- (set-window-start w2 s1)))
- (other-window 1))
+;; modified from https://www.emacswiki.org/emacs/TransposeWindows
+(defun crux-transpose-windows (arg)
+ "Transpose the buffers shown in two windows.
+Prefix ARG determines if the current windows buffer is swapped
+with the next or previous window, and the number of
+transpositions to execute in sequence."
+ (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 (cl-plusp arg) (1- arg) (1+ arg))))))
+
+(defalias 'crux-swap-windows 'crux-transpose-windows)
(defun crux-switch-to-previous-buffer ()
"Switch to previously open buffer.
- [nongnu] elpa/crux 382834e 020/112: Fix contributors link, (continued)
- [nongnu] elpa/crux 382834e 020/112: Fix contributors link, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e6e3221 025/112: Fix crux-*-file-and-buffer commands inconsistencies and alias the inverse, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 4c90762 026/112: Add complementary `with-region-or-line` & `with-region-or-point-to-eol`, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e4c539b 028/112: Merge pull request #9 from waymondo/with-region-or-line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux dc1606b 034/112: Add crux-transpose-windows for swapping the buffers between two windows, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2be95ea 040/112: Use read-from-minibuffer for the new file name, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e2124c8 023/112: Merge pull request #6 from verdammelt/patch-1, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 3c14b4a 024/112: Merge pull request #13 from jiegec/master, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 79e500e 030/112: Add multiple choice with completion for shell init files., ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e6c7421 035/112: Remove crux-swap-windows and alias it to crux-transpose-windows, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 5938c84 036/112: Merge pull request #21 from dgtized/transpose-windows,
ELPA Syncer <=
- [nongnu] elpa/crux 6d11d2e 039/112: When opening a line above, don't reindent the current line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 1967a75 041/112: Allow users to create directories with crux-rename-file-and-buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 582a68d 046/112: Fix the version header, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux bcbfdec 048/112: Don't assume ido when offering files from recentf (#33), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 3b377b4 054/112: Add smart kill line function, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 1c2c179 061/112: Improve a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2b6ddf0 060/112: Add missing space, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 5a7201a 062/112: Fix a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 32baf6a 064/112: Bump the development version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux a71669e 033/112: Merge pull request #17 from jiegec/master, ELPA Syncer, 2021/08/11