erc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Erc-commit] [commit][emacs22] Many fixes to erc-track.el


From: mwolson
Subject: [Erc-commit] [commit][emacs22] Many fixes to erc-track.el
Date: Sun, 14 Oct 2007 00:49:09 -0400

commit 21f04e6eeb3daebf970e74346696fd1e95ee408f
Author: Jeremy Maitin-Shepard <address@hidden>
Date:   Tue Aug 14 16:40:11 2007 -0400

    Many fixes to erc-track.el
    
    - Added variable `erc-track-remove-disconnected-buffers', which controls
      whether buffers associated with a server that is disconnected should
      be removed from `erc-modified-channels-alist'.  Existing behavior is
      to unconditionally remove such buffers, which is achieved by setting
      `erc-track-removed-disconnected-buffers' to t.  When set to t, which
      is the new default value, such buffers remain in the list, which I
      think is often the desired behavior, since the user may likely wish to
      find out about activity that occurred in a channel prior to it being
      disconnected.
    
    - Added hook `erc-track-list-changed-hook'.  This is run whenever the
      contents of `erc-modified-channels-alist' changes; it is useful for
      users such as myself that don't use the default mode-line
      notification but instead use a separate mechanism (which is tied to my
      window manager) to provide notification of channel activity.
    
    - Added function `erc-track-get-buffer-window' as a wrapper around
      `get-buffer-window' that handles the `selected-visible' option of
      `erc-track-visibility'; previously, the value of
      `erc-track-visibility' was passed directly to `get-buffer-window',
      which does not support `selected-visible'; consequently,
      `selected-visible' was not properly supported.
    
    - Fixed a bug in the logic in `erc-track-modified-channels' for removing
      buffers from the list in certain cases.

diff --git a/erc-track.el b/erc-track.el
index f72a5be..3cb1206 100644
--- a/erc-track.el
+++ b/erc-track.el
@@ -95,6 +95,12 @@ Activity means that there was no user input in the last 10 
seconds."
   :group 'erc-track
   :type '(repeat string))
 
+(defcustom erc-track-remove-disconnected-buffers nil
+  "*If true, remove buffers associated with a server that is
+disconnected from `erc-modified-channels-alist'."
+  :group 'erc-track
+  :type 'boolean)
+
 (defcustom erc-track-exclude-types '("NICK")
   "*List of message types to be ignored.
 This list could look like '(\"JOIN\" \"PART\")."
@@ -151,6 +157,8 @@ If nil instead of a function, shortening is disabled."
   :type '(choice (const :tag "Disabled")
                 function))
 
+(defvar erc-track-list-changed-hook nil)
+
 (defcustom erc-track-use-faces t
   "*Use faces in the mode-line.
 The faces used are the same as used for text in the buffers.
@@ -192,12 +200,14 @@ Setting this variable only has effects in GNU Emacs 
versions above 21.3.
 Choices are:
 'before-modes - add to the beginning of `mode-line-modes'
 'after-modes  - add to the end of `mode-line-modes'
-
-Any other value means add to the end of `global-mode-string'."
+t             - add to the end of `global-mode-string'.
+nil           - don't add to mode line
+"
   :group 'erc-track
   :type '(choice (const :tag "Just before mode information" before-modes)
                 (const :tag "Just after mode information" after-modes)
-                (const :tag "After all other information" nil))
+                (const :tag "After all other information" t)
+                (const :tag "Don't display in mode line" nil))
   :set (lambda (sym val)
         (set sym val)
         (when (and (boundp 'erc-track-mode)
@@ -296,7 +306,7 @@ See `erc-track-position-in-mode-line' for possible values."
              (boundp 'mode-line-modes))
         (add-to-list 'mode-line-modes
                      '(t erc-modified-channels-object) t))
-       (t
+       ((eq position t)
         (when (not global-mode-string)
           (setq global-mode-string '(""))) ; Padding for mode-line wart
         (add-to-list 'global-mode-string
@@ -644,14 +654,21 @@ only consider active buffers visible.")
   (setq erc-buffer-activity (erc-current-time))
   (erc-track-modified-channels))
 
+(defun erc-track-get-buffer-window (buffer frame-param)
+  (if (eq frame-param 'selected-visible)
+      (if (eq (frame-visible-p (selected-frame)) t)
+         (get-buffer-window buffer nil)
+       nil)
+    (get-buffer-window buffer frame-param)))
+
 (defun erc-buffer-visible (buffer)
   "Return non-nil when the buffer is visible."
   (if erc-track-when-inactive
       (when erc-buffer-activity; could be nil
-       (and (get-buffer-window buffer erc-track-visibility)
+       (and (erc-track-get-buffer-window buffer erc-track-visibility)
             (<= (erc-time-diff erc-buffer-activity (erc-current-time))
                 erc-buffer-activity-timeout)))
-    (get-buffer-window buffer erc-track-visibility)))
+    (erc-track-get-buffer-window buffer erc-track-visibility)))
 
 ;;; Tracking the channel modifications
 
@@ -668,18 +685,22 @@ called via `window-configuration-change-hook'.
 ARGS are ignored."
   (interactive)
   (unless erc-modified-channels-update-inside
-    (let ((erc-modified-channels-update-inside t))
+    (let ((erc-modified-channels-update-inside t)
+         (removed-channel nil))
       (mapcar (lambda (elt)
                (let ((buffer (car elt)))
                  (when (or (not (bufferp buffer))
                            (not (buffer-live-p buffer))
                            (erc-buffer-visible buffer)
+                           (and erc-track-remove-disconnected-buffers
                            (not (with-current-buffer buffer
-                                  erc-server-connected)))
+                                       erc-server-connected))))
+                   (setq removed-channel t)
                    (erc-modified-channels-remove-buffer buffer))))
              erc-modified-channels-alist)
+      (when removed-channel
       (erc-modified-channels-display)
-      (force-mode-line-update t))))
+       (force-mode-line-update t)))))
 
 (defvar erc-track-mouse-face (if (featurep 'xemacs)
                                 'modeline-mousable
@@ -733,6 +754,8 @@ Use `erc-make-mode-line-buffer-name' to create buttons."
        (eq 'mostactive erc-track-switch-direction)
        (eq 'leastactive erc-track-switch-direction))
       (erc-track-sort-by-activest))
+  (run-hooks 'erc-track-list-changed-hook)
+  (unless (eq erc-track-position-in-mode-line nil)
   (if (null erc-modified-channels-alist)
       (setq erc-modified-channels-object (erc-modified-channels-object nil))
     ;; erc-modified-channels-alist contains all the data we need.  To
@@ -768,7 +791,7 @@ Use `erc-make-mode-line-buffer-name' to create buttons."
       (when (featurep 'xemacs)
        (erc-modified-channels-object nil))
       (setq erc-modified-channels-object
-           (erc-modified-channels-object strings)))))
+             (erc-modified-channels-object strings))))))
 
 (defun erc-modified-channels-remove-buffer (buffer)
   "Remove BUFFER from `erc-modified-channels-alist'."
@@ -802,8 +825,7 @@ is in `erc-mode'."
     (if (and (not (erc-buffer-visible (current-buffer)))
             (not (member this-channel erc-track-exclude))
             (not (and erc-track-exclude-server-buffer
-                      (string= this-channel
-                               (buffer-name (erc-server-buffer)))))
+                      (erc-server-buffer-p)))
             (not (erc-message-type-member
                   (or (erc-find-parsed-property)
                       (point-min))
@@ -847,10 +869,10 @@ is in `erc-mode'."
            (erc-modified-channels-display)))
       ;; Else if the active buffer is the current buffer, remove it
       ;; from our list.
-      (when (or (erc-buffer-visible (current-buffer))
+      (when (and (or (erc-buffer-visible (current-buffer))
                (and this-channel
-                    (assq (current-buffer) erc-modified-channels-alist)
                     (member this-channel erc-track-exclude)))
+                (assq (current-buffer) erc-modified-channels-alist))
        ;; Remove it from mode-line if buffer is visible or
        ;; channel was added to erc-track-exclude recently.
        (erc-modified-channels-remove-buffer (current-buffer))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]