[ Merge from Emacs: ]
[gnus] / lisp / gnus-group.el
index 096e05d..4861655 100644 (file)
@@ -999,31 +999,6 @@ simple manner.")
 
 (defvar gnus-group-tool-bar-map nil)
 
-;; Work around for Emacs not updating the tool bar, see
-; http://www.google.com/groups?as_umsgid=v9u0an3hti.fsf@marauder.physik.uni-ulm.de
-(defvar gnus-group-redraw-line-number nil
-  "When non-nil, redraw the Group buffer frame when idle.
-Internal variable.")
-;; Don't make this customizable yet.
-
-(defun gnus-group-redraw-check ()
-  "Check if we need to redraw the frame."
-  (when (and gnus-group-redraw-line-number
-            (not (featurep 'xemacs))
-            (boundp 'tool-bar-mode)
-            tool-bar-mode)
-    (let ((no (if (fboundp 'line-number-at-pos) ;; Emacs 22 only
-                 (line-number-at-pos)
-               ;; Not equivalent to `line-number-at-pos' but good enough
-               ;; here:
-               (1+ (count-lines (point-min) (point))))))
-      (unless (eq gnus-group-redraw-line-number no)
-       (setq gnus-group-redraw-line-number no)
-       ;; (run-with-idle-timer 1 nil 'menu-bar-update-buffers t)
-       ;; (run-with-idle-timer 1 nil 'redraw-frame (selected-frame))
-       (run-with-idle-timer 1 nil 'force-window-update)
-        t))))
-
 (defun gnus-group-tool-bar-update (&optional symbol value)
   "Update group buffer toolbar.
 Setter function for custom variables."
@@ -1033,13 +1008,11 @@ Setter function for custom variables."
   ;; (use-local-map gnus-group-mode-map)
   (when (gnus-alive-p)
     (with-current-buffer gnus-group-buffer
-      (when gnus-group-redraw-line-number
-       (add-to-list (make-local-variable 'post-command-hook)
-                    'gnus-group-redraw-check))
       (gnus-group-make-tool-bar t))))
 
-;; The default will be changed when the new icons have been checked in:
-(defcustom gnus-group-tool-bar 'gnus-group-tool-bar-retro
+(defcustom gnus-group-tool-bar (if (eq gmm-tool-bar-style 'gnome)
+                                  'gnus-group-tool-bar-gnome
+                                'gnus-group-tool-bar-retro)
   "Specifies the Gnus group tool bar.
 
 It can be either a list or a symbol refering to a list.  See
@@ -1074,8 +1047,12 @@ Pre-defined symbols include `gnus-group-tool-bar-gnome' and
                             :visible (or (not gnus-agent)
                                          gnus-plugged))
     ;; FIXME: gnus-*-read-group should have a better help text.
-    (gnus-topic-read-group "open" nil :visible gnus-topic-mode)
-    (gnus-group-read-group "open" nil :visible (not gnus-topic-mode))
+    (gnus-topic-read-group "open" nil
+                          :visible (and (boundp 'gnus-topic-mode)
+                                        gnus-topic-mode))
+    (gnus-group-read-group "open" nil
+                          :visible (not (and (boundp 'gnus-topic-mode)
+                                             gnus-topic-mode)))
     ;; (gnus-group-find-new-groups "???" nil)
     (gnus-group-save-newsrc "save")
     (gnus-group-describe-group "describe")
@@ -1083,6 +1060,7 @@ Pre-defined symbols include `gnus-group-tool-bar-gnome' and
     (gnus-group-prev-unread-group "left-arrow")
     (gnus-group-next-unread-group "right-arrow")
     (gnus-group-exit "exit")
+    (gmm-customize-mode "preferences" t :help "Edit mode preferences")
     (gnus-info-find-node "help"))
   "List of functions for the group tool bar (GNOME style).
 
@@ -1134,6 +1112,8 @@ See `gmm-tool-bar-from-list' for the format of the list."
   :set 'gnus-group-tool-bar-update
   :group 'gnus-group)
 
+(defvar image-load-path)
+
 (defun gnus-group-make-tool-bar (&optional force)
   "Make a group mode tool bar from `gnus-group-tool-bar'.
 When FORCE, rebuild the tool bar."
@@ -1144,11 +1124,12 @@ When FORCE, rebuild the tool bar."
             ;; Why?  --rsteib
             (or (not gnus-group-tool-bar-map) force))
     (let* ((load-path
-           (gmm-image-load-path "gnus" "gnus/toggle-subscription.xpm"
-                                'load-path))
-          (image-load-path
-           (gmm-image-load-path "gnus" "gnus/toggle-subscription.xpm"
-                                'image-load-path))
+           (gmm-image-load-path-for-library "gnus"
+                                            "gnus/toggle-subscription.xpm"
+                                            nil t))
+           (image-load-path (cons (car load-path)
+                                  (when (boundp 'image-load-path)
+                                    image-load-path)))
           (map (gmm-tool-bar-from-list gnus-group-tool-bar
                                        gnus-group-tool-bar-zap-list
                                        'gnus-group-mode-map)))
@@ -1526,6 +1507,18 @@ if it is a string, only list groups matching REGEXP."
                (gnus-range-difference (list active) (gnus-info-read info))
                seen))))))
 
+(defcustom gnus-group-update-tool-bar
+  (and (not (featurep 'xemacs))
+       (boundp 'tool-bar-mode)
+       tool-bar-mode
+       ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs 21 might
+       ;; be confusing, so maybe we shouldn't call it by default.
+       (fboundp 'force-window-update))
+  "Force updating the group buffer tool bar."
+  :group 'gnus-group
+  :version "22.1"
+  :type 'boolean)
+
 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
                                                    gnus-tmp-marked number
                                                    gnus-tmp-method)
@@ -1590,8 +1583,10 @@ if it is a string, only list groups matching REGEXP."
          (if (member gnus-tmp-group gnus-group-marked)
              gnus-process-mark ? ))
         (buffer-read-only nil)
+        beg end
         header gnus-tmp-header)        ; passed as parameter to user-funcs.
     (beginning-of-line)
+    (setq beg (point))
     (gnus-add-text-properties
      (point)
      (prog1 (1+ (point))
@@ -1606,6 +1601,12 @@ if it is a string, only list groups matching REGEXP."
                  gnus-marked ,gnus-tmp-marked-mark
                  gnus-indentation ,gnus-group-indentation
                  gnus-level ,gnus-tmp-level))
+    (setq end (point))
+    (when gnus-group-update-tool-bar
+      (gnus-put-text-property beg end 'point-entered
+                             'gnus-tool-bar-update)
+      (gnus-put-text-property beg end 'point-left
+                             'gnus-tool-bar-update))
     (forward-line -1)
     (when (inline (gnus-visual-p 'group-highlight 'highlight))
       (gnus-run-hooks 'gnus-group-update-hook))
@@ -3788,7 +3789,10 @@ re-scanning.  If ARG is non-nil and not a number, this will force
 
     ;; We might read in new NoCeM messages here.
     (when (and gnus-use-nocem
-              (null arg))
+              (or (and (numberp gnus-use-nocem)
+                       (numberp arg)
+                       (>= arg gnus-use-nocem))
+                  (not arg)))
       (gnus-nocem-scan-groups))
     ;; If ARG is not a number, then we read the active file.
     (when (and arg (not (numberp arg)))