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

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

[elpa] externals/window-commander ed81d15671 157/170: Only define and bi


From: ELPA Syncer
Subject: [elpa] externals/window-commander ed81d15671 157/170: Only define and bind 'swsw-selected-window-prefix' in Emacs 28+
Date: Wed, 28 Jun 2023 19:00:36 -0400 (EDT)

branch: externals/window-commander
commit ed81d1567118c88c6998d998439107f26774accb
Author: Daniel Semyonov <daniel@dsemy.com>
Commit: Daniel Semyonov <daniel@dsemy.com>

    Only define and bind 'swsw-selected-window-prefix' in Emacs 28+
    
    * swsw.el (swsw-selected-window-prefix, swsw-command-map): Only define
    and bind 'swsw-selected-window-prefix' when function
    'display-buffer-override-next-command' is bound (Emacs 28+).
---
 NEWS    |  4 ++--
 swsw.el | 23 +++++++++++++----------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/NEWS b/NEWS
index ba5ad9074b..c80629ad52 100644
--- a/NEWS
+++ b/NEWS
@@ -10,8 +10,8 @@ now use it and 5 new window commands have been added:
 'swsw-delete-other', 'swsw-split-window-below' and
 'swsw-split-window-right', which correspond to the built-in commands,
 'swsw-selected-window-prefix', which displays the buffer of the next
-command in the selected window, and 'swsw-swap' which swaps the state
-of the current window and the selected window.
+command in the selected window (Emacs 28+), and 'swsw-swap' which
+swaps the state of the current window and the selected window.
 
 * 2.2
 
diff --git a/swsw.el b/swsw.el
index c7f5ce9ac7..399dd9087c 100644
--- a/swsw.el
+++ b/swsw.el
@@ -83,7 +83,8 @@
   (require 'subr-x)
   ;; Avoid byte-compilation warnings.
   (defvar swsw-mode)
-  (defvar swsw-command-map))
+  (defvar swsw-command-map)
+  (declare-function swsw-selected-window-prefix nil))
 
 ;;;; Customization:
 
@@ -438,14 +439,15 @@ indirectly called by the latter."
                 (window-dedicated-p window))
       (window--display-buffer buffer window 'reuse alist))))
 
-(swsw-define-window-command swsw-selected-window-prefix (window)
-  "Display the buffer of the next command in a window."
-  (display-buffer-override-next-command
-   (lambda (buffer alist)
-     (setq alist (append `((window . ,window)) alist))
-     (cons (swsw-display-buffer-selected-window buffer alist) 'reuse))
-   nil (format "[swsw-window-%s]" (window-parameter window 'swsw-id)))
-  (message "Display next command buffer in the selected window..."))
+(when (fboundp 'display-buffer-override-next-command)
+  (swsw-define-window-command swsw-selected-window-prefix (window)
+    "Display the buffer of the next command in a window."
+    (display-buffer-override-next-command
+     (lambda (buffer alist)
+       (setq alist (append `((window . ,window)) alist))
+       (cons (swsw-display-buffer-selected-window buffer alist) 'reuse))
+     nil (format "[swsw-window-%s]" (window-parameter window 'swsw-id)))
+    (message "Display next command buffer in the selected window...")))
 
 (swsw-define-window-command swsw-swap (window)
   "Swap the states of a window and the currently selected window."
@@ -466,7 +468,8 @@ indirectly called by the latter."
     (define-key map [?1] #'swsw-delete-other)
     (define-key map [?2] #'swsw-split-window-below)
     (define-key map [?3] #'swsw-split-window-right)
-    (define-key map [?4] #'swsw-selected-window-prefix)
+    (when (fboundp 'display-buffer-override-next-command)
+      (define-key map [?4] #'swsw-selected-window-prefix))
     (define-key map [?t] #'swsw-swap)
     (define-key map [?m] #'swsw-select-minibuffer)
     map)



reply via email to

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