aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmin Bandali2020-04-13 23:21:34 -0400
committerAmin Bandali2020-04-13 23:35:34 -0400
commit38f7538d8f62ee287e8271d048f1230d840c11a0 (patch)
tree9182a733b4dd448b124cc63175509feac658a8e2
parentf84aed5fd233d59196d942acfb67bb4051c69cf1 (diff)
downloademacs-38f7538d8f62ee287e8271d048f1230d840c11a0.tar.gz
emacs-38f7538d8f62ee287e8271d048f1230d840c11a0.zip
New function erc-switch-to-buffer-other-window
* lisp/erc/erc.el (erc-switch-to-buffer): Factor out the buffer choice implementation from here ... (erc--switch-to-buffer): ... to here. (erc-switch-to-buffer-other-window): New function, like `erc-switch-to-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.el47
2 files changed, 33 insertions, 19 deletions
diff --git a/etc/NEWS b/etc/NEWS
index f4edfaf9bec..f3ef798a426 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1647,6 +1647,11 @@ adjacent to an apostrophe, like "nick's".
1647*** Set 'erc-button-url-regexp' to 'browse-url-button-regexp' 1647*** Set 'erc-button-url-regexp' to 'browse-url-button-regexp'
1648which better handles surrounding pair of parentheses. 1648which better handles surrounding pair of parentheses.
1649 1649
1650---
1651*** New function 'erc-switch-to-buffer-other-window'
1652which is like 'erc-switch-to-buffer', but opens the buffer in another
1653window.
1654
1650** EUDC 1655** EUDC
1651 1656
1652--- 1657---
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 5c63382d86f..cc5226bf6ed 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1762,29 +1762,38 @@ nil."
1762 res))) 1762 res)))
1763 1763
1764(define-obsolete-function-alias 'erc-iswitchb 'erc-switch-to-buffer "25.1") 1764(define-obsolete-function-alias 'erc-iswitchb 'erc-switch-to-buffer "25.1")
1765(defun erc--switch-to-buffer (&optional arg)
1766 (read-buffer "Switch to ERC buffer: "
1767 (when (boundp 'erc-modified-channels-alist)
1768 (buffer-name (caar (last erc-modified-channels-alist))))
1769 t
1770 ;; Only allow ERC buffers in the same session.
1771 (let ((proc (unless arg erc-server-process)))
1772 (lambda (bufname)
1773 (let ((buf (if (consp bufname)
1774 (cdr bufname) (get-buffer bufname))))
1775 (when buf
1776 (erc--buffer-p buf (lambda () t) proc)
1777 (with-current-buffer buf
1778 (and (derived-mode-p 'erc-mode)
1779 (or (null proc)
1780 (eq proc erc-server-process))))))))))
1765(defun erc-switch-to-buffer (&optional arg) 1781(defun erc-switch-to-buffer (&optional arg)
1766 "Prompt for a ERC buffer to switch to. 1782 "Prompt for an ERC buffer to switch to.
1767When invoked with prefix argument, use all erc buffers. Without prefix 1783When invoked with prefix argument, use all ERC buffers. Without
1768ARG, allow only buffers related to same session server. 1784prefix ARG, allow only buffers related to same session server.
1769If `erc-track-mode' is in enabled, put the last element of 1785If `erc-track-mode' is in enabled, put the last element of
1770`erc-modified-channels-alist' in front of the buffer list." 1786`erc-modified-channels-alist' in front of the buffer list."
1771 (interactive "P") 1787 (interactive "P")
1772 (switch-to-buffer 1788 (switch-to-buffer (erc--switch-to-buffer arg)))
1773 (read-buffer "Switch to ERC buffer: " 1789(defun erc-switch-to-buffer-other-window (&optional arg)
1774 (when (boundp 'erc-modified-channels-alist) 1790 "Prompt for an ERC buffer to switch to in another window.
1775 (buffer-name (caar (last erc-modified-channels-alist)))) 1791When invoked with prefix argument, use all ERC buffers. Without
1776 t 1792prefix ARG, allow only buffers related to same session server.
1777 ;; Only allow ERC buffers in the same session. 1793If `erc-track-mode' is in enabled, put the last element of
1778 (let ((proc (unless arg erc-server-process))) 1794`erc-modified-channels-alist' in front of the buffer list."
1779 (lambda (bufname) 1795 (interactive "P")
1780 (let ((buf (if (consp bufname) 1796 (switch-to-buffer-other-window (erc--switch-to-buffer arg)))
1781 (cdr bufname) (get-buffer bufname))))
1782 (when buf
1783 (erc--buffer-p buf (lambda () t) proc)
1784 (with-current-buffer buf
1785 (and (derived-mode-p 'erc-mode)
1786 (or (null proc)
1787 (eq proc erc-server-process)))))))))))
1788 1797
1789(defun erc-channel-list (proc) 1798(defun erc-channel-list (proc)
1790 "Return a list of channel buffers. 1799 "Return a list of channel buffers.