Merge from gnus--rel--5.10
[gnus] / lisp / gmm-utils.el
index e773aa3..1d9f30c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; gmm-utils.el --- Utility functions for Gnus, Message and MML
 
-;; Copyright (C) 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Reiner Steib <reiner.steib@gmx.de>
 ;; Keywords: news
@@ -9,7 +9,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -26,7 +26,7 @@
 
 ;; This library provides self-contained utility functions.  The functions are
 ;; used in Gnus, Message and MML, but within this library there are no
-;; dependencies on Gnus, Message, or MML or Gnus.
+;; dependencies on Gnus, Message, or MML.
 
 ;;; Code:
 
@@ -49,6 +49,19 @@ jabbering all the time."
   :type 'integer
   :group 'gmm)
 
+;;;###autoload
+(defun gmm-regexp-concat (regexp)
+  "Potentially concat a list of regexps into a single one.
+The concatenation is done with logical ORs."
+  (cond ((null regexp)
+        nil)
+       ((stringp regexp)
+        regexp)
+       ((listp regexp)
+        (mapconcat (lambda (elt) (concat "\\(" elt "\\)"))
+                   regexp
+                   "\\|"))))
+
 ;;;###autoload
 (defun gmm-message (level &rest args)
   "If LEVEL is lower than `gmm-verbose' print ARGS using `message'.
@@ -79,7 +92,7 @@ ARGS are passed to `message'."
 
 ;;;###autoload
 (defun gmm-widget-p (symbol)
-  "Non-nil iff SYMBOL is a widget."
+  "Non-nil if SYMBOL is a widget."
   (get symbol 'widget-type))
 
 ;; Copy of the `nnmail-lazy' code from `nnmail.el':
@@ -203,8 +216,8 @@ This is copy of the `lazy' widget in Emacs 22.1 provided for compatibility."
       'gnome
     'retro)
   "Prefered tool bar style."
-  :type '(choice (const :tag "GNOME style" 'gnome)
-                (const :tag "Retro look"  'retro))
+  :type '(choice (const :tag "GNOME style" gnome)
+                (const :tag "Retro look"  retro))
   :group 'gmm)
 
 (defvar tool-bar-map)
@@ -217,7 +230,7 @@ Within each entry of ICON-LIST, the first element is a menu
 command, the second element is an icon file name and the third
 element is a test function.  You can use \\[describe-key]
 <menu-entry> to find out the name of a menu command.  The fourth
-and all following elements are passed a the PROPS argument to the
+and all following elements are passed as the PROPS argument to the
 function `tool-bar-local-item'.
 
 If ZAP-LIST is a list, remove those item from the default
@@ -401,6 +414,21 @@ If mode is nil, use `major-mode' of the curent buffer."
                 (string-match "^\\(.+\\)-mode$" mode)
                 (match-string 1 mode))))))
 
+(defun gmm-write-region (start end filename &optional append visit
+                              lockname mustbenew)
+  "Compatibility function for `write-region'.
+
+In XEmacs, the seventh argument of `write-region' specifies the
+coding-system."
+  (if (and mustbenew
+          (or (featurep 'xemacs)
+              (= emacs-major-version 20)))
+      (if (file-exists-p filename)
+         (signal 'file-already-exists
+                 (list "File exists" filename))
+       (write-region start end filename append visit lockname))
+    (write-region start end filename append visit lockname mustbenew)))
+
 (provide 'gmm-utils)
 
 ;; arch-tag: e0b60920-2ce6-40c1-bfc0-cadbbe26b602