gnus-art.el (gnus-mime-buttonize-attachments-in-header): Improve criterion that finds...
[gnus] / lisp / mm-util.el
index 129609d..0d02e1d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mm-util.el --- Utility functions for Mule and low level things
 
-;; Copyright (C) 1998-201 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2014 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;     MORIOKA Tomohiko <morioka@jaist.ac.jp>
 
 ;;; Code:
 
-;; For Emacs <22.2 and XEmacs.
-(eval-and-compile
-  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
-
 (eval-when-compile (require 'cl))
 (require 'mail-prsvr)
 
      (multibyte-char-to-unibyte . identity)
      ;; `set-buffer-multibyte' is an Emacs function, not available in XEmacs.
      (set-buffer-multibyte . ignore)
-     ;; `special-display-p' is an Emacs function, not available in XEmacs.
-     (special-display-p
-      . ,(lambda (buffer-name)
-          "Returns non-nil if a buffer named BUFFER-NAME gets a special frame."
-          (and special-display-function
-               (or (and (member buffer-name special-display-buffer-names) t)
-                   (cdr (assoc buffer-name special-display-buffer-names))
-                   (catch 'return
-                     (dolist (elem special-display-regexps)
-                       (and (stringp elem)
-                            (string-match elem buffer-name)
-                            (throw 'return t))
-                       (and (consp elem)
-                            (stringp (car elem))
-                            (string-match (car elem) buffer-name)
-                            (throw 'return (cdr elem)))))))))
      ;; `substring-no-properties' is available only in Emacs 22.1 or greater.
      (substring-no-properties
       . ,(lambda (string &optional from to)
@@ -174,6 +154,25 @@ to the contents of the accessible portion of the buffer."
               (forward-line 0)
               (1+ (count-lines start (point))))))))))
 
+;; `special-display-p' is an Emacs function, not available in XEmacs.
+(defalias 'mm-special-display-p
+  (if (featurep 'emacs)
+      'special-display-p
+    (lambda (buffer-name)
+      "Returns non-nil if a buffer named BUFFER-NAME gets a special frame."
+      (and special-display-function
+          (or (and (member buffer-name special-display-buffer-names) t)
+              (cdr (assoc buffer-name special-display-buffer-names))
+              (catch 'return
+                (dolist (elem special-display-regexps)
+                  (and (stringp elem)
+                       (string-match elem buffer-name)
+                       (throw 'return t))
+                  (and (consp elem)
+                       (stringp (car elem))
+                       (string-match (car elem) buffer-name)
+                       (throw 'return (cdr elem))))))))))
+
 ;; `decode-coding-string', `encode-coding-string', `decode-coding-region'
 ;; and `encode-coding-region' are available in Emacs and XEmacs built with
 ;; the `file-coding' feature, but the XEmacs versions treat nil, that is
@@ -424,7 +423,7 @@ corresponding number of an iso-8859 charset."
   ;; Cf. http://thread.gmane.org/v9lkng5nwy.fsf@marauder.physik.uni-ulm.de
   "List of IBM codepage numbers.
 
-The codepage mappings slighly differ between IBM and other vendors.
+The codepage mappings slightly differ between IBM and other vendors.
 See \"ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/IBM/README.TXT\".
 
 If an element is a number corresponding to a supported windows
@@ -845,17 +844,17 @@ Valid elements include:
           (not lang) nil)
          ;; In XEmacs 21.5 it may be the one like "Japanese (UTF-8)".
          ((string-match "\\`Japanese" lang)
-          ;; Japanese users prefer iso-2022-jp to euc-japan or
-          ;; shift_jis, however iso-8859-1 should be used when
-          ;; there are only ASCII text and Latin-1 characters.
-          '(iso-8859-1 iso-2022-jp iso-2022-jp-2 shift_jis utf-8))))
+          ;; Japanese users prefer iso-2022-jp to others usually used
+          ;; for `buffer-file-coding-system', however iso-8859-1 should
+          ;; be used when there are only ASCII and Latin-1 characters.
+          '(iso-8859-1 iso-2022-jp utf-8))))
   "Preferred coding systems for encoding outgoing messages.
 
 More than one suitable coding system may be found for some text.
 By default, the coding system with the highest priority is used
 to encode outgoing messages (see `sort-coding-systems').  If this
 variable is set, it overrides the default priority."
-  :version "21.2"
+  :version "24.4"
   :type '(repeat (symbol :tag "Coding system"))
   :group 'mime)
 
@@ -1375,17 +1374,18 @@ If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'."
     (write-region start end filename append visit lockname)))
 
 (autoload 'gmm-write-region "gmm-utils")
+(declare-function help-function-arglist "help-fns"
+                 (def &optional preserve-names))
 
 ;; It is not a MIME function, but some MIME functions use it.
 (if (and (fboundp 'make-temp-file)
         (ignore-errors
-          (let ((def (symbol-function 'make-temp-file)))
-            (and (byte-code-function-p def)
-                 (setq def (if (fboundp 'compiled-function-arglist)
-                               ;; XEmacs
-                               (eval (list 'compiled-function-arglist def))
-                             (aref def 0)))
-                 (>= (length def) 4)
+          (let ((def (if (fboundp 'compiled-function-arglist) ;; XEmacs
+                         (eval (list 'compiled-function-arglist
+                                     (symbol-function 'make-temp-file)))
+                       (require 'help-fns)
+                       (help-function-arglist 'make-temp-file t))))
+            (and (>= (length def) 4)
                  (eq (nth 3 def) 'suffix)))))
     (defalias 'mm-make-temp-file 'make-temp-file)
   ;; Stolen (and modified for XEmacs) from Emacs 22.
@@ -1508,8 +1508,8 @@ To make this function work with XEmacs, the APEL package is required."
                      (fboundp 'coding-system-to-mime-charset)))
             (coding-system-to-mime-charset coding-system)))))
 
-(eval-when-compile
-  (require 'jka-compr))
+(defvar jka-compr-acceptable-retval-list)
+(declare-function jka-compr-make-temp-name "jka-compr" (&optional local))
 
 (defun mm-decompress-buffer (filename &optional inplace force)
   "Decompress buffer's contents, depending on jka-compr.
@@ -1592,7 +1592,7 @@ gzip, bzip2, etc. are allowed."
   (unless filename
     (setq filename buffer-file-name))
   (save-excursion
-    (let ((decomp (unless ;; No worth to examine charset of tar files.
+    (let ((decomp (unless ;; Not worth it to examine charset of tar files.
                      (and filename
                           (string-match
                            "\\.\\(?:tar\\.[^.]+\\|tbz\\|tgz\\)\\'"