Merge from emacs--devo--0
[gnus] / lisp / deuglify.el
index 5c303b5..03c2bcf 100644 (file)
@@ -1,7 +1,7 @@
 ;;; deuglify.el --- deuglify broken Outlook (Express) articles
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
-;; Copyright (C) 2001, 2002 Raymond Scholz
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   Free Software Foundation, Inc.
 
 ;; Author: Raymond Scholz <rscholz@zonix.de>
 ;;         Thomas Steffen (unwrapping algorithm,
@@ -12,7 +12,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
   :version "22.1"
   :group 'gnus)
 
-;;;###autoload
 (defcustom gnus-outlook-deuglify-unwrap-min 45
   "Minimum length of the cited line above the (possibly) wrapped line."
   :version "22.1"
   :type 'integer
   :group 'gnus-outlook-deuglify)
 
-;;;###autoload
 (defcustom gnus-outlook-deuglify-unwrap-max 95
   "Maximum length of the cited line after unwrapping."
   :version "22.1"
   :type 'string
   :group 'gnus-outlook-deuglify)
 
-;;;###autoload
 (defcustom gnus-outlook-display-hook nil
   "A hook called after an deuglified article has been prepared.
 It is run after `gnus-article-prepare-hook'."
@@ -341,6 +338,7 @@ NODISPLAY is non-nil, don't redisplay the article buffer."
 
 (defun gnus-outlook-rearrange-article (attr-start)
   "Put the text from ATTR-START to the end of buffer at the top of the article buffer."
+  ;; FIXME: 1.  (*) text/plain          ( ) text/html
   (let ((inhibit-read-only t)
        (cite-marks gnus-outlook-deuglify-cite-marks))
     (gnus-with-article-buffer
@@ -355,8 +353,18 @@ NODISPLAY is non-nil, don't redisplay the article buffer."
                    (point-max))))
          ;; handle the case where the full quote is below the
          ;; signature
-         (if (< to attr-start)
+         (when (< to attr-start)
+           (setq to (point-max)))
+         (save-excursion
+           (narrow-to-region attr-start to)
+           (goto-char attr-start)
+           (forward-line)
+           (unless (looking-at ">")
+             (message-indent-citation (point) (point-max) 'yank-only)
+             (goto-char (point-max))
+             (newline)
              (setq to (point-max)))
+           (widen))
          (transpose-regions cur attr-start attr-start to))))))
 
 ;; John Doe <john.doe@some.domain> wrote in message