[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-commit] [commit][emacs22] erc-goodies: Fix bug with buffer ordering
From: |
mwolson |
Subject: |
[Erc-commit] [commit][emacs22] erc-goodies: Fix bug with buffer ordering in erc-scroll-to-bottom |
Date: |
Sun, 14 Oct 2007 00:49:03 -0400 |
commit 4050552ba8737dd6c90e2df749480d757e82bbe9
Author: Michael Olson <address@hidden>
Date: Wed Jun 13 00:25:47 2007 +0000
erc-goodies: Fix bug with buffer ordering in erc-scroll-to-bottom
2007-06-13 Michael Olson <address@hidden>
* erc-compat.el (erc-with-selected-window): New compatibility
macro that implements `with-selected-window'.
* erc-goodies.el (erc-scroll-to-bottom): Use it. This fixes a bug
with buffer ordering where ERC buffers would move to the top.
Thanks to Ivan Kanis for the patch.
git-archimport-id: address@hidden/erc--main--0--patch-149
diff --git a/CREDITS b/CREDITS
index bf10c21..d7f9ba9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -161,6 +161,9 @@ Leo <sdl.web AT gmail.com>:
Vivek Dasmohapatra <vivek AT etla DOT org>:
* Fixed issue with reconnecting to a not-yet-dead server connection.
+Ivan Kanis <apple AT kanis DOT eu>:
+ * Fixed window ordering bug in erc-goodies.el (1 line changed).
+
----
diff --git a/ChangeLog b/ChangeLog
index 0f6f03f..f048b8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-13 Michael Olson <address@hidden>
+
+ * erc-compat.el (erc-with-selected-window): New compatibility
+ macro that implements `with-selected-window'.
+
+ * erc-goodies.el (erc-scroll-to-bottom): Use it. This fixes a bug
+ with buffer ordering where ERC buffers would move to the top.
+ Thanks to Ivan Kanis for the patch.
+
2007-06-10 Michael Olson <address@hidden>
* erc-log.el (erc-logging-enabled): Fix a bug that occurred when
diff --git a/erc-compat.el b/erc-compat.el
index 58afcb0..dba5911 100644
--- a/erc-compat.el
+++ b/erc-compat.el
@@ -288,6 +288,40 @@ starting with a character."
(setq pairs (cddr pairs)))
(nreverse alist)))))
+;; Emacs21 does not have `with-selected-window', but Emacs22 and
+;; XEmacs do.
+(if (or (fboundp 'with-selected-window)
+ (condition-case nil
+ (progn
+ (require 'window)
+ (fboundp 'with-selected-window))
+ (error nil)))
+ (defmacro erc-with-selected-window (window &rest body)
+ "Execute the forms in BODY with WINDOW as the selected window.
+The value returned is the value of the last form in BODY."
+ (cons 'with-selected-window (cons window body)))
+ ;; ripped from subr.el in Emacs 22
+ (defmacro erc-with-selected-window (window &rest body)
+ "Execute the forms in BODY with WINDOW as the selected window.
+The value returned is the value of the last form in BODY."
+ `(let ((save-selected-window-window (selected-window))
+ (save-selected-window-alist
+ (mapcar (lambda (frame) (list frame (frame-selected-window frame)))
+ (frame-list))))
+ (save-current-buffer
+ (unwind-protect
+ (progn (select-window ,window 'norecord)
+ ,@body)
+ (dolist (elt save-selected-window-alist)
+ (and (frame-live-p (car elt))
+ (window-live-p (cadr elt))
+ (set-frame-selected-window (car elt) (cadr elt))))
+ (if (window-live-p save-selected-window-window)
+ (select-window save-selected-window-window 'norecord)))))))
+
+(put 'erc-with-selected-window 'lisp-indent-function 1)
+(put 'erc-with-selected-window 'edebug-form-spec '(form body))
+
;; Emacs has `cancel-timer', but XEmacs uses `delete-itimer'.
(defun erc-cancel-timer (timer)
(cond ((fboundp 'cancel-timer)
diff --git a/erc-goodies.el b/erc-goodies.el
index 933e6b3..e7b4de5 100644
--- a/erc-goodies.el
+++ b/erc-goodies.el
@@ -84,8 +84,7 @@ DISPLAY-START is ignored."
;; works, but it solves the problem, and has no negative side effects.
;; (Fran Litterio, 2003/01/07)
(let ((resize-mini-windows nil))
- (save-selected-window
- (select-window window)
+ (erc-with-selected-window window
(save-restriction
(widen)
(when (and erc-insert-marker
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Erc-commit] [commit][emacs22] erc-goodies: Fix bug with buffer ordering in erc-scroll-to-bottom,
mwolson <=