emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/crux de603e9 088/112: Add function other-window-or-switch-


From: ELPA Syncer
Subject: [nongnu] elpa/crux de603e9 088/112: Add function other-window-or-switch-buffer
Date: Wed, 11 Aug 2021 09:57:59 -0400 (EDT)

branch: elpa/crux
commit de603e953ed382277fd352c1a3a71924548ae7d9
Author: thdox <thdox@free.fr>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>

    Add function other-window-or-switch-buffer
    
    Move to other window if one exists, or switch to most recent buffer.
    Source is http://mbork.pl/2017-02-26_other-window-or-switch-buffer.
---
 README.md | 1 +
 crux.el   | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/README.md b/README.md
index 101043e..146962a 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,7 @@ Command                                             | 
Suggested Keybinding(s)
 `crux-upcase-region`                                | <kbd>C-x C-u</kbd> | 
`upcase-region` when `transient-mark-mode` is on and region is active.
 `crux-downcase-region`                              | <kbd>C-x C-l</kbd> | 
`downcase-region` when `transient-mark-mode` is on and region is active.
 `crux-capitalize-region`                            | <kbd>C-x M-c</kbd> | 
`capitalize-region` when `transient-mark-mode` is on and region is active.
+`crux-other-window-or-switch-buffer`                | <kbd>M-o</kbd>     | 
Select other window, or switch to most recent buffer if only one windows.
 
 Here's how you'd bind some of the commands to keycombos:
 
diff --git a/crux.el b/crux.el
index fa9259c..d0a5931 100644
--- a/crux.el
+++ b/crux.el
@@ -621,6 +621,15 @@ Repeated invocations toggle between the two most recently 
open buffers."
   (switch-to-buffer (other-buffer (current-buffer) 1)))
 
 ;;;###autoload
+(defun crux-other-window-or-switch-buffer ()
+  "Call `other-window' if more than one window is visible.
+Switch to most recent buffer otherwise."
+  (interactive)
+  (if (one-window-p)
+      (switch-to-buffer nil)
+    (other-window 1)))
+
+;;;###autoload
 (defun crux-kill-other-buffers ()
   "Kill all buffers but the current one.
 Doesn't mess with special buffers."



reply via email to

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