emacs-diffs
[Top][All Lists]
Advanced

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

emacs-27 13301d4 2/2: New function erc-track-switch-buffer-other-window


From: Amin Bandali
Subject: emacs-27 13301d4 2/2: New function erc-track-switch-buffer-other-window
Date: Tue, 14 Apr 2020 00:34:21 -0400 (EDT)

branch: emacs-27
commit 13301d4266d26882f9fe7efe3046accd315d7c55
Author: Amin Bandali <address@hidden>
Commit: Amin Bandali <address@hidden>

    New function erc-track-switch-buffer-other-window
    
    * lisp/erc/erc-track.el (erc-track-switch-buffer): Factor out the
    implementation from here ...
    (erc-track--switch-buffer): ... to here.
    (erc-track-switch-buffer-other-window): New function, like
    `erc-track-switch-buffer', but uses `switch-to-buffer-other-window'
    instead, to open the buffer in another window.
---
 etc/NEWS              |  5 +++++
 lisp/erc/erc-track.el | 32 +++++++++++++++++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index f3ef798..aba3028 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1652,6 +1652,11 @@ which better handles surrounding pair of parentheses.
 which is like 'erc-switch-to-buffer', but opens the buffer in another
 window.
 
+---
+*** New function 'erc-track-switch-buffer-other-window'
+which is like 'erc-track-switch-buffer', but opens the buffer in
+another window.
+
 ** EUDC
 
 ---
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index db8ccbb..41d8fc1 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -921,11 +921,7 @@ is relative to `erc-track-switch-direction'."
           (setq offset 0)))
     (car (nth offset erc-modified-channels-alist))))
 
-(defun erc-track-switch-buffer (arg)
-  "Switch to the next active ERC buffer, or if there are no active buffers,
-switch back to the last non-ERC buffer visited.  Next is defined by
-`erc-track-switch-direction', a negative argument will reverse this."
-  (interactive "p")
+(defun erc-track--switch-buffer (fun arg)
   (if (not erc-track-mode)
       (message (concat "Enable the ERC track module if you want to use the"
                       " tracking minor mode"))
@@ -934,12 +930,30 @@ switch back to the last non-ERC buffer visited.  Next is 
defined by
           (unless (eq major-mode 'erc-mode)
             (setq erc-track-last-non-erc-buffer (current-buffer)))
           ;; and jump to the next active channel
-          (switch-to-buffer (erc-track-get-active-buffer arg)))
+          (funcall fun (erc-track-get-active-buffer arg)))
          ;; if no active channels, switch back to what we were doing before
          ((and erc-track-last-non-erc-buffer
-               erc-track-switch-from-erc
-               (buffer-live-p erc-track-last-non-erc-buffer))
-          (switch-to-buffer erc-track-last-non-erc-buffer)))))
+               erc-track-switch-from-erc
+               (buffer-live-p erc-track-last-non-erc-buffer))
+          (funcall fun erc-track-last-non-erc-buffer)))))
+
+(defun erc-track-switch-buffer (arg)
+  "Switch to the next active ERC buffer.
+If there are no active ERC buffers, switch back to the last
+non-ERC buffer visited.  The order of buffers is defined by
+`erc-track-switch-direction', and a negative argument will
+reverse it."
+  (interactive "p")
+  (erc-track--switch-buffer 'switch-to-buffer arg))
+
+(defun erc-track-switch-buffer-other-window (arg)
+  "Switch to the next active ERC buffer in another window.
+If there are no active ERC buffers, switch back to the last
+non-ERC buffer visited.  The order of buffers is defined by
+`erc-track-switch-direction', and a negative argument will
+reverse it."
+  (interactive "p")
+  (erc-track--switch-buffer 'switch-to-buffer-other-window arg))
 
 (provide 'erc-track)
 



reply via email to

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