summaryrefslogtreecommitdiff
path: root/lisp/erc
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2020-04-15 07:50:15 -0700
committerGlenn Morris <rgm@gnu.org>2020-04-15 07:50:15 -0700
commit97e48510ad4fec9ca5f576a750018a231523f7a6 (patch)
tree06f50ebc5da12038bc4851b44946462a498ac755 /lisp/erc
parentafa542c914379538f986f1428f176ffe42f62609 (diff)
parenta5f7c269075180e4531f0a784201a09b49731a27 (diff)
downloademacs-97e48510ad4fec9ca5f576a750018a231523f7a6.tar.gz
Merge from origin/emacs-27
a5f7c26907 (origin/emacs-27) * admin/authors.el: Add an author alias. d87a4d1f4e Limit RLIMIT_NOFILE to FD_SETSIZE on macOS e5ca8e5e73 Fix Elisp manual entry on 'set-window-configuration' 485f24223f ; Update ChangeLog.3 8f200254fb ; Update etc/AUTHORS c7adc851ad * admin/authors.el: Add missing author aliases. 4acdd7fe58 Fix edge case errors in filename-matching regexps 5f36e21fe5 Clarify the doc string of 'yank' 13301d4266 New function erc-track-switch-buffer-other-window 38f7538d8f New function erc-switch-to-buffer-other-window # Conflicts: # etc/NEWS
Diffstat (limited to 'lisp/erc')
-rw-r--r--lisp/erc/erc-track.el32
-rw-r--r--lisp/erc/erc.el47
2 files changed, 51 insertions, 28 deletions
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'."
(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)
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."
res)))
(define-obsolete-function-alias 'erc-iswitchb 'erc-switch-to-buffer "25.1")
+(defun erc--switch-to-buffer (&optional arg)
+ (read-buffer "Switch to ERC buffer: "
+ (when (boundp 'erc-modified-channels-alist)
+ (buffer-name (caar (last erc-modified-channels-alist))))
+ t
+ ;; Only allow ERC buffers in the same session.
+ (let ((proc (unless arg erc-server-process)))
+ (lambda (bufname)
+ (let ((buf (if (consp bufname)
+ (cdr bufname) (get-buffer bufname))))
+ (when buf
+ (erc--buffer-p buf (lambda () t) proc)
+ (with-current-buffer buf
+ (and (derived-mode-p 'erc-mode)
+ (or (null proc)
+ (eq proc erc-server-process))))))))))
(defun erc-switch-to-buffer (&optional arg)
- "Prompt for a ERC buffer to switch to.
-When invoked with prefix argument, use all erc buffers. Without prefix
-ARG, allow only buffers related to same session server.
+ "Prompt for an ERC buffer to switch to.
+When invoked with prefix argument, use all ERC buffers. Without
+prefix ARG, allow only buffers related to same session server.
If `erc-track-mode' is in enabled, put the last element of
`erc-modified-channels-alist' in front of the buffer list."
(interactive "P")
- (switch-to-buffer
- (read-buffer "Switch to ERC buffer: "
- (when (boundp 'erc-modified-channels-alist)
- (buffer-name (caar (last erc-modified-channels-alist))))
- t
- ;; Only allow ERC buffers in the same session.
- (let ((proc (unless arg erc-server-process)))
- (lambda (bufname)
- (let ((buf (if (consp bufname)
- (cdr bufname) (get-buffer bufname))))
- (when buf
- (erc--buffer-p buf (lambda () t) proc)
- (with-current-buffer buf
- (and (derived-mode-p 'erc-mode)
- (or (null proc)
- (eq proc erc-server-process)))))))))))
+ (switch-to-buffer (erc--switch-to-buffer arg)))
+(defun erc-switch-to-buffer-other-window (&optional arg)
+ "Prompt for an ERC buffer to switch to in another window.
+When invoked with prefix argument, use all ERC buffers. Without
+prefix ARG, allow only buffers related to same session server.
+If `erc-track-mode' is in enabled, put the last element of
+`erc-modified-channels-alist' in front of the buffer list."
+ (interactive "P")
+ (switch-to-buffer-other-window (erc--switch-to-buffer arg)))
(defun erc-channel-list (proc)
"Return a list of channel buffers.