2001-07-16 12:00:00 ShengHuo ZHU <zsh@cs.rochester.edu>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Mon, 16 Jul 2001 20:05:33 +0000 (20:05 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Mon, 16 Jul 2001 20:05:33 +0000 (20:05 +0000)
From:  Stefan Monnier  <monnier@cs.yale.edu>

* message.el (message-mode): Use define-derived-mode.
(message-tab): message-completion-alist.

* imap.el (imap-interactive-login): Use make-local-variable.
(imap-open): Ditto.
(imap-authenticate): Ditto.

* gnus-msg.el (gnus-setup-message): Change-major-mode-hook.

* gnus-art.el (gnus-article-edit-mode): Use define-derived-mode.

lisp/ChangeLog
lisp/gnus-art.el
lisp/gnus-msg.el
lisp/imap.el
lisp/lpath.el
lisp/message.el

index 0e38974..3155f61 100644 (file)
@@ -1,3 +1,17 @@
+2001-07-16 12:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
+       From:  Stefan Monnier  <monnier@cs.yale.edu>
+
+       * message.el (message-mode): Use define-derived-mode.
+       (message-tab): message-completion-alist.
+
+       * imap.el (imap-interactive-login): Use make-local-variable.
+       (imap-open): Ditto.
+       (imap-authenticate): Ditto.
+
+       * gnus-msg.el (gnus-setup-message): Change-major-mode-hook.
+
+       * gnus-art.el (gnus-article-edit-mode): Use define-derived-mode.
+
 2001-07-16  Kai Gro\e,A_\e(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
 
        * message.el (message-citation-line-function): Refer to
index 080a024..3b46395 100644 (file)
@@ -1524,7 +1524,7 @@ MAP is an alist where the elements are on the form (\"from\" \"to\")."
          (width (window-width (get-buffer-window (current-buffer)))))
       (save-restriction
        (article-goto-body)
-       (let ((adaptive-fill-mode nil))
+       (let ((adaptive-fill-mode nil)) ;Why?  -sm
          (while (not (eobp))
            (end-of-line)
            (when (>= (current-column) (min fill-column width))
@@ -4574,21 +4574,18 @@ If given a prefix, show the hidden text instead."
                     "\C-c\C-w" gnus-article-edit-mode-map)
     "f" gnus-article-edit-full-stops))
 
-(defun gnus-article-edit-mode ()
+(define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
   "Major mode for editing articles.
 This is an extended text-mode.
 
 \\{gnus-article-edit-mode-map}"
-  (interactive)
-  (setq major-mode 'gnus-article-edit-mode)
-  (setq mode-name "Article Edit")
-  (use-local-map gnus-article-edit-mode-map)
   (make-local-variable 'gnus-article-edit-done-function)
   (make-local-variable 'gnus-prev-winconf)
+  (set (make-local-variable 'font-lock-defaults)
+       '(message-font-lock-keywords t))
   (setq buffer-read-only nil)
   (buffer-enable-undo)
-  (widen)
-  (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
+  (widen))
 
 (defun gnus-article-edit (&optional force)
   "Edit the current article.
index 3f25c7a..33b101b 100644 (file)
@@ -246,6 +246,7 @@ Thank you for your help in stamping out bugs.
             (let ((mbl1 mml-buffer-list))
               (setq mml-buffer-list mbl)  ;; Global value
               (set (make-local-variable 'mml-buffer-list) mbl1);; Local value
+              (add-hook 'change-major-mode-hook 'mml-destroy-buffers nil t)
               (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))
           (mml-destroy-buffers)
           (setq mml-buffer-list mbl)))
index 91c74da..057d98e 100644 (file)
@@ -734,8 +734,8 @@ LOGINFUNC is passed a username and a password, it should return t if
 it where sucessful authenticating itself to the server, nil otherwise.
 Returns t if login was successful, nil otherwise."
   (with-current-buffer buffer
-    (make-variable-buffer-local 'imap-username)
-    (make-variable-buffer-local 'imap-password)
+    (make-local-variable 'imap-username)
+    (make-local-variable 'imap-password)
     (let (user passwd ret)
       ;;      (condition-case ()
       (while (or (not user) (not passwd))
@@ -900,7 +900,7 @@ necessery.  If nil, the buffer name is generated."
   (with-current-buffer (get-buffer-create buffer)
     (if (imap-opened buffer)
        (imap-close buffer))
-    (mapcar 'make-variable-buffer-local imap-local-variables)
+    (mapcar 'make-local-variable imap-local-variables)
     (imap-disable-multibyte)
     (buffer-disable-undo)
     (setq imap-server (or server imap-server))
@@ -970,8 +970,8 @@ password is remembered in the buffer."
        (or (eq imap-state 'auth)
            (eq imap-state 'select)
            (eq imap-state 'examine))
-      (make-variable-buffer-local 'imap-username)
-      (make-variable-buffer-local 'imap-password)
+      (make-local-variable 'imap-username)
+      (make-local-variable 'imap-password)
       (if user (setq imap-username user))
       (if passwd (setq imap-password passwd))
       (if (funcall (nth 2 (assq imap-auth imap-authenticator-alist)) buffer)
index 867de91..96fa5da 100644 (file)
@@ -13,6 +13,7 @@
 
 (maybe-fbind '(babel-fetch
               babel-wash create-image decode-coding-string display-graphic-p
+               bbdb-complete-name
               display-time-event-handler
               find-image font-create-object gnus-mule-get-coding-system
               font-lock-set-defaults
index ffc5563..b9b39ba 100644 (file)
@@ -771,10 +771,6 @@ candidates:
     table)
   "Syntax table used while in Message mode.")
 
-(defvar message-mode-abbrev-table text-mode-abbrev-table
-  "Abbrev table used in Message mode buffers.
-Defaults to `text-mode-abbrev-table'.")
-
 (defface message-header-to-face
   '((((class color)
       (background dark))
@@ -1555,7 +1551,7 @@ Point is left at the beginning of the narrowed-to region."
   (defvar facemenu-remove-face-function))
 
 ;;;###autoload
-(defun message-mode ()
+(define-derived-mode message-mode text-mode "Message"
   "Major mode for editing mail and news to be sent.
 Like Text Mode but with these additional commands:\\<message-mode-map>
 C-c C-s  `message-send' (send the message)  C-c C-c  `message-send-and-exit'
@@ -1580,35 +1576,22 @@ C-c C-z  `message-kill-to-signature' (kill the text up to the signature).
 C-c C-r  `message-caesar-buffer-body' (rot13 the message body).
 C-c C-a  `mml-attach-file' (attach a file as MIME).
 M-RET    `message-newline-and-reformat' (break the line and reformat)."
-  (interactive)
-  (if (local-variable-p 'mml-buffer-list (current-buffer))
-      (mml-destroy-buffers))
-  (kill-all-local-variables)
   (set (make-local-variable 'message-reply-buffer) nil)
   (make-local-variable 'message-send-actions)
   (make-local-variable 'message-exit-actions)
   (make-local-variable 'message-kill-actions)
   (make-local-variable 'message-postpone-actions)
   (make-local-variable 'message-draft-article)
-  (make-local-hook 'kill-buffer-hook)
-  (set-syntax-table message-mode-syntax-table)
-  (use-local-map message-mode-map)
-  (setq local-abbrev-table message-mode-abbrev-table)
-  (setq major-mode 'message-mode)
-  (setq mode-name "Message")
   (setq buffer-offer-save t)
-  (make-local-variable 'facemenu-add-face-function)
-  (make-local-variable 'facemenu-remove-face-function)
-  (setq facemenu-add-face-function
-       (lambda (face end)
-         (let ((face-fun (cdr (assq face message-face-alist))))
-           (if face-fun
-               (funcall face-fun (point) end)
-             (error "Face %s not configured for %s mode" face mode-name)))
-         "")
-       facemenu-remove-face-function t)
-  (make-local-variable 'message-reply-headers)
-  (setq message-reply-headers nil)
+  (set (make-local-variable 'facemenu-add-face-function)
+       (lambda (face end)
+        (let ((face-fun (cdr (assq face message-face-alist))))
+          (if face-fun
+              (funcall face-fun (point) end)
+            (error "Face %s not configured for %s mode" face mode-name)))
+        ""))
+  (set (make-local-variable 'facemenu-remove-face-function) t)
+  (set (make-local-variable 'message-reply-headers) nil)
   (make-local-variable 'message-newsreader)
   (make-local-variable 'message-mailer)
   (make-local-variable 'message-post-method)
@@ -1633,10 +1616,8 @@ M-RET    `message-newline-and-reformat' (break the line and reformat)."
       (mail-aliases-setup)))
   (message-set-auto-save-file-name)
   (mm-enable-multibyte)
-  (make-local-variable 'indent-tabs-mode) ;Turn off tabs for indentation.
-  (setq indent-tabs-mode nil)
-  (mml-mode)
-  (run-hooks 'text-mode-hook 'message-mode-hook))
+  (set (make-local-variable 'indent-tabs-mode) nil) ;No tabs for indentation.
+  (mml-mode))
 
 (defun message-setup-fill-variables ()
   "Setup message fill variables."
@@ -4803,14 +4784,21 @@ which specify the range to operate on."
   "^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):"
   "Regexp that match headers that lists groups.")
 
+(defvar message-completion-alist
+  (list (cons message-newgroups-header-regexp 'message-expand-group)
+       '("^\\(Resent-\\)?\\(To\\|B?Cc\\):" . message-expand-name))
+  "Alist of (RE . FUN).  Use FUN for completion on header lines matching RE.")
+
 (defun message-tab ()
   "Expand group names in Newsgroups and Followup-To headers.
 Do a `tab-to-tab-stop' if not in those headers."
   (interactive)
-  (if (let ((mail-abbrev-mode-regexp message-newgroups-header-regexp))
-       (mail-abbrev-in-expansion-header-p))
-      (message-expand-group)
-    (tab-to-tab-stop)))
+  (let ((alist message-completion-alist))
+    (while (and alist
+               (let ((mail-abbrev-mode-regexp (caar alist)))
+                 (not (mail-abbrev-in-expansion-header-p))))
+      (setq alist (cdr alist)))
+    (funcall (or (cdar alist) (default-value 'indent-line-function)))))
 
 (defun message-expand-group ()
   "Expand the group name under point."
@@ -4854,6 +4842,11 @@ Do a `tab-to-tab-stop' if not in those headers."
            (goto-char (point-min))
            (delete-region (point) (progn (forward-line 3) (point))))))))))
 
+(defun message-expand-name ()
+  (if (fboundp 'bbdb-complete-name)
+      (bbdb-complete-name)
+    (expand-abbrev)))
+
 ;;; Help stuff.
 
 (defun message-talkative-question (ask question show &rest text)