diff options
| author | Amin Bandali | 2020-04-13 23:21:34 -0400 |
|---|---|---|
| committer | Amin Bandali | 2020-04-13 23:35:34 -0400 |
| commit | 38f7538d8f62ee287e8271d048f1230d840c11a0 (patch) | |
| tree | 9182a733b4dd448b124cc63175509feac658a8e2 | |
| parent | f84aed5fd233d59196d942acfb67bb4051c69cf1 (diff) | |
| download | emacs-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/NEWS | 5 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 47 |
2 files changed, 33 insertions, 19 deletions
| @@ -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' |
| 1648 | which better handles surrounding pair of parentheses. | 1648 | which better handles surrounding pair of parentheses. |
| 1649 | 1649 | ||
| 1650 | --- | ||
| 1651 | *** New function 'erc-switch-to-buffer-other-window' | ||
| 1652 | which is like 'erc-switch-to-buffer', but opens the buffer in another | ||
| 1653 | window. | ||
| 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. |
| 1767 | When invoked with prefix argument, use all erc buffers. Without prefix | 1783 | When invoked with prefix argument, use all ERC buffers. Without |
| 1768 | ARG, allow only buffers related to same session server. | 1784 | prefix ARG, allow only buffers related to same session server. |
| 1769 | If `erc-track-mode' is in enabled, put the last element of | 1785 | If `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)))) | 1791 | When invoked with prefix argument, use all ERC buffers. Without |
| 1776 | t | 1792 | prefix ARG, allow only buffers related to same session server. |
| 1777 | ;; Only allow ERC buffers in the same session. | 1793 | If `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. |