aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmin Bandali2020-04-14 00:23:56 -0400
committerAmin Bandali2020-04-14 00:23:56 -0400
commit13301d4266d26882f9fe7efe3046accd315d7c55 (patch)
treeb5aa49a90f9531ade3fe5161bc168f25a85aa064
parent38f7538d8f62ee287e8271d048f1230d840c11a0 (diff)
downloademacs-13301d4266d26882f9fe7efe3046accd315d7c55.tar.gz
emacs-13301d4266d26882f9fe7efe3046accd315d7c55.zip
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.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/erc/erc-track.el32
2 files changed, 28 insertions, 9 deletions
diff --git a/etc/NEWS b/etc/NEWS
index f3ef798a426..aba3028184b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1652,6 +1652,11 @@ which better handles surrounding pair of parentheses.
1652which is like 'erc-switch-to-buffer', but opens the buffer in another 1652which is like 'erc-switch-to-buffer', but opens the buffer in another
1653window. 1653window.
1654 1654
1655---
1656*** New function 'erc-track-switch-buffer-other-window'
1657which is like 'erc-track-switch-buffer', but opens the buffer in
1658another window.
1659
1655** EUDC 1660** EUDC
1656 1661
1657--- 1662---
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index db8ccbb4a79..41d8fc1a98f 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -921,11 +921,7 @@ is relative to `erc-track-switch-direction'."
921 (setq offset 0))) 921 (setq offset 0)))
922 (car (nth offset erc-modified-channels-alist)))) 922 (car (nth offset erc-modified-channels-alist))))
923 923
924(defun erc-track-switch-buffer (arg) 924(defun erc-track--switch-buffer (fun arg)
925 "Switch to the next active ERC buffer, or if there are no active buffers,
926switch back to the last non-ERC buffer visited. Next is defined by
927`erc-track-switch-direction', a negative argument will reverse this."
928 (interactive "p")
929 (if (not erc-track-mode) 925 (if (not erc-track-mode)
930 (message (concat "Enable the ERC track module if you want to use the" 926 (message (concat "Enable the ERC track module if you want to use the"
931 " tracking minor mode")) 927 " tracking minor mode"))
@@ -934,12 +930,30 @@ switch back to the last non-ERC buffer visited. Next is defined by
934 (unless (eq major-mode 'erc-mode) 930 (unless (eq major-mode 'erc-mode)
935 (setq erc-track-last-non-erc-buffer (current-buffer))) 931 (setq erc-track-last-non-erc-buffer (current-buffer)))
936 ;; and jump to the next active channel 932 ;; and jump to the next active channel
937 (switch-to-buffer (erc-track-get-active-buffer arg))) 933 (funcall fun (erc-track-get-active-buffer arg)))
938 ;; if no active channels, switch back to what we were doing before 934 ;; if no active channels, switch back to what we were doing before
939 ((and erc-track-last-non-erc-buffer 935 ((and erc-track-last-non-erc-buffer
940 erc-track-switch-from-erc 936 erc-track-switch-from-erc
941 (buffer-live-p erc-track-last-non-erc-buffer)) 937 (buffer-live-p erc-track-last-non-erc-buffer))
942 (switch-to-buffer erc-track-last-non-erc-buffer))))) 938 (funcall fun erc-track-last-non-erc-buffer)))))
939
940(defun erc-track-switch-buffer (arg)
941 "Switch to the next active ERC buffer.
942If there are no active ERC buffers, switch back to the last
943non-ERC buffer visited. The order of buffers is defined by
944`erc-track-switch-direction', and a negative argument will
945reverse it."
946 (interactive "p")
947 (erc-track--switch-buffer 'switch-to-buffer arg))
948
949(defun erc-track-switch-buffer-other-window (arg)
950 "Switch to the next active ERC buffer in another window.
951If there are no active ERC buffers, switch back to the last
952non-ERC buffer visited. The order of buffers is defined by
953`erc-track-switch-direction', and a negative argument will
954reverse it."
955 (interactive "p")
956 (erc-track--switch-buffer 'switch-to-buffer-other-window arg))
943 957
944(provide 'erc-track) 958(provide 'erc-track)
945 959