From 177b6c893d20eb9d093c463d53c6653434334792 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 18 Jul 2010 15:56:01 -0600 Subject: [PATCH] other-window-in-any-frame now accepts negative args (from phob on reddit) --- emacs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/emacs b/emacs index 10afa22..d48a723 100644 --- a/emacs +++ b/emacs @@ -401,14 +401,19 @@ switch to that frame first using `select-frame-set-input-focus'. If N is non-nil switch to the nth next window." (interactive "p") - (while (> arg 0) - (let ((window (next-window (selected-window) nil 'visible))) - (when (not (member window (window-list))) - (dolist (frame (delq (selected-frame) (frame-list))) - (when (member window (window-list frame)) - (select-frame-set-input-focus frame)))) - (select-window window)) - (decf arg))) + (setq arg (or arg 1)) + (let ((gt-or-lt (if (> arg 0) #'> #'<)) + (sign (if (> arg 0) 1 -1))) + (while (apply gt-or-lt arg '(0)) + (let ((window (if (= sign 1) + (next-window (selected-window) nil 'visible) + (previous-window (selected-window) nil 'visible)))) + (when (not (member window (window-list))) + (dolist (frame (delq (selected-frame) (frame-list))) + (when (member window (window-list frame)) + (select-frame-set-input-focus frame)))) + (select-window window)) + (setq arg (- arg sign))))) ;; Reload the .emacs file with a minimum of effort, ;; first saving histories with Persistent