]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/supercite.el
Additional fix for rfc822-addresses (Bug#5692).
[gnu-emacs] / lisp / mail / supercite.el
index 98c5f8689ba34ce7a63dcd3691ee85bd1435011d..f3636c6504faf92f87d99a7b6de7162f56cf2f98 100644 (file)
@@ -1,7 +1,7 @@
 ;;; supercite.el --- minor mode for citing mail and news replies
 
-;; Copyright (C) 1993, 1997, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: 1993 Barry A. Warsaw <bwarsaw@python.org>
 ;; Maintainer:    Glenn Morris <rgm@gnu.org>
@@ -700,6 +700,7 @@ the list should be unique."
   "For minibuffer completion on mail field modifications.")
 (defvar sc-mail-glom-frame
   '((begin                        (setq sc-mail-headers-start (point)))
+    ("^From "                     (sc-mail-check-from) nil nil)
     ("^x-attribution:[ \t]+.*$"   (sc-mail-fetch-field t) nil t)
     ("^\\S +:.*$"                 (sc-mail-fetch-field) nil t)
     ("^$"                         (list 'abort '(step . 0)))
@@ -712,6 +713,17 @@ the list should be unique."
 (defvar curline)                       ; dynamic bondage
 
 ;; regi functions
+
+;; http://lists.gnu.org/archive/html/emacs-devel/2009-02/msg00691.html
+;; When rmail replies to a message with full headers visible, the "From "
+;; line can be included.
+(defun sc-mail-check-from ()
+  "Deal with a \"From \" line in the header.
+Such a line should only occur at the very start of the headers."
+  (and sc-mail-warn-if-non-rfc822-p
+       (/= (point) sc-mail-headers-start)
+       (sc-mail-error-in-mail-field)))
+
 (defun sc-mail-fetch-field (&optional attribs-p)
   "Insert a key and value into `sc-mail-info' alist.
 If optional ATTRIBS-P is non-nil, the key/value pair is placed in
@@ -1657,23 +1669,22 @@ header style to use, unless not supplied or invalid, in which case
            (if sc-electric-circular-p
                0
              (progn (error msg "follow") (1- last))))))
-    (save-excursion
-     (set-buffer sc-electric-bufname)
-     (let ((buffer-read-only nil))
-       (erase-buffer)
-       (goto-char (point-min))
-       (sc-eref-insert-selected)
-       ;; now shrink the window to just contain the electric reference
-       ;; header.
-       (let ((hdrlines (count-lines (point-min) (point-max)))
-            (winlines (1- (window-height))))
-        (if (/= hdrlines winlines)
-            (if (> hdrlines winlines)
-                ;; we have to enlarge the window
-                (enlarge-window (- hdrlines winlines))
-              ;; we have to shrink the window
-              (shrink-window (- winlines (max hdrlines
-                                              window-min-height))))))))))
+    (with-current-buffer sc-electric-bufname
+      (let ((inhibit-read-only t))
+        (erase-buffer)
+        (goto-char (point-min))
+        (sc-eref-insert-selected)
+        ;; now shrink the window to just contain the electric reference
+        ;; header.
+        (let ((hdrlines (count-lines (point-min) (point-max)))
+              (winlines (1- (window-height))))
+          (if (/= hdrlines winlines)
+              (if (> hdrlines winlines)
+                  ;; we have to enlarge the window
+                  (enlarge-window (- hdrlines winlines))
+                ;; we have to shrink the window
+                (shrink-window (- winlines (max hdrlines
+                                                window-min-height))))))))))
 
 (defun sc-eref-next ()
   "Display next reference in other buffer."
@@ -1956,11 +1967,13 @@ cited."
        (insert (sc-mail-field "sc-citation"))
       (error "Line is already cited"))))
 
+;; The argument logic here is crazy.
 (defun sc-version (message)
-  "Echo the current version of Supercite in the minibuffer.
+  "Return the current Supercite version.
 If MESSAGE is non-nil (interactively, with no prefix argument),
-inserts the version string in the current buffer instead."
-  (interactive (not current-prefix-arg))
+echoes the version in the minibuffer.  Otherwise, inserts the
+version at point."
+  (interactive (list (not current-prefix-arg)))
   (let ((verstr (format "Using Supercite.el %s" emacs-version)))
     (if message
        (message verstr)