Remove unnecessary `require'ments. Defvar gnus-list-identifiers when
authorDave Love <fx@gnu.org>
Sun, 25 Jun 2000 17:19:10 +0000 (17:19 +0000)
committerDave Love <fx@gnu.org>
Sun, 25 Jun 2000 17:19:10 +0000 (17:19 +0000)
compiling.  Don't try to autoload variable `gnus-list-identifiers'.
Autoload gnus-group-name-charset.
(message-fetch-field): Don't assume `format' removes text properties.
(message-strip-list-identifiers, message-reply, message-followup):
Require gnus-sum.
(message-mode): Tidy XEmacs conditionals.
(message-replace-chars-in-string): Use subst-char-in-string when
available.

lisp/message.el

index 41777b6..1c7f5ff 100644 (file)
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl)
+  (defvar gnus-list-identifiers))      ; gnus-sum is required where necessary
 (require 'mailheader)
 (require 'nnheader)
-(require 'easymenu)
-(if (string-match "XEmacs\\|Lucid" emacs-version)
-    (require 'mail-abbrevs)
-  (require 'mailabbrev))
 (require 'mail-parse)
-(require 'mm-bodies)
-(require 'mm-encode)
 (require 'mml)
 
 (defgroup message '((user-mail-address custom-variable)
@@ -1014,7 +1010,7 @@ should be sent in several parts. If it is nil, the size is unlimited."
   (autoload 'gnus-open-server "gnus-int")
   (autoload 'gnus-request-post "gnus-int")
   (autoload 'gnus-alive-p "gnus-util")
-  (autoload 'gnus-list-identifiers "gnus-sum")
+  (autoload 'gnus-group-name-charset "gnus-group")
   (autoload 'rmail-output "rmail"))
 
 \f
@@ -1094,8 +1090,8 @@ is used by default."
     (when value
       (while (string-match "\n[\t ]+" value)
        (setq value (replace-match " " t t value)))
-      ;; We remove all text props.
-      (format "%s" value))))
+      (set-text-properties 0 (length value) nil value)
+      value)))
 
 (defun message-narrow-to-field ()
   "Narrow the buffer to the header on the current line."
@@ -1150,6 +1146,7 @@ is used by default."
 
 (defun message-strip-list-identifiers (subject)
   "Remove list identifiers in `gnus-list-identifiers'."
+  (require 'gnus-sum)                  ; for gnus-list-identifiers
   (let ((regexp (if (stringp gnus-list-identifiers)
                    gnus-list-identifiers
                  (mapconcat 'identity gnus-list-identifiers " *\\|"))))
@@ -1368,7 +1365,25 @@ Point is left at the beginning of the narrowed-to region."
 
   (define-key message-mode-map "\C-c\C-a" 'mml-attach-file)
 
-  (define-key message-mode-map "\t" 'message-tab))
+  (define-key message-mode-map "\t" 'message-tab)
+
+  ;; Emacs 21 toolbar
+  (when (and (fboundp 'find-image) (boundp 'auto-raise-tool-bar-buttons))
+    (let ((message-help
+          (find-image '((:type xpm :file "message-help-up.xpm")
+                        (:type xbm :file "message-help-up.xbm"))))
+         (message-spell
+          (find-image '((:type xpm :file "message-spell-up.xpm")
+                        (:type xbm :file "message-spell-up.xbm")))))
+      (if message-help
+         (define-key message-mode-map [tool-bar message-help]
+           `(menu-item "Message mode documentation"
+                       ,(lambda () (info "(message)Top"))
+                       :image ,message-help)))
+      (if message-spell
+         (define-key message-mode-map [tool-bar message-spell]
+           `(menu-item "Spell-check message" ispell-message
+                       :image ,message-spell))))))
 
 (easy-menu-define
  message-mode-menu message-mode-map "Message Menu."
@@ -1489,8 +1504,10 @@ M-RET    message-newline-and-reformat (break the line and reformat)."
   (set (make-local-variable 'message-mime-part) 0)
   ;;(when (fboundp 'mail-hist-define-keys)
   ;;  (mail-hist-define-keys))
-  (when (string-match "XEmacs\\|Lucid" emacs-version)
-    (message-setup-toolbar))
+  (if (featurep 'xemacs)
+      (message-setup-toolbar)
+    (set (make-local-variable 'font-lock-defaults)
+        '(message-font-lock-keywords t)))
   (easy-menu-add message-mode-menu message-mode-map)
   (easy-menu-add message-mode-field-menu message-mode-map)
   ;; Allow mail alias things.
@@ -1499,9 +1516,6 @@ M-RET    message-newline-and-reformat (break the line and reformat)."
        (mail-abbrevs-setup)
       (mail-aliases-setup)))
   (message-set-auto-save-file-name)
-  (unless (string-match "XEmacs" emacs-version)
-    (set (make-local-variable 'font-lock-defaults)
-        '(message-font-lock-keywords t)))
   (make-local-variable 'adaptive-fill-regexp)
   (setq adaptive-fill-regexp
        (concat "[ \t]*[-a-z0-9A-Z]*\\(>[ \t]*\\)+[ \t]*\\|" adaptive-fill-regexp))
@@ -3690,6 +3704,7 @@ OTHER-HEADERS is an alist of header/value pairs."
 (defun message-reply (&optional to-address wide)
   "Start editing a reply to the article in the current buffer."
   (interactive)
+  (require 'gnus-sum)                  ; for gnus-list-identifiers
   (let ((cur (current-buffer))
        from subject date reply-to to cc
        references message-id follow-to
@@ -3752,6 +3767,7 @@ OTHER-HEADERS is an alist of header/value pairs."
   "Follow up to the message in the current buffer.
 If TO-NEWSGROUPS, use that as the new Newsgroups line."
   (interactive)
+  (require 'gnus-sum)                  ; for gnus-list-identifiers
   (let ((cur (current-buffer))
        from subject date reply-to mct
        references message-id follow-to
@@ -4278,10 +4294,6 @@ which specify the range to operate on."
 
 (defalias 'message-exchange-point-and-mark 'exchange-point-and-mark)
 
-;; Support for toolbar
-(when (string-match "XEmacs\\|Lucid" emacs-version)
-  (require 'messagexmas))
-
 ;;; Group name completion.
 
 (defvar message-newgroups-header-regexp
@@ -4400,17 +4412,20 @@ regexp varstr."
 ;;; Miscellaneous functions
 
 ;; stolen (and renamed) from nnheader.el
-(defun message-replace-chars-in-string (string from to)
-  "Replace characters in STRING from FROM to TO."
-  (let ((string (substring string 0))  ;Copy string.
-       (len (length string))
-       (idx 0))
-    ;; Replace all occurrences of FROM with TO.
-    (while (< idx len)
-      (when (= (aref string idx) from)
-       (aset string idx to))
-      (setq idx (1+ idx)))
-    string))
+(if (fboundp 'subst-char-in-string)
+    (defsubst message-replace-chars-in-string (string from to)
+      (subst-char-in-string from to string))
+  (defun message-replace-chars-in-string (string from to)
+    "Replace characters in STRING from FROM to TO."
+    (let ((string (substring string 0))        ;Copy string.
+         (len (length string))
+         (idx 0))
+      ;; Replace all occurrences of FROM with TO.
+      (while (< idx len)
+       (when (= (aref string idx) from)
+         (aset string idx to))
+       (setq idx (1+ idx)))
+      string)))
 
 ;;;
 ;;; MIME functions