]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/gnus-group.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / gnus / gnus-group.el
index 190acf13870a7a542df4cab8b440cd2131e3f8d7..3de2609457299d4c8e43c97145072a182c09328d 100644 (file)
@@ -421,8 +421,7 @@ For example:
   :type '(repeat (cons (sexp :tag "Method") (symbol :tag "Charset"))))
 
 (defcustom gnus-group-name-charset-group-alist
-  (if (or (and (fboundp 'find-coding-system) (find-coding-system 'utf-8))
-         (mm-coding-system-p 'utf-8))
+  (if (mm-coding-system-p 'utf-8)
       '((".*" . utf-8))
     nil)
   "Alist of group regexp and the charset for group names.
@@ -1085,12 +1084,9 @@ When FORCE, rebuild the tool bar."
              (display-graphic-p)
             (or (not gnus-group-tool-bar-map) force))
     (let* ((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)))
+           (image-load-path-for-library
+            "gnus" "gnus/toggle-subscription.xpm" nil t))
+           (image-load-path (cons (car 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)))
@@ -1145,7 +1141,7 @@ The following commands are available:
       (goto-char (point-min))
       (setq gnus-group-mark-positions
            (list (cons 'process (and (search-forward
-                                      (mm-string-to-multibyte "\200") nil t)
+                                      (string-to-multibyte "\200") nil t)
                                      (- (point) (point-min) 1))))))))
 
 (defun gnus-mouse-pick-group (e)
@@ -1207,8 +1203,8 @@ The following commands are available:
 
 (defun gnus-group-name-decode (string charset)
   ;; Fixme: Don't decode in unibyte mode.
-  (if (and string charset (featurep 'mule))
-      (mm-decode-coding-string string charset)
+  (if (and string charset)
+      (decode-coding-string string charset)
     string))
 
 (defun gnus-group-decoded-name (string)
@@ -1372,7 +1368,7 @@ if it is a string, only list groups matching REGEXP."
     (when (or gnus-group-listed-groups
              (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
       (gnus-group-prepare-flat-list-dead
-       (gnus-union
+       (cl-union
        not-in-list
        (setq gnus-killed-list (sort gnus-killed-list 'string<))
        :test 'equal)
@@ -1396,7 +1392,7 @@ if it is a string, only list groups matching REGEXP."
                 (or (not regexp)
                     (and (stringp regexp) (string-match regexp group))
                     (and (functionp regexp) (funcall regexp group))))
-           (gnus-add-text-properties
+           (add-text-properties
             (point) (prog1 (1+ (point))
                       (insert " " mark "     *: "
                               (gnus-group-decoded-name group)
@@ -1488,12 +1484,10 @@ if it is a string, only list groups matching REGEXP."
 ;; Date: Mon, 23 Jan 2006 19:59:13 +0100
 ;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
 
-(defcustom gnus-group-update-tool-bar
-  (and (boundp 'tool-bar-mode)
-       tool-bar-mode
-       ;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs might
-       ;; be confusing, so maybe we shouldn't call it by default.
-       (fboundp 'force-window-update))
+;; Using `redraw-frame' (see `gnus-tool-bar-update') in Emacs might
+;; be confusing, so maybe we shouldn't call it by default.
+(defcustom gnus-group-update-tool-bar (and (boundp 'tool-bar-mode)
+                                          tool-bar-mode)
   "Force updating the group buffer tool bar."
   :group 'gnus-group
   :version "22.1"
@@ -1574,7 +1568,7 @@ if it is a string, only list groups matching REGEXP."
          gnus-tmp-header)      ; passed as parameter to user-funcs.
     (beginning-of-line)
     (setq beg (point))
-    (gnus-add-text-properties
+    (add-text-properties
      (point)
      (prog1 (1+ (point))
        ;; Insert the text.
@@ -1602,58 +1596,42 @@ if it is a string, only list groups matching REGEXP."
         (progn
           (unless (bound-and-true-p cursor-sensor-mode)
             (cursor-sensor-mode 1))
-          (gnus-put-text-property beg end 'cursor-sensor-functions
+          (put-text-property beg end 'cursor-sensor-functions
                                   '(gnus-tool-bar-update)))
-      (gnus-put-text-property beg end 'point-entered
+      (put-text-property beg end 'point-entered
                               #'gnus-tool-bar-update)
-      (gnus-put-text-property beg end 'point-left
+      (put-text-property beg end 'point-left
                               #'gnus-tool-bar-update))))
 
 (defun gnus-group-update-eval-form (group list)
   "Eval `car' of each element of LIST, and return the first that return t.
 Some value are bound so the form can use them."
-  (defvar group-age) (defvar ticked) (defvar score) (defvar level)
-  (defvar mailp) (defvar total) (defvar unread)
   (when list
     (let* ((entry (gnus-group-entry group))
-           (unread (if (numberp (car entry)) (car entry) 0))
            (active (gnus-active group))
-           (total (if active (1+ (- (cdr active) (car active))) 0))
            (info (nth 2 entry))
-           (method (inline (gnus-server-get-method group (gnus-info-method info))))
+           (method (inline (gnus-server-get-method
+                           group (gnus-info-method info))))
            (marked (gnus-info-marks info))
-           (mailp (apply 'append
-                         (mapcar
-                          (lambda (x)
-                            (memq x (assoc (symbol-name
-                                            (car (or method gnus-select-method)))
-                                           gnus-valid-select-methods)))
-                          '(mail post-mail))))
-           (level (or (gnus-info-level info) gnus-level-killed))
-           (score (or (gnus-info-score info) 0))
-           (ticked (gnus-range-length (cdr (assq 'tick marked))))
-           (group-age (gnus-group-timestamp-delta group)))
-      ;; FIXME: http://thread.gmane.org/gmane.emacs.gnus.general/65451/focus=65465
-      ;; ======================================================================
-      ;; From: Richard Stallman
-      ;; Subject: Re: Rewriting gnus-group-highlight-line (was: [...])
-      ;; Cc: ding@gnus.org
-      ;; Date: Sat, 27 Oct 2007 19:41:20 -0400
-      ;; Message-ID: <E1IlvHM-0006TS-7t@fencepost.gnu.org>
-      ;;
-      ;; [...]
-      ;; The kludge is that the alist elements contain expressions that refer
-      ;; to local variables with short names.  Perhaps write your own tiny
-      ;; evaluator that handles just `and', `or', and numeric comparisons
-      ;; and just a few specific variables.
-      ;; ======================================================================
-      ;;
-      ;; Similar for other evaluated variables.  Grep for risky-local-variable
-      ;; to find them!  -- rsteib
-      ;;
-      ;; Eval the cars of the lists until we find a match.
+          (env
+           (list
+            (cons 'unread (if (numberp (car entry)) (car entry) 0))
+            (cons 'total (if active (1+ (- (cdr active) (car active))) 0))
+            (cons 'mailp (apply
+                          'append
+                          (mapcar
+                           (lambda (x)
+                             (memq x (assoc
+                                      (symbol-name
+                                       (car (or method gnus-select-method)))
+                                      gnus-valid-select-methods)))
+                           '(mail post-mail))))
+            (cons 'level (or (gnus-info-level info) gnus-level-killed))
+            (cons 'score (or (gnus-info-score info) 0))
+            (cons 'ticked (gnus-range-length (cdr (assq 'tick marked))))
+            (cons 'group-age (gnus-group-timestamp-delta group)))))
       (while (and list
-                  (not (eval (caar list))))
+                  (not (eval (caar list) env)))
         (setq list (cdr list)))
       list)))
 
@@ -1664,12 +1642,12 @@ and ends at END."
   (let ((face (cdar (gnus-group-update-eval-form
                       group
                       gnus-group-highlight))))
-    (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
+    (unless (eq face (gnus-get-text-property-excluding-characters-with-faces
+                     beg 'face))
       (let ((inhibit-read-only t))
         (gnus-put-text-property-excluding-characters-with-faces
          beg end 'face
-         (if (boundp face) (symbol-value face) face)))
-      (gnus-extent-start-open beg))))
+         (if (boundp face) (symbol-value face) face))))))
 
 (defun gnus-group-get-icon (group)
   "Return an icon for GROUP according to `gnus-group-icon-list'."
@@ -2216,9 +2194,9 @@ if it is not a list."
                (member group (mapcar 'symbol-name collection))
              (symbol-value (intern-soft group collection)))
       (setq group
-           (mm-encode-coding-string
+           (encode-coding-string
             group (gnus-group-name-charset nil group))))
-    (replace-regexp-in-string group "\n" "")))
+    (replace-regexp-in-string "\n" "" group)))
 
 ;;;###autoload
 (defun gnus-fetch-group (group &optional articles)
@@ -2378,7 +2356,7 @@ specified by `gnus-gmane-group-download-format'."
   (unless range (setq range 500))
   (when (< range 1)
     (error "Invalid range: %s" range))
-  (let ((tmpfile (mm-make-temp-file
+  (let ((tmpfile (make-temp-file
                  (format "%s.start-%s.range-%s." group start range)))
        (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
     (with-temp-file tmpfile
@@ -2464,21 +2442,25 @@ the bug number, and browsing the URL must return mbox output."
     (setq ids (string-to-number ids)))
   (unless (listp ids)
     (setq ids (list ids)))
-  (let ((tmpfile (mm-make-temp-file "gnus-temp-group-")))
+  (let ((tmpfile (make-temp-file "gnus-temp-group-")))
     (let ((coding-system-for-write 'binary)
          (coding-system-for-read 'binary))
       (with-temp-file tmpfile
        (mm-disable-multibyte)
        (dolist (id ids)
-         (url-insert-file-contents (format mbox-url id)))
+         (let ((file (format "~/.emacs.d/debbugs-cache/%s" id)))
+           (if (and (not gnus-plugged)
+                    (file-exists-p file))
+               (insert-file-contents file)
+             (url-insert-file-contents (format mbox-url id)))))
        (goto-char (point-min))
        ;; Add the debbugs address so that we can respond to reports easily.
        (while (re-search-forward "^To: " nil t)
          (end-of-line)
          (insert (format ", %s@%s" (car ids)
                          (replace-regexp-in-string
-                          (replace-regexp-in-string mbox-url "^http://" "")
-                          "/.*$" ""))))))
+                          "/.*$" ""
+                          (replace-regexp-in-string "^http://" "" mbox-url)))))))
     (gnus-group-read-ephemeral-group
      (format "nndoc+ephemeral:bug#%s"
             (mapconcat 'number-to-string ids ","))
@@ -2738,7 +2720,7 @@ server."
   (when (stringp method)
     (setq method (or (gnus-server-to-method method) method)))
   (unless encoded
-    (setq name (mm-encode-coding-string
+    (setq name (encode-coding-string
                name
                (gnus-group-name-charset method name))))
   (let* ((meth (gnus-method-simplify
@@ -2856,7 +2838,7 @@ and NEW-NAME will be prompted for."
                     "Rename group to: "
                     (gnus-group-real-name (gnus-group-decoded-name group)))
           method (gnus-info-method (gnus-get-info group)))
-     (list group (mm-encode-coding-string
+     (list group (encode-coding-string
                  new-name
                  (gnus-group-name-charset
                   method
@@ -2927,7 +2909,7 @@ and NEW-NAME will be prompted for."
            (gnus-info-params info))
           (t info))
      ;; The proper documentation.
-     (gnus-format-message
+     (format-message
       "Editing the %s for `%s'."
       (cond
        ((eq part 'method) "select method")
@@ -3070,9 +3052,9 @@ If called with a prefix argument, ask for the file type."
                       (list 'nndoc-address file)
                       (list 'nndoc-article-type (or type 'guess))))
         (coding (gnus-group-name-charset method name)))
-    (setcar (cdr method) (mm-encode-coding-string file coding))
+    (setcar (cdr method) (encode-coding-string file coding))
     (gnus-group-make-group
-     (mm-encode-coding-string (gnus-group-real-name name) coding)
+     (encode-coding-string (gnus-group-real-name name) coding)
      method nil nil t)))
 
 (defvar nnweb-type-definition)
@@ -3149,8 +3131,8 @@ If there is, use Gnus to create an nnrss group"
               (coding (gnus-group-name-charset '(nnrss "") title)))
          (when coding
            ;; Unify non-ASCII text.
-           (setq title (mm-decode-coding-string
-                        (mm-encode-coding-string title coding)
+           (setq title (decode-coding-string
+                        (encode-coding-string title coding)
                         coding)))
          (gnus-group-make-group title '(nnrss ""))
          (push (list title href desc) nnrss-group-alist)
@@ -3255,7 +3237,7 @@ mail messages or news articles in files that have numeric names."
       (error "%s is not an nnimap group" group))
     (unless (setq acl (nnimap-acl-get mailbox (cadr method)))
       (error "Server does not support ACL's"))
-    (gnus-edit-form acl (gnus-format-message "\
+    (gnus-edit-form acl (format-message "\
 Editing the access control list for `%s'.
 
    An access control list is a list of (identifier . rights) elements.
@@ -4016,7 +3998,7 @@ entail asking the server for the groups."
     (erase-buffer)
     (while groups
       (setq group (pop groups))
-      (gnus-add-text-properties
+      (add-text-properties
        (point) (prog1 (1+ (point))
                 (insert "       *: "
                         (gnus-group-decoded-name group)
@@ -4138,22 +4120,23 @@ If DONT-SCAN is non-nil, scan non-activated groups as well."
                 (gnus-read-all-descriptions-files)))
     (error "Couldn't request descriptions file"))
   (let ((buffer-read-only nil)
-       b)
-    (erase-buffer)
+       b groups)
     (mapatoms
      (lambda (group)
-       (setq b (point))
-       (let ((charset (gnus-group-name-charset nil (symbol-name group))))
-        (insert (format "      *: %-20s %s\n"
-                        (gnus-group-name-decode
-                         (symbol-name group) charset)
-                        (gnus-group-name-decode
-                         (symbol-value group) charset))))
-       (gnus-add-text-properties
-       b (1+ b) (list 'gnus-group group
-                      'gnus-unread t 'gnus-marked nil
-                      'gnus-level (1+ gnus-level-subscribed))))
+       (push (symbol-name group) groups))
      gnus-description-hashtb)
+    (setq groups (sort groups 'string<))
+    (erase-buffer)
+    (dolist (group groups)
+      (setq b (point))
+      (let ((charset (gnus-group-name-charset nil group)))
+       (insert (format "      *: %-20s %s\n"
+                       (gnus-group-name-decode group charset)
+                       (gnus-group-name-decode group charset))))
+      (add-text-properties
+       b (1+ b) (list 'gnus-group (intern group gnus-description-hashtb)
+                     'gnus-unread t 'gnus-marked nil
+                     'gnus-level (1+ gnus-level-subscribed))))
     (goto-char (point-min))
     (gnus-group-position-point)))
 
@@ -4509,7 +4492,7 @@ and the second element is the address."
        (if force
            (if (null articles)
                (setcar (nthcdr 3 info)
-                       (gnus-delete-alist type (car marked)))
+                       (assq-delete-all type (car marked)))
              (setcdr m (gnus-compress-sequence articles t)))
          (setcdr m (gnus-compress-sequence
                     (sort (nconc (gnus-uncompress-range (cdr m))