* nnmbox.el (nnmbox-request-article): Don't assume delim regexp matches newline.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 13 Sep 2007 05:16:13 +0000 (05:16 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 13 Sep 2007 05:16:13 +0000 (05:16 +0000)
(nnmbox-request-accept-article): Don't change article in source buffer;
 narrow to header to use message-fetch-field rather than nnmail-fetch-field;
 use with-current-buffer instead of save-excursion.
(nnmbox-request-replace-article): Quote lines that'll be misidentified as
 delimiters; make sure article ends with newline.
(nnmbox-delete-mail): Correct last position of article to be deleted;
 ignore X-Gnus-Newsgroup header in article body.
(nnmbox-save-mail): Quote lines looking like delimiters at the right positions;
 make sure article ends with newline.

* message.el (message-display-abbrev): Don't infloop when a user inserts SPC in
 the beginning of header.

* lpath.el: Don't bind define-ccl-program for non-Mule XEmacs;
 bind coding-system-for-read and coding-system-for-write for XEmacs having no
 file-coding feature.

* dgnushack.el: Bind or autoload define-ccl-program for XEmacs.

lisp/ChangeLog
lisp/dgnushack.el
lisp/lpath.el
lisp/message.el
lisp/nnmbox.el

index 0f83c08..7358edc 100644 (file)
@@ -1,3 +1,26 @@
+2007-09-13  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * nnmbox.el (nnmbox-request-article): Don't assume delim regexp matches
+       newline.
+       (nnmbox-request-accept-article): Don't change article in source buffer;
+       narrow to header to use message-fetch-field rather than
+       nnmail-fetch-field; use with-current-buffer instead of save-excursion.
+       (nnmbox-request-replace-article): Quote lines that'll be misidentified
+       as delimiters; make sure article ends with newline.
+       (nnmbox-delete-mail): Correct last position of article to be deleted;
+       ignore X-Gnus-Newsgroup header in article body.
+       (nnmbox-save-mail): Quote lines looking like delimiters at the right
+       positions; make sure article ends with newline.
+
+       * message.el (message-display-abbrev): Don't infloop when a user
+       inserts SPC in the beginning of header.
+
+       * lpath.el: Don't bind define-ccl-program for non-Mule XEmacs; bind
+       coding-system-for-read and coding-system-for-write for XEmacs having no
+       file-coding feature.
+
+       * dgnushack.el: Bind or autoload define-ccl-program for XEmacs.
+
 2007-09-12  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * gnus-registry.el (gnus-registry-unfollowed-groups): Add INBOX to the
index 751ec60..9b2ef3f 100644 (file)
@@ -217,6 +217,10 @@ fixed in Emacs 22."
     (autoload 'customize-save-variable "cus-edit" nil t)
     (autoload 'customize-set-variable "cus-edit" nil t)
     (autoload 'customize-variable "cus-edit" nil t)
+    (if (featurep 'mule)
+       (unless (locate-library "mule-ccl")
+         (autoload 'define-ccl-program "ccl" nil nil 'macro))
+      (defalias 'define-ccl-program 'ignore))
     (autoload 'delete-annotation "annotations")
     (autoload 'dolist "cl-macs" nil nil 'macro)
     (autoload 'enriched-decode "enriched")
index af440d1..5e3b205 100644 (file)
@@ -68,9 +68,8 @@
 (when (and (featurep 'xemacs)
           (not (featurep 'mule)))
   (maybe-fbind '(ccl-execute-on-string
-                char-charset charsetp coding-system-get define-ccl-program
-                find-charset-region get-charset-property
-                pgg-parse-crc24-string))
+                char-charset charsetp coding-system-get find-charset-region
+                get-charset-property pgg-parse-crc24-string))
   (maybe-bind '(language-info-alist))
   (unless (featurep 'file-coding)
     (maybe-fbind '(coding-system-base
@@ -78,7 +77,8 @@
                   coding-system-p decode-coding-region decode-coding-string
                   detect-coding-region encode-coding-region
                   encode-coding-string))
-    (maybe-bind '(file-name-coding-system))))
+    (maybe-bind '(coding-system-for-read
+                 coding-system-for-write file-name-coding-system))))
 
 (defun nnkiboze-score-file (a)
   )
index ab42c33..c66d988 100644 (file)
@@ -7698,13 +7698,13 @@ From headers in the original article."
 (defun message-display-abbrev (&optional choose)
   "Display the next possible abbrev for the text before point."
   (interactive (list t))
-  (when (and (member (char-after (point-at-bol)) '(?C ?T ? ))
+  (when (and (memq (char-after (point-at-bol)) '(?C ?T ?\t ? ))
             (message-point-in-header-p)
             (save-excursion
-              (save-restriction
-                (message-narrow-to-field)
-                (goto-char (point-min))
-                (looking-at "To\\|Cc"))))
+              (beginning-of-line)
+              (while (and (memq (char-after) '(?\t ? ))
+                          (zerop (forward-line -1))))
+              (looking-at "To:\\|Cc:")))
     (let* ((end (point))
           (start (save-excursion
                    (and (re-search-backward "[\n\t ]" nil t)
index 1871aa3..6b217da 100644 (file)
        (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
        (setq start (point))
        (forward-line 1)
-       (or (and (re-search-forward
-                 (concat "^" message-unix-mail-delimiter) nil t)
-                (forward-line -1))
-           (goto-char (point-max)))
-       (setq stop (point))
+       (setq stop (if (re-search-forward (concat "^"
+                                                 message-unix-mail-delimiter)
+                                         nil 'move)
+                      (match-beginning 0)
+                    (point)))
        (let ((nntp-server-buffer (or buffer nntp-server-buffer)))
          (set-buffer nntp-server-buffer)
          (erase-buffer)
   (nnmbox-possibly-change-newsgroup group server)
   (nnmail-check-syntax)
   (let ((buf (current-buffer))
-       result)
-    (goto-char (point-min))
-    ;; The From line may have been quoted by movemail.
-    (when (looking-at (concat ">" message-unix-mail-delimiter))
-      (delete-char 1))
-    (if (looking-at "X-From-Line: ")
-       (replace-match "From ")
-      (insert "From nobody " (current-time-string) "\n"))
+       result cont)
     (and
      (nnmail-activate 'nnmbox)
-     (progn
-       (set-buffer buf)
+     (with-temp-buffer
+       (insert-buffer-substring buf)
        (goto-char (point-min))
-       (search-forward "\n\n" nil t)
-       (forward-line -1)
+       (cond (;; The From line may have been quoted by movemail.
+             (looking-at (concat ">" message-unix-mail-delimiter))
+             (delete-char 1)
+             (forward-line 1))
+            ((looking-at "X-From-Line: ")
+             (replace-match "From ")
+             (forward-line 1))
+            (t
+             (insert "From nobody " (current-time-string) "\n")))
+       (narrow-to-region (point)
+                        (if (search-forward "\n\n" nil 'move)
+                            (1- (point))
+                          (point)))
        (while (re-search-backward "^X-Gnus-Newsgroup: " nil t)
         (delete-region (point) (progn (forward-line 1) (point))))
        (when nnmail-cache-accepted-message-ids
-        (nnmail-cache-insert (nnmail-fetch-field "message-id") 
+        (nnmail-cache-insert (message-fetch-field "message-id")
                              group
-                             (nnmail-fetch-field "subject")
-                             (nnmail-fetch-field "from")))
+                             (message-fetch-field "subject")
+                             (message-fetch-field "from")))
+       (widen)
        (setq result (if (stringp group)
                        (list (cons group (nnmbox-active-number group)))
                      (nnmail-article-group 'nnmbox-active-number)))
-       (if (and (null result)
-               (yes-or-no-p "Moved to `junk' group; delete article? "))
-          (setq result 'junk)
-        (setq result (car (nnmbox-save-mail result)))))
-     (save-excursion
-       (set-buffer nnmbox-mbox-buffer)
+       (prog1
+          (if (and (null result)
+                   (yes-or-no-p "Moved to `junk' group; delete article? "))
+              (setq result 'junk)
+            (setq result (car (nnmbox-save-mail result))))
+        (setq cont (buffer-string))))
+     (with-current-buffer nnmbox-mbox-buffer
        (goto-char (point-max))
-       (insert-buffer-substring buf)
+       (insert cont)
        (when last
         (when nnmail-cache-accepted-message-ids
           (nnmail-cache-close))
     (if (not (nnmbox-find-article article))
        nil
       (nnmbox-delete-mail t t)
-      (insert-buffer-substring buffer)
+      (insert
+       (with-temp-buffer
+        (insert-buffer-substring buffer)
+        (goto-char (point-min))
+        (when (looking-at "X-From-Line:")
+          (delete-region (point) (progn (forward-line 1) (point))))
+        (while (re-search-forward (concat "^" message-unix-mail-delimiter)
+                                  nil t)
+          (goto-char (match-beginning 0))
+          (insert ">"))
+        (goto-char (point-max))
+        (unless (bolp)
+          (insert "\n"))
+        (buffer-string)))
       (nnmbox-save-buffer)
       t)))
 
   (save-excursion
     (save-restriction
       (narrow-to-region
-       (save-excursion
-        (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
-        (if leave-delim (progn (forward-line 1) (point))
-          (match-beginning 0)))
-       (progn
-        (forward-line 1)
-        (or (and (re-search-forward (concat "^" message-unix-mail-delimiter)
-                                    nil t)
-                 (if (and (not (bobp)) leave-delim)
-                     (progn (forward-line -2) (point))
-                   (match-beginning 0)))
-            (point-max))))
+       (prog2
+          (re-search-backward (concat "^" message-unix-mail-delimiter) nil t)
+          (if leave-delim (progn (forward-line 1) (point))
+            (match-beginning 0))
+        (forward-line 1))
+       (or (and (re-search-forward (concat "^" message-unix-mail-delimiter)
+                                  nil t)
+               (match-beginning 0))
+          (point-max)))
       (goto-char (point-min))
       ;; Only delete the article if no other group owns it as well.
-      (when (or force (not (re-search-forward "^X-Gnus-Newsgroup: " nil t)))
+      (when (or force
+               (not (re-search-forward "^X-Gnus-Newsgroup: " nil t))
+               (search-backward "\n\n" nil t))
        (delete-region (point-min) (point-max))))))
 
 (defun nnmbox-possibly-change-newsgroup (newsgroup &optional server)
   (let ((delim (concat "^" message-unix-mail-delimiter)))
     (goto-char (point-min))
     ;; This might come from somewhere else.
-    (unless (looking-at delim)
-      (insert "From nobody " (current-time-string) "\n")
-      (goto-char (point-min)))
+    (if (looking-at delim)
+       (forward-line 1)
+      (insert "From nobody " (current-time-string) "\n"))
     ;; Quote all "From " lines in the article.
-    (forward-line 1)
     (while (re-search-forward delim nil t)
-      (beginning-of-line)
-      (insert "> "))
-    (nnmail-insert-lines)
-    (nnmail-insert-xref group-art)
-    (nnmbox-insert-newsgroup-line group-art)
-    (let ((alist group-art))
-      (while alist
-       (nnmbox-record-active-article (car alist))
-       (setq alist (cdr alist))))
-    (run-hooks 'nnmail-prepare-save-mail-hook)
-    (run-hooks 'nnmbox-prepare-save-mail-hook)
-    group-art))
+      (goto-char (match-beginning 0))
+      (insert ">")))
+  (goto-char (point-max))
+  (unless (bolp)
+    (insert "\n"))
+  (nnmail-insert-lines)
+  (nnmail-insert-xref group-art)
+  (nnmbox-insert-newsgroup-line group-art)
+  (let ((alist group-art))
+    (while alist
+      (nnmbox-record-active-article (car alist))
+      (setq alist (cdr alist))))
+  (run-hooks 'nnmail-prepare-save-mail-hook)
+  (run-hooks 'nnmbox-prepare-save-mail-hook)
+  group-art)
 
 (defun nnmbox-insert-newsgroup-line (group-art)
   (save-excursion