]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/message.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / gnus / message.el
index 5551820a2cdd116543cd21cc6fa0517fe7db702f..1ca7c5cafef737f6f6cf5997776a9b46ebfb2a31 100644 (file)
 ;; This is apparently necessary even though things are autoloaded.
 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better
 ;; require mailabbrev here.
-(if (featurep 'xemacs)
-    (require 'mail-abbrevs)
-  (require 'mailabbrev))
+(require 'mailabbrev)
 (require 'mail-parse)
 (require 'mml)
 (require 'rfc822)
 (require 'format-spec)
 (require 'dired)
+(require 'mm-util)
+(require 'rfc2047)
+(require 'puny)
 
-(autoload 'mailclient-send-it "mailclient") ;; Emacs 22 or contrib/
+(autoload 'mailclient-send-it "mailclient")
 
 (defvar gnus-message-group-art)
 (defvar gnus-list-identifiers) ; gnus-sum is required where necessary
@@ -1249,11 +1250,7 @@ called and its result is inserted."
          (if (and (boundp 'mail-archive-file-name)
                   (stringp mail-archive-file-name))
              (format "FCC: %s\n" mail-archive-file-name))
-         ;; Use the value of `mail-default-headers' if available.
-         ;; Note: as for XEmacs 21.4 and 21.5, it is unavailable
-         ;; unless sendmail.el is loaded.
-         (if (boundp 'mail-default-headers)
-             mail-default-headers))
+         mail-default-headers)
   "*A string of header lines to be inserted in outgoing mails."
   :version "23.2"
   :group 'message-headers
@@ -1346,18 +1343,19 @@ If nil, Message won't auto-save."
   :link '(custom-manual "(message)Various Message Variables")
   :type '(choice directory (const :tag "Don't auto-save" nil)))
 
-(defcustom message-default-charset
-  (and (not (mm-multibyte-p)) 'iso-8859-1)
+(defcustom message-default-charset (and (not (mm-multibyte-p)) 'iso-8859-1)
   "Default charset used in non-MULE Emacsen.
 If nil, you might be asked to input the charset."
   :version "21.1"
   :group 'message
   :link '(custom-manual "(message)Various Message Variables")
   :type 'symbol)
+(make-obsolete-variable
+ 'message-default-charset
+ "The default charset comes from the language environment" "25.2")
 
-(defcustom message-dont-reply-to-names
-  (and (boundp 'mail-dont-reply-to-names) mail-dont-reply-to-names)
-  "*Addresses to prune when doing wide replies.
+(defcustom message-dont-reply-to-names mail-dont-reply-to-names
+  "Addresses to prune when doing wide replies.
 This can be a regexp, a list of regexps or a predicate function.
 Also, a value of nil means exclude your own user name only.
 
@@ -1370,10 +1368,9 @@ If a function email is passed as the argument."
                 (repeat :tag "Regexp List" regexp)))
 
 (defsubst message-dont-reply-to-names ()
-  (cond ((functionp message-dont-reply-to-names)
-         message-dont-reply-to-names)
-        ((stringp message-dont-reply-to-names)
-         (gmm-regexp-concat message-dont-reply-to-names))))
+  (if (functionp message-dont-reply-to-names)
+      message-dont-reply-to-names
+    (gmm-regexp-concat message-dont-reply-to-names)))
 
 (defvar message-shoot-gnksa-feet nil
   "*A list of GNKSA feet you are allowed to shoot.
@@ -1635,11 +1632,6 @@ starting with `not' and followed by regexps."
        (0 'message-mml))))
   "Additional expressions to highlight in Message mode.")
 
-
-;; XEmacs does it like this.  For Emacs, we have to set the
-;; `font-lock-defaults' buffer-local variable.
-(put 'message-mode 'font-lock-defaults '(message-font-lock-keywords t))
-
 (defvar message-face-alist
   '((bold . message-bold-region)
     (underline . underline-region)
@@ -1681,12 +1673,8 @@ news."
 (defvar message-send-coding-system 'binary
   "Coding system to encode outgoing mail.")
 
-(defvar message-draft-coding-system
-  mm-auto-save-coding-system
-  "*Coding system to compose mail.
-If you'd like to make it possible to share draft files between XEmacs
-and Emacs, you may use `iso-2022-7bit' for this value at your own risk.
-Note that the coding-system `iso-2022-7bit' isn't suitable to all data.")
+(defvar message-draft-coding-system mm-auto-save-coding-system
+  "Coding system to compose mail.")
 
 (defcustom message-send-mail-partially-limit nil
   "The limitation of messages sent as message/partial.
@@ -1769,25 +1757,9 @@ no, only reply back to the author."
   :type '(radio (const :format "%v  " nil)
                (string :format "FQDN: %v")))
 
-(defcustom message-use-idna
-  (and (or (mm-coding-system-p 'utf-8)
-          (condition-case nil
-              (let (mucs-ignore-version-incompatibilities)
-                (require 'un-define))
-            (error)))
-       (condition-case nil
-          (require 'idna)
-        (file-error)
-        (invalid-operation))
-       idna-program
-       (executable-find idna-program)
-       (string= (idna-to-ascii "räksmörgås") "xn--rksmrgs-5wao1o")
-       t)
-  "Whether to encode non-ASCII in domain names into ASCII according to IDNA.
-GNU Libidn, and in particular the elisp package \"idna.el\" and
-the external program \"idn\", must be installed for this
-functionality to work."
-  :version "22.1"
+(defcustom message-use-idna t
+  "Whether to encode non-ASCII in domain names into ASCII according to IDNA."
+  :version "25.2"
   :group 'message-headers
   :link '(custom-manual "(message)IDNA")
   :type '(choice (const :tag "Ask" ask)
@@ -1918,12 +1890,7 @@ You must have the \"hashcash\" binary installed, see `hashcash-path'."
 
 (defvar        message-options nil
   "Some saved answers when sending message.")
-;; FIXME: On XEmacs this causes problems since let-binding like:
-;; (let ((message-options message-options)) ...)
-;; as in `message-send' and `mml-preview' loses to buffer-local
-;; variable initialization.
-(unless (featurep 'xemacs)
-  (make-variable-buffer-local 'message-options))
+(make-variable-buffer-local 'message-options)
 
 (defvar message-send-mail-real-function nil
   "Internal send mail function.")
@@ -1939,14 +1906,11 @@ You must have the \"hashcash\" binary installed, see `hashcash-path'."
 (autoload 'gnus-group-name-charset "gnus-group")
 (autoload 'gnus-group-name-decode "gnus-group")
 (autoload 'gnus-groups-from-server "gnus")
-(autoload 'gnus-make-local-hook "gnus-util")
 (autoload 'gnus-open-server "gnus-int")
 (autoload 'gnus-output-to-mail "gnus-util")
 (autoload 'gnus-output-to-rmail "gnus-util")
 (autoload 'gnus-request-post "gnus-int")
-(autoload 'gnus-select-frame-set-input-focus "gnus-util")
 (autoload 'gnus-server-string "gnus")
-(autoload 'idna-to-ascii "idna")
 (autoload 'message-setup-toolbar "messagexmas")
 (autoload 'mh-new-draft-name "mh-comp")
 (autoload 'mh-send-letter "mh-comp")
@@ -1956,20 +1920,8 @@ You must have the \"hashcash\" binary installed, see `hashcash-path'."
 (autoload 'rmail-msg-is-pruned "rmail")
 (autoload 'rmail-output "rmailout")
 
-;; Emacs < 24.1 do not have mail-dont-reply-to
-(unless (fboundp 'mail-dont-reply-to)
-  (defalias 'mail-dont-reply-to 'rmail-dont-reply-to))
-
-(eval-and-compile
-  (if (featurep 'emacs)
-      (progn
-       (defun message-kill-all-overlays ()
-         (mapcar #'delete-overlay (overlays-in (point-min) (point-max))))
-       (defalias 'message-window-inside-pixel-edges
-         'window-inside-pixel-edges))
-    (defun message-kill-all-overlays ()
-      (map-extents (lambda (extent ignore) (delete-extent extent))))
-    (defalias 'message-window-inside-pixel-edges 'ignore)))
+(defun message-kill-all-overlays ()
+  (mapcar #'delete-overlay (overlays-in (point-min) (point-max))))
 
 \f
 
@@ -2189,8 +2141,8 @@ contains a valid encoded word.  Decode again? "
          ;; No double encoded subject? => bogus charset.
          (unless cs-coding
            (setq cs-coding
-                 (mm-read-coding-system
-                  (gnus-format-message "\
+                 (read-coding-system
+                  (format-message "\
 Decoded Subject \"%s\"
 contains an encoded word.  The charset `%s' is unknown or invalid.
 Hit RET to replace non-decodable characters with \"%s\" or enter replacement
@@ -2228,33 +2180,26 @@ charset: "
   "Remove trailing \"(was: <old subject>)\" from SUBJECT lines.
 Leading \"Re: \" is not stripped by this function.  Use the function
 `message-strip-subject-re' for this."
-  (let* ((query message-subject-trailing-was-query)
-        (new) (found))
-    (setq found
-         (string-match
-          (if (eq query 'ask)
-              message-subject-trailing-was-ask-regexp
-            message-subject-trailing-was-regexp)
-          subject))
-    (if found
-       (setq new (substring subject 0 (match-beginning 0))))
-    (if (or (not found) (eq query nil))
-       subject
-      (if (eq query 'ask)
-         (if (message-y-or-n-p
-              "Strip `(was: <old subject>)' in subject? " t
-              (concat
-               "Strip `(was: <old subject>)' in subject "
-               "and use the new one instead?\n\n"
-               "Current subject is:   \""
-               subject "\"\n\n"
-               "New subject would be: \""
-               new "\"\n\n"
-               "See the variable `message-subject-trailing-was-query' "
-               "to get rid of this query."
-               ))
-             new subject)
-       new))))
+  (or
+   (let ((query message-subject-trailing-was-query) new)
+     (and query
+          (string-match (if (eq query 'ask)
+                            message-subject-trailing-was-ask-regexp
+                          message-subject-trailing-was-regexp)
+                        subject)
+          (setq new (substring subject 0 (match-beginning 0)))
+          (or (not (eq query 'ask))
+              (message-y-or-n-p
+               "Strip `(was: <old subject>)' in subject? " t
+               (concat
+                "Strip `(was: <old subject>)' in subject "
+                "and use the new one instead?\n\n"
+                "Current subject is:   \"" subject "\"\n\n"
+                "New subject would be: \"" new "\"\n\n"
+                "See the variable `message-subject-trailing-was-query' "
+                "to get rid of this query.")))
+          new))
+   subject))
 
 ;;; Suggested by Jonas Steverud  @  www.dtek.chalmers.se/~d4jonas/
 
@@ -2418,6 +2363,8 @@ With prefix-argument just set Follow-Up, don't cross-post."
                     nil nil '("poster" . 0)
                     (if (boundp 'gnus-group-history)
                         'gnus-group-history))))
+  (when (fboundp 'gnus-group-real-name)
+    (setq target-group (gnus-group-real-name target-group)))
   (cond ((not (or (null target-group) ; new subject not empty
                  (zerop (string-width target-group))
                  (string-match "^[ \t]*$" target-group)))
@@ -2651,19 +2598,16 @@ Prefixed with one \\[universal-argument], display the Emacs MIME
 manual.  With two \\[universal-argument]'s, display the EasyPG or
 PGG manual, depending on the value of `mml2015-use'."
   (interactive "p")
-  ;; Don't use `info' because support for `(filename)nodename' is not
-  ;; available in XEmacs < 21.5.12.
-  (Info-goto-node (format "(%s)Top"
-                         (cond ((eq arg 16)
-                                (require 'mml2015)
-                                mml2015-use)
-                               ((eq arg  4) 'emacs-mime)
-                               ;; `booleanp' only available in Emacs 22+
-                               ((and (not (memq arg '(nil t)))
-                                     (symbolp arg))
-                                arg)
-                               (t
-                                'message)))))
+  (info (format "(%s)Top"
+               (cond ((eq arg 16)
+                      (require 'mml2015)
+                      mml2015-use)
+                     ((eq arg  4) 'emacs-mime)
+                     ((and (not (booleanp arg))
+                           (symbolp arg))
+                      arg)
+                     (t
+                      'message)))))
 
 \f
 
@@ -2761,43 +2705,29 @@ PGG manual, depending on the value of `mml2015-use'."
     ["Caesar (rot13) Region" message-caesar-region (message-mark-active-p)]
     ["Elide Region" message-elide-region
      :active (message-mark-active-p)
-     ,@(if (featurep 'xemacs) nil
-        '(:help "Replace text in region with an ellipsis"))]
+     :help "Replace text in region with an ellipsis"]
     ["Delete Outside Region" message-delete-not-region
      :active (message-mark-active-p)
-     ,@(if (featurep 'xemacs) nil
-        '(:help "Delete all quoted text outside region"))]
+     :help "Delete all quoted text outside region"]
     ["Kill To Signature" message-kill-to-signature t]
     ["Newline and Reformat" message-newline-and-reformat t]
     ["Rename buffer" message-rename-buffer t]
-    ["Spellcheck" ispell-message
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Spellcheck this message"))]
+    ["Spellcheck" ispell-message :help "Spellcheck this message"]
     "----"
     ["Insert Region Marked" message-mark-inserted-region
-     :active (message-mark-active-p)
-     ,@(if (featurep 'xemacs) nil
-        '(:help "Mark region with enclosing tags"))]
+     :active (message-mark-active-p) :help "Mark region with enclosing tags"]
     ["Insert File Marked..." message-mark-insert-file
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Insert file at point marked with enclosing tags"))]
+     :help "Insert file at point marked with enclosing tags"]
     "----"
-    ["Send Message" message-send-and-exit
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Send this message"))]
+    ["Send Message" message-send-and-exit :help "Send this message"]
     ["Postpone Message" message-dont-send
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "File this draft message and exit"))]
+     :help "File this draft message and exit"]
     ["Send at Specific Time..." gnus-delay-article
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Ask, then arrange to send message at that time"))]
+     :help "Ask, then arrange to send message at that time"]
     ["Kill Message" message-kill-buffer
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Delete this message without sending"))]
+     :help "Delete this message without sending"]
     "----"
-    ["Message manual" message-info
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Display the Message manual"))]))
+    ["Message manual" message-info :help "Display the Message manual"]))
 
 (easy-menu-define
   message-mode-field-menu message-mode-map ""
@@ -2811,15 +2741,12 @@ PGG manual, depending on the value of `mml2015-use'."
     ["Fcc" message-goto-fcc t]
     ["Reply-To" message-goto-reply-to t]
     ["Flag As Important" message-insert-importance-high
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Mark this message as important"))]
+     :help "Mark this message as important"]
     ["Flag As Unimportant" message-insert-importance-low
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Mark this message as unimportant"))]
+     :help "Mark this message as unimportant"]
     ["Request Receipt"
      message-insert-disposition-notification-to
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Request a receipt notification"))]
+     :help "Request a receipt notification"]
     "----"
     ;; (typical) news stuff
     ["Summary" message-goto-summary t]
@@ -2835,18 +2762,14 @@ PGG manual, depending on the value of `mml2015-use'."
     "----"
     ;; (typical) mailing-lists stuff
     ["Fetch To" message-insert-to
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Insert a To header that points to the author."))]
+     :help "Insert a To header that points to the author."]
     ["Fetch To and Cc" message-insert-wide-reply
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help
-          "Insert To and Cc headers as if you were doing a wide reply."))]
+     :help "Insert To and Cc headers as if you were doing a wide reply."]
     "----"
     ["Send to list only" message-to-list-only t]
     ["Mail-Followup-To" message-goto-mail-followup-to t]
     ["Unsubscribed list post" message-generate-unsubscribed-mail-followup-to
-     ,@(if (featurep 'xemacs) '(t)
-        '(:help "Insert a reasonable `Mail-Followup-To:' header."))]
+     :help "Insert a reasonable `Mail-Followup-To:' header."]
     ["Reduce To: to Cc:" message-reduce-to-to-cc t]
     "----"
     ["Sort Headers" message-sort-headers t]
@@ -2892,7 +2815,6 @@ message composition doesn't break too bad."
   ;; category, face, display: probably doesn't do any harm.
   ;; fontified: is used by font-lock.
   ;; syntax-table, local-map: I dunno.
-  ;; We need to add XEmacs names to the list.
   "Property list of with properties forbidden in message buffers.
 The values of the properties are ignored, only the property names are used.")
 
@@ -2928,8 +2850,6 @@ See also `message-forbidden-properties'."
          (inhibit-read-only t))
       (remove-text-properties begin end message-forbidden-properties))))
 
-(autoload 'ecomplete-setup "ecomplete") ;; for Emacs <23.
-
 (defvar message-smileys '(":-)" ":)"
                           ":-(" ":("
                           ";-)" ";)")
@@ -3027,25 +2947,19 @@ M-RET    `message-newline-and-reformat' (break the line and reformat)."
     (set (make-local-variable 'comment-start) message-yank-prefix)
     (set (make-local-variable 'comment-start-skip)
         (concat "^" (regexp-quote message-yank-prefix) "[ \t]*")))
-  (if (featurep 'xemacs)
-      (message-setup-toolbar)
-    (set (make-local-variable 'font-lock-defaults)
-        '(message-font-lock-keywords t))
-    (if (boundp 'tool-bar-map)
-       (set (make-local-variable 'tool-bar-map) (message-make-tool-bar))))
+  (set (make-local-variable 'font-lock-defaults)
+       '(message-font-lock-keywords t))
+  (if (boundp 'tool-bar-map)
+      (set (make-local-variable 'tool-bar-map) (message-make-tool-bar)))
   (easy-menu-add message-mode-menu message-mode-map)
   (easy-menu-add message-mode-field-menu message-mode-map)
-  (gnus-make-local-hook 'after-change-functions)
   ;; Mmmm... Forbidden properties...
   (add-hook 'after-change-functions 'message-strip-forbidden-properties
            nil 'local)
   ;; Allow mail alias things.
   (cond
    ((message-mail-alias-type-p 'abbrev)
-    (if (fboundp 'mail-abbrevs-setup)
-       (mail-abbrevs-setup)
-      (if (fboundp 'mail-aliases-setup)        ; warning avoidance
-         (mail-aliases-setup))))
+    (mail-abbrevs-setup))
    ((message-mail-alias-type-p 'ecomplete)
     (ecomplete-setup)))
   (add-hook 'completion-at-point-functions 'message-completion-function nil t)
@@ -3071,8 +2985,6 @@ M-RET    `message-newline-and-reformat' (break the line and reformat)."
   (make-local-variable 'paragraph-separate)
   (make-local-variable 'paragraph-start)
   (make-local-variable 'adaptive-fill-regexp)
-  (unless (boundp 'adaptive-fill-first-line-regexp)
-    (setq adaptive-fill-first-line-regexp nil))
   (make-local-variable 'adaptive-fill-first-line-regexp)
   (let ((quote-prefix-regexp
         ;; User should change message-cite-prefix-regexp if
@@ -3095,20 +3007,8 @@ M-RET    `message-newline-and-reformat' (break the line and reformat)."
     (setq adaptive-fill-first-line-regexp
          (concat quote-prefix-regexp "\\|"
                  adaptive-fill-first-line-regexp)))
-  (make-local-variable 'auto-fill-inhibit-regexp)
-  ;;(setq auto-fill-inhibit-regexp "^[A-Z][^: \n\t]+:")
-  (setq auto-fill-inhibit-regexp nil)
-  (make-local-variable 'normal-auto-fill-function)
-  (setq normal-auto-fill-function 'message-do-auto-fill)
-  ;; KLUDGE: auto fill might already be turned on in `text-mode-hook'.
-  ;; In that case, ensure that it uses the right function.  The real
-  ;; solution would be not to use `define-derived-mode', and run
-  ;; `text-mode-hook' ourself at the end of the mode.
-  ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-19.
-  ;; This kludge is unneeded in Emacs>=21 since define-derived-mode is
-  ;; now careful to run parent hooks after the body.  --Stef
-  (when auto-fill-function
-    (setq auto-fill-function normal-auto-fill-function)))
+  (setq-local auto-fill-inhibit-regexp nil)
+  (setq-local normal-auto-fill-function 'message-do-auto-fill))
 
 \f
 
@@ -3199,7 +3099,7 @@ M-RET    `message-newline-and-reformat' (break the line and reformat)."
 (defun message-goto-body ()
   "Move point to the beginning of the message body."
   (interactive)
-  (when (and (gmm-called-interactively-p 'any)
+  (when (and (called-interactively-p 'any)
             (looking-at "[ \t]*\n"))
     (expand-abbrev))
   (push-mark)
@@ -3514,12 +3414,10 @@ Prefix arg means justify as well."
 This function is used as the value of `fill-paragraph-function' in
 Message buffers and is not meant to be called directly."
   (interactive (list (if current-prefix-arg 'full)))
-  (if (if (boundp 'filladapt-mode) filladapt-mode)
-      nil
-    (if (message-point-in-header-p)
-       (message-fill-field)
-      (message-newline-and-reformat arg t))
-    t))
+  (if (message-point-in-header-p)
+      (message-fill-field)
+    (message-newline-and-reformat arg t))
+  t)
 
 (defun message-point-in-header-p ()
   "Return t if point is in the header."
@@ -3803,15 +3701,11 @@ If REMOVE is non-nil, remove newlines, too.
 To use this automatically, you may add this function to
 `gnus-message-setup-hook'."
   (interactive "P")
-  (let ((citexp
-        (concat
-         "^\\("
-         (when (boundp 'message-yank-cited-prefix)
-           (concat message-yank-cited-prefix "\\|"))
-         message-yank-prefix
-         "\\)+ *\n"
-         )))
-    (gnus-message 8 "removing `%s'" citexp)
+  (let ((citexp (concat "^\\("
+                       (concat message-yank-cited-prefix "\\|")
+                       message-yank-prefix
+                       "\\)+ *\n")))
+    (message "Removing `%s'" citexp)
     (save-excursion
       (message-goto-body)
       (while (re-search-forward citexp nil t)
@@ -3969,8 +3863,13 @@ This function uses `mail-citation-hook' if that is non-nil."
 (defun message-insert-formatted-citation-line (&optional from date tz)
   "Function that inserts a formatted citation line.
 The optional FROM, and DATE are strings containing the contents of
-the From header and the Date header respectively.  The optional TZ
-is a number of seconds, overrides the time zone of DATE.
+the From header and the Date header respectively.
+
+The optional TZ is omitted or nil for Emacs local time, t for
+Universal Time, `wall' for system wall clock time, or a string as
+in the TZ environment variable.  It can also be a list (as from
+`current-time-zone') or an integer (as from `decode-time')
+applied without consideration for daylight saving time.
 
 See `message-citation-line-format'."
   ;; The optional args are for testing/debugging.  They will disappear later.
@@ -4061,7 +3960,7 @@ See `message-citation-line-format'."
                               (>= i ?a)))
                  (push i lst)
                  (push (condition-case nil
-                           (gmm-format-time-string (format "%%%c" i) time tz)
+                           (format-time-string (format "%%%c" i) time tz)
                          (error (format ">%c<" i)))
                        lst))
                (setq i (1+ i)))
@@ -4232,7 +4131,7 @@ It should typically alter the sending method in some way or other."
                    (or (eq message-allow-no-recipients 'always)
                        (and (not (eq message-allow-no-recipients 'never))
                             (setq dont-barf-on-no-method
-                                  (gnus-y-or-n-p
+                                  (y-or-n-p
                                    (format "No receiver, perform %s anyway? "
                                            (cond ((and fcc gcc) "Fcc and Gcc")
                                                  (fcc "Fcc")
@@ -4366,7 +4265,7 @@ conformance."
                                 (point) 'no-illegible-text)
                                (point-max))))
               (setq char (char-after)))
-       (when (or (< (mm-char-int char) 128)
+       (when (or (< char 128)
                  (and (mm-multibyte-p)
                       (memq (char-charset char)
                             '(eight-bit-control eight-bit-graphic
@@ -4380,23 +4279,25 @@ conformance."
        (forward-char))
       (when found
        (setq choice
-             (gnus-multiple-choice
-              (if nul-chars
-                  "NUL characters found, which may cause problems.  Continue sending?"
-                "Non-printable characters found.  Continue sending?")
-              `((?d "Remove non-printable characters and send")
-                (?r ,(format
-                      "Replace non-printable characters with \"%s\" and send"
-                      message-replacement-char))
-                (?s "Send as is without removing anything")
-                (?e "Continue editing"))))
+             (car
+              (read-multiple-choice
+               (if nul-chars
+                   "NUL characters found, which may cause problems.  Continue sending?"
+                 "Non-printable characters found.  Continue sending?")
+               `((?d "delete" "Remove non-printable characters and send")
+                 (?r "replace"
+                     ,(format
+                       "Replace non-printable characters with \"%s\" and send"
+                       message-replacement-char))
+                 (?s "send" "Send as is without removing anything")
+                 (?e "edit" "Continue editing")))))
        (if (eq choice ?e)
          (error "Non-printable characters"))
        (message-goto-body)
        (skip-chars-forward mm-7bit-chars)
        (while (not (eobp))
          (when (let ((char (char-after)))
-                 (or (< (mm-char-int char) 128)
+                 (or (< char 128)
                      (and (mm-multibyte-p)
                           ;; FIXME: Wrong for Emacs 23 (unicode) and for
                           ;; things like undecodable utf-8 (in Emacs 21?).
@@ -4460,7 +4361,7 @@ This function could be useful in `message-setup-hook'."
          (dolist (bog (message-bogus-recipient-p addr))
            (and bog
                 (not (y-or-n-p
-                      (gnus-format-message
+                      (format-message
                        "Address `%s'%s might be bogus.  Continue? "
                        bog
                        ;; If the encoded version of the email address
@@ -5393,7 +5294,7 @@ Otherwise, generate and save a value for `canlock-password' first."
    ;; Check for control characters.
    (message-check 'control-chars
      (if (re-search-forward
-         (mm-string-to-multibyte "[\000-\007\013\015-\032\034-\037\200-\237]")
+         (string-to-multibyte "[\000-\007\013\015-\032\034-\037\200-\237]")
          nil t)
         (y-or-n-p
          "The article contains control characters.  Really post? ")
@@ -5759,10 +5660,7 @@ In posting styles use `(\"Expires\" (make-expires-date 30))'."
   "Make a From header."
   (let* ((style message-from-style)
         (login (or address (message-make-address)))
-        (fullname (or name
-                      (and (boundp 'user-full-name)
-                           user-full-name)
-                      (user-full-name))))
+        (fullname (or name user-full-name (user-full-name))))
     (when (string= fullname "&")
       (setq fullname (user-login-name)))
     (with-temp-buffer
@@ -5862,8 +5760,7 @@ give as trustworthy answer as possible."
       ;; `system-name' returned the right result.
       sysname)
      ;; Try `mail-host-address'.
-     ((and (boundp 'mail-host-address)
-          (stringp mail-host-address)
+     ((and (stringp mail-host-address)
           (not (string-match message-bogus-system-names mail-host-address)))
       mail-host-address)
      ;; We try `user-mail-address' as a backup.
@@ -5942,7 +5839,7 @@ subscribed address (and not the additional To and Cc header contents)."
         ace)
     (when field
       (dolist (rhs
-              (mm-delete-duplicates
+              (delete-dups
                (mapcar (lambda (rhs) (or (cadr (split-string rhs "@")) ""))
                        (mapcar 'downcase
                                (mapcar
@@ -5954,7 +5851,7 @@ subscribed address (and not the additional To and Cc header contents)."
        ;; the domain part, i.e., if it is a local user's address.
        (setq ace (if (string-match "\\`[[:ascii:]]*\\'" rhs)
                      rhs
-                   (downcase (idna-to-ascii rhs))))
+                   (downcase (puny-encode-domain rhs))))
        (when (and (not (equal rhs ace))
                   (or (not (eq message-use-idna 'ask))
                       (y-or-n-p (format "Replace %s with %s in %s:? "
@@ -5988,41 +5885,27 @@ See `message-idna-encode'."
        (message-idna-to-ascii-rhs-1 "Mail-Followup-To")
        (message-idna-to-ascii-rhs-1 "Cc")))))
 
-(defvar Date)
-(defvar Message-ID)
-(defvar Organization)
-(defvar From)
-(defvar Path)
-(defvar Subject)
-(defvar Newsgroups)
-(defvar In-Reply-To)
-(defvar References)
-(defvar To)
-(defvar Distribution)
-(defvar Lines)
-(defvar User-Agent)
-(defvar Expires)
-
 (defun message-generate-headers (headers)
   "Prepare article HEADERS.
 Headers already prepared in the buffer are not modified."
   (setq headers (append headers message-required-headers))
   (save-restriction
     (message-narrow-to-headers)
-    (let* ((Date (message-make-date))
-          (Message-ID (message-make-message-id))
-          (Organization (message-make-organization))
-          (From (message-make-from))
-          (Path (message-make-path))
-          (Subject nil)
-          (Newsgroups nil)
-          (In-Reply-To (message-make-in-reply-to))
-          (References (message-make-references))
-          (To nil)
-          (Distribution (message-make-distribution))
-          (Lines (message-make-lines))
-          (User-Agent message-newsreader)
-          (Expires (message-make-expires))
+    (let* ((header-values
+           (list 'Date (message-make-date)
+                 'Message-ID (message-make-message-id)
+                 'Organization (message-make-organization)
+                 'From (message-make-from)
+                 'Path (message-make-path)
+                 'Subject nil
+                 'Newsgroups nil
+                 'In-Reply-To (message-make-in-reply-to)
+                 'References (message-make-references)
+                 'To nil
+                 'Distribution (message-make-distribution)
+                 'Lines (message-make-lines)
+                 'User-Agent message-newsreader
+                 'Expires (message-make-expires)))
           (case-fold-search t)
           (optionalp nil)
           header value elem header-string)
@@ -6076,8 +5959,8 @@ Headers already prepared in the buffer are not modified."
                  (setq header (cdr elem))
                  (or (and (functionp (cdr elem))
                           (funcall (cdr elem)))
-                     (and (boundp (cdr elem))
-                          (symbol-value (cdr elem)))))
+                     (and (symbolp (cdr elem))
+                          (plist-get header-values (cdr elem)))))
                 ((consp elem)
                  ;; The element is a cons.  Either the cdr is a
                  ;; string to be inserted verbatim, or it is a
@@ -6087,11 +5970,11 @@ Headers already prepared in the buffer are not modified."
                           (cdr elem))
                      (and (functionp (cdr elem))
                           (funcall (cdr elem)))))
-                ((and (boundp header)
-                      (symbol-value header))
-                 ;; The element is a symbol.  We insert the value
-                 ;; of this symbol, if any.
-                 (symbol-value header))
+                ((and (symbolp header)
+                      (plist-member header-values header))
+                 ;; The element is a symbol.  We insert the value of
+                 ;; this symbol, if any.
+                 (plist-get header-values header))
                 ((not (message-check-element
                        (intern (downcase (symbol-name header)))))
                  ;; We couldn't generate a value for this header,
@@ -6203,10 +6086,7 @@ Headers already prepared in the buffer are not modified."
   "Split current line, moving portion beyond point vertically down.
 If the current line has `message-yank-prefix', insert it on the new line."
   (interactive "*")
-  (condition-case nil
-      (split-line message-yank-prefix) ;; Emacs 22.1+ supports arg.
-    (error
-     (split-line))))
+  (split-line message-yank-prefix))
 
 (defun message-insert-header (header value)
   (insert (capitalize (symbol-name header))
@@ -6404,19 +6284,15 @@ multiple lines is treated as a single line.  Otherwise, even if
 N is 1, when point is on a continuation header line, it will be
 moved to the beginning "
   (interactive "p")
-  (let ((zrs 'zmacs-region-stays))
-    (when (and (featurep 'xemacs) (interactive-p) (boundp zrs))
-      (set zrs t)))
   (cond
    ;; Go to beginning of header or beginning of line.
    ((and message-beginning-of-line (message-point-in-header-p))
     (let* ((point (point))
            (bol (progn (beginning-of-line n) (point)))
-           (boh (message-beginning-of-header (and (boundp 'visual-line-mode)
-                                                  visual-line-mode))))
+           (boh (message-beginning-of-header visual-line-mode)))
       (goto-char (if (and boh (or (< boh point) (= bol point))) boh bol))))
    ;; Go to beginning of visual line
-   ((and (boundp 'visual-line-mode) visual-line-mode)
+   (visual-line-mode
     (beginning-of-visual-line n))
    ;; Go to beginning of line.
    ((beginning-of-line n))))
@@ -6486,7 +6362,7 @@ moved to the beginning "
          (if window
              ;; Raise the frame already displaying the message buffer.
              (progn
-               (gnus-select-frame-set-input-focus (window-frame window))
+               (select-frame-set-input-focus (window-frame window))
                (select-window window))
            (funcall (or switch-function #'pop-to-buffer) buffer)
            (set-buffer buffer))
@@ -6496,10 +6372,7 @@ moved to the beginning "
                               "Message already being composed; erase? ")
                            (message nil))))
            (error "Message being composed")))
-      (funcall (or switch-function
-                  (if (fboundp #'pop-to-buffer-same-window)
-                      #'pop-to-buffer-same-window
-                    #'pop-to-buffer))
+      (funcall (or switch-function 'pop-to-buffer-same-window)
               name)
       (set-buffer name))
     (erase-buffer)
@@ -7331,7 +7204,7 @@ header line with the old Message-ID."
     (cond ((save-window-excursion
             (with-output-to-temp-buffer "*Directory*"
               (with-current-buffer standard-output
-                (fundamental-mode))    ; for Emacs 20.4+
+                (fundamental-mode))
               (buffer-disable-undo standard-output)
               (let ((default-directory "/"))
                 (call-process
@@ -7477,14 +7350,13 @@ Optional DIGEST will use digest to forward."
   (let ((b (point))
        (contents (with-current-buffer forward-buffer (buffer-string)))
        e)
-    (unless (featurep 'xemacs)
-      (unless (mm-multibyte-string-p contents)
-       (error "Attempt to insert unibyte string from the buffer \"%s\"\
+    (unless (multibyte-string-p contents)
+      (error "Attempt to insert unibyte string from the buffer \"%s\"\
  to the multibyte buffer \"%s\""
-              (if (bufferp forward-buffer)
-                  (buffer-name forward-buffer)
-                forward-buffer)
-              (buffer-name))))
+            (if (bufferp forward-buffer)
+                (buffer-name forward-buffer)
+              forward-buffer)
+            (buffer-name)))
     (insert (mm-with-multibyte-buffer
              (insert contents)
              (mime-to-mml)
@@ -7541,14 +7413,13 @@ Optional DIGEST will use digest to forward."
   (let ((b (point)) e)
     (if (not message-forward-decoded-p)
        (let ((contents (with-current-buffer forward-buffer (buffer-string))))
-         (unless (featurep 'xemacs)
-           (unless (mm-multibyte-string-p contents)
-             (error "Attempt to insert unibyte string from the buffer \"%s\"\
+         (unless (multibyte-string-p contents)
+           (error "Attempt to insert unibyte string from the buffer \"%s\"\
  to the multibyte buffer \"%s\""
-                    (if (bufferp forward-buffer)
-                        (buffer-name forward-buffer)
-                      forward-buffer)
-                    (buffer-name))))
+                  (if (bufferp forward-buffer)
+                      (buffer-name forward-buffer)
+                    forward-buffer)
+                  (buffer-name)))
          (insert (mm-with-multibyte-buffer
                    (insert contents)
                    (mime-to-mml)
@@ -7680,10 +7551,8 @@ is for the internal use."
 (defun message-forward-rmail-make-body (forward-buffer)
   (save-window-excursion
     (set-buffer forward-buffer)
-    (if (rmail-msg-is-pruned)
-       (if (fboundp 'rmail-msg-restore-non-pruned-header)
-           (rmail-msg-restore-non-pruned-header) ; Emacs 22
-         (rmail-toggle-header 0))))              ; Emacs 23
+    (when (rmail-msg-is-pruned)
+      (rmail-toggle-header 0)))
   (message-forward-make-body forward-buffer))
 
 ;; Fixme: Should have defcustom.
@@ -7757,6 +7626,9 @@ is for the internal use."
             (let ((case-fold-search t))
               (re-search-forward "^mime-version:" nil t)))
            (message-inhibit-ecomplete t)
+           ;; We don't want smtpmail.el to encode anything, either.
+           (sendmail-coding-system 'raw-text)
+           (select-safe-coding-system-function nil)
            message-required-mail-headers
            message-generate-hashcash
            rfc2047-encode-encoded-words)
@@ -7933,12 +7805,10 @@ Pre-defined symbols include `message-tool-bar-gnome' and
 (defcustom message-tool-bar-gnome
   '((ispell-message "spell" nil
                    :vert-only t
-                   :visible (or (not (boundp 'flyspell-mode))
-                                (not flyspell-mode)))
+                   :visible (not flyspell-mode))
     (flyspell-buffer "spell" t
                     :vert-only t
-                    :visible (and (boundp 'flyspell-mode)
-                                  flyspell-mode)
+                    :visible flyspell-mode
                     :help "Flyspell whole buffer")
     (message-send-and-exit "mail/send" t :label "Send")
     (message-dont-send "mail/save-draft")
@@ -7995,18 +7865,14 @@ See `gmm-tool-bar-from-list' for the format of the list."
 (defun message-make-tool-bar (&optional force)
   "Make a message mode tool bar from `message-tool-bar-list'.
 When FORCE, rebuild the tool bar."
-  (when (and (not (featurep 'xemacs))
-            (boundp 'tool-bar-mode)
+  (when (and (boundp 'tool-bar-mode)
             tool-bar-mode
             (or (not message-tool-bar-map) force))
     (setq message-tool-bar-map
          (let* ((load-path
-                 (gmm-image-load-path-for-library "message"
-                                                  "mail/save-draft.xpm"
-                                                  nil t))
-                (image-load-path (cons (car load-path)
-                                       (when (boundp 'image-load-path)
-                                         image-load-path))))
+                 (image-load-path-for-library
+                  "message" "mail/save-draft.xpm" nil t))
+                (image-load-path (cons (car load-path) image-load-path)))
            (gmm-tool-bar-from-list message-tool-bar
                                    message-tool-bar-zap-list
                                    'message-mode-map))))
@@ -8057,10 +7923,8 @@ not in those headers.  If that variable is nil, indent with the
 regular text mode tabbing command."
   (interactive)
   (cond
-   ((if (and (boundp 'completion-fail-discreetly)
-             (fboundp 'completion-at-point))
-        (let ((completion-fail-discreetly t)) (completion-at-point))
-      (funcall (or (message-completion-function) #'ignore)))
+   ((let ((completion-fail-discreetly t))
+      (completion-at-point))
     ;; Completion was performed; nothing else to do.
     nil)
    (message-tab-body-function (funcall message-tab-body-function))
@@ -8106,41 +7970,7 @@ regular text mode tabbing command."
                 group)
               collection))
        gnus-active-hashtb))
-    (message-completion-in-region b e collection)))
-
-(defalias 'message-completion-in-region
-  (if (fboundp 'completion-in-region)
-      'completion-in-region
-    (lambda (b e hashtb)
-      (let* ((string (buffer-substring b e))
-             (completions (all-completions string hashtb))
-             comp)
-        (delete-region b (point))
-        (cond
-         ((= (length completions) 1)
-          (if (string= (car completions) string)
-              (progn
-                (insert string)
-                (message "Only matching group"))
-            (insert (car completions))))
-         ((and (setq comp (try-completion string hashtb))
-               (not (string= comp string)))
-          (insert comp))
-         (t
-          (insert string)
-          (if (not comp)
-              (message "No matching groups")
-            (save-selected-window
-              (pop-to-buffer "*Completions*")
-              (buffer-disable-undo)
-              (let ((buffer-read-only nil))
-                (erase-buffer)
-                (let ((standard-output (current-buffer)))
-                  (display-completion-list (sort completions 'string<)))
-                (setq buffer-read-only nil)
-                (goto-char (point-min))
-                (delete-region (point)
-                               (progn (forward-line 3) (point))))))))))))
+    (completion-in-region b e collection)))
 
 (defun message-expand-name ()
   (cond ((and (memq 'eudc message-expand-name-databases)
@@ -8169,7 +7999,7 @@ The following arguments may contain lists of values."
       (save-window-excursion
         (with-output-to-temp-buffer " *MESSAGE information message*"
           (with-current-buffer " *MESSAGE information message*"
-           (fundamental-mode)          ; for Emacs 20.4+
+           (fundamental-mode)
            (mapc 'princ text)
            (goto-char (point-min))))
        (funcall ask question))
@@ -8262,13 +8092,9 @@ regexp VARSTR."
 
 (defun message-read-from-minibuffer (prompt &optional initial-contents)
   "Read from the minibuffer while providing abbrev expansion."
-  (if (fboundp 'mail-abbrevs-setup)
-      (let ((minibuffer-setup-hook 'mail-abbrevs-setup)
-           (minibuffer-local-map message-minibuffer-local-map))
-       (read-from-minibuffer prompt initial-contents))
-    (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook)
-         (minibuffer-local-map message-minibuffer-local-map))
-      (read-string prompt initial-contents))))
+  (let ((minibuffer-setup-hook 'mail-abbrevs-setup)
+       (minibuffer-local-map message-minibuffer-local-map))
+    (read-from-minibuffer prompt initial-contents)))
 
 (defun message-use-alternative-email-as-from ()
   "Set From field of the outgoing message to the first matching
@@ -8371,8 +8197,9 @@ From headers in the original article."
     (let ((value (message-field-value header)))
       (dolist (string (mail-header-parse-addresses value 'raw))
        (setq string
-             (gnus-replace-in-string
-              (gnus-replace-in-string string "^ +\\| +$" "") "\n" ""))
+             (replace-regexp-in-string
+              "\n" ""
+              (replace-regexp-in-string "^ +\\| +$" "" string)))
        (ecomplete-add-item 'mail (car (mail-header-parse-address string))
                            string))))
   (ecomplete-save))
@@ -8483,7 +8310,7 @@ Header and body are separated by `mail-header-separator'."
        (when force
          (sit-for message-send-form-letter-delay))
        (if (or force
-                 (y-or-n-p (gnus-format-message "Send message to `%s'? " to)))
+                 (y-or-n-p (format-message "Send message to `%s'? " to)))
            (progn
              (setq sent (1+ sent))
              (message-send-and-exit))
@@ -8572,7 +8399,7 @@ Used in `message-simplify-recipients'."
        (goto-char (point-min))
        (while (re-search-forward "<img.*src=\"\\([^\"]+\\)" nil t)
          (let ((file (match-string 1))
-               (edges (message-window-inside-pixel-edges
+               (edges (window-inside-pixel-edges
                        (get-buffer-window (current-buffer)))))
            (put-image
             (create-image
@@ -8584,10 +8411,6 @@ Used in `message-simplify-recipients'."
             (match-beginning 0)
             " ")))))))
 
-(when (featurep 'xemacs)
-  (require 'messagexmas)
-  (message-xmas-redefine))
-
 (provide 'message)
 
 (run-hooks 'message-load-hook)