]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/supercite.el
(rmail-reply): Don't call mail-strip-quoted-names.
[gnu-emacs] / lisp / mail / supercite.el
index b9e6f867dafae45a878244b0b89293896cc1f564..eadfa1430c3e919aca1d42ff1107e0a30068569f 100644 (file)
@@ -1,16 +1,15 @@
 ;;; supercite.el --- minor mode for citing mail and news replies
 
+;; Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+
 ;; Author: 1993 Barry A. Warsaw, Century Computing, Inc. <bwarsaw@cen.com>
-;; Maintainer:    supercite-help@anthem.nlm.nih.gov
+;; Maintainer:    Mark Senn <mds@ecn.purdue.edu>
 ;; Created:       February 1993
-;; Version:       3.1
 ;; Last Modified: 1993/09/22 18:58:46
 ;; Keywords: mail, news
 
 ;; supercite.el revision: 3.54
 
-;; Copyright (C) 1993 Barry A. Warsaw
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;; LCD Archive Entry
-;; supercite|Barry A. Warsaw|supercite-help@anthem.nlm.nih.gov
+;; supercite|Barry A. Warsaw|supercite-help@python.org
 ;; |Mail and news reply citation package
 ;; |1993/09/22 18:58:46|3.1|
 
-;; Code:
+;;; Commentary:
+
+;;; Code:
 
 \f
 (require 'regi)
+(require 'sendmail)    ;; For mail-header-end.
 
 ;; start user configuration variables
 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 
-(defvar sc-auto-fill-region-p t
-  "*If non-nil, automatically fill each paragraph after it has been cited.")
-
-(defvar sc-blank-lines-after-headers 1
+(defgroup supercite nil
+  "Supercite package"
+  :prefix "sc-"
+  :group 'mail
+  :group 'news)
+
+(defgroup supercite-frames nil
+  "Supercite (regi) frames"
+  :prefix "sc-"
+  :group 'supercite)
+
+(defgroup supercite-attr nil
+  "Supercite attributions"
+  :prefix "sc-"
+  :group 'supercite)
+
+(defgroup supercite-cite nil
+  "Supercite citings"
+  :prefix "sc-"
+  :group 'supercite)
+
+(defgroup supercite-hooks nil
+  "Hooking into supercite"
+  :prefix "sc-"
+  :group 'supercite)
+
+(defcustom sc-auto-fill-region-p t
+  "*If non-nil, automatically fill each paragraph after it has been cited."
+  :type 'boolean
+  :group 'supercite)
+
+(defcustom sc-blank-lines-after-headers 1
   "*Number of blank lines to leave after mail headers have been nuked.
-Set to nil, to use whatever blank lines happen to occur naturally.")
+Set to nil, to use whatever blank lines happen to occur naturally."
+  :type '(choice (const :tag "leave" nil)
+                integer)
+  :group 'supercite)
+
+(defcustom sc-citation-leader "    "
+  "*String comprising first part of a citation."
+  :type 'string
+  :group 'supercite-cite)
 
-(defvar sc-citation-leader "    "
-  "*String comprising first part of a citation.")
-(defvar sc-citation-delimiter ">"
+(defcustom sc-citation-delimiter ">"
   "*String comprising third part of a citation.
-This string is used in both nested and non-nested citations.")
-(defvar sc-citation-separator " "
-  "*String comprising fourth and last part of a citation.")
+This string is used in both nested and non-nested citations."
+  :type 'string
+  :group 'supercite-cite)
 
-(defvar sc-citation-leader-regexp "[ \t]*"
+(defcustom sc-citation-separator " "
+  "*String comprising fourth and last part of a citation."
+  :type 'string
+  :group 'supercite-cite)
+
+(defcustom sc-citation-leader-regexp "[ \t]*"
   "*Regexp describing citation leader for a cited line.
-This should NOT have a leading `^' character.")
+This should NOT have a leading `^' character."
+  :type 'regexp
+  :group 'supercite-cite)
 
 ;; Nemacs and Mule users note: please see the texinfo manual for
 ;; suggestions on setting these variables.
-(defvar sc-citation-root-regexp "[-._a-zA-Z0-9]*"
+(defcustom sc-citation-root-regexp "[-._[:alnum:]]*"
   "*Regexp describing variable root part of a citation for a cited line.
 This should NOT have a leading `^' character.  See also
-`sc-citation-nonnested-root-regexp'.")
-(defvar sc-citation-nonnested-root-regexp "[-._a-zA-Z0-9]+"
+`sc-citation-nonnested-root-regexp'."
+  :type 'regexp
+  :group 'supercite-cite)
+
+(defcustom sc-citation-nonnested-root-regexp "[-._[:alnum:]]+"
   "*Regexp describing the variable root part of a nested citation.
 This should NOT have a leading `^' character.  This variable is
-related to `sc-citation-root-regexp' but where as that varariable
+related to `sc-citation-root-regexp' but whereas that variable
 describes both nested and non-nested citation roots, this variable
-describes only nested citation roots.")
-(defvar sc-citation-delimiter-regexp "[>]+"
+describes only nested citation roots."
+  :type 'regexp
+  :group 'supercite-cite)
+
+(defcustom sc-citation-delimiter-regexp "[>]+"
   "*Regexp describing citation delimiter for a cited line.
-This should NOT have a leading `^' character.")
-(defvar sc-citation-separator-regexp "[ \t]*"
+This should NOT have a leading `^' character."
+  :type 'regexp
+  :group 'supercite-cite)
+
+(defcustom sc-citation-separator-regexp "[ \t]*"
   "*Regexp describing citation separator for a cited line.
-This should NOT have a leading `^' character.")
+This should NOT have a leading `^' character."
+  :type 'regexp
+  :group 'supercite-cite)
 
-(defvar sc-cite-blank-lines-p nil
-  "*If non-nil, put a citation on blank lines.")
+(defcustom sc-cite-blank-lines-p nil
+  "*If non-nil, put a citation on blank lines."
+  :type 'boolean
+  :group 'supercite-cite)
 
-(defvar sc-cite-frame-alist '()
+(defcustom sc-cite-frame-alist '()
   "*Alist for frame selection during citing.
 Each element of this list has the following form:
-
    (INFOKEY ((REGEXP . FRAME)
              (REGEXP . FRAME)
              (...)))
 
 Where INFOKEY is a key for `sc-mail-field', REGEXP is a regular
 expression to match against the INFOKEY's value.  FRAME is a citation
-frame, or a variable containing a citation frame.")
-(defvar sc-uncite-frame-alist '()
+frame, or a variable containing a citation frame."
+  :type '(repeat (list symbol (repeat (cons regexp
+                                           (choice (repeat (repeat sexp))
+                                                   symbol)))))
+  :group 'supercite-frames)
+
+(defcustom sc-uncite-frame-alist '()
   "*Alist for frame selection during unciting.
-See the variable `sc-cite-frame-alist' for details.")
-(defvar sc-recite-frame-alist '()
+See the variable `sc-cite-frame-alist' for details."
+  :type '(repeat (list symbol (repeat (cons regexp
+                                           (choice (repeat (repeat sexp))
+                                                   symbol)))))
+  :group 'supercite-frames)
+
+(defcustom sc-recite-frame-alist '()
   "*Alist for frame selection during reciting.
-See the variable `sc-cite-frame-alist' for details.")
+See the variable `sc-cite-frame-alist' for details."
+  :type '(repeat (list symbol (repeat (cons regexp
+                                           (choice (repeat (repeat sexp))
+                                                   symbol)))))
+  :group 'supercite-frames)
 
-(defvar sc-default-cite-frame
+(defcustom sc-default-cite-frame
   '(;; initialize fill state and temporary variables when entering
     ;; frame. this makes things run much faster
     (begin (progn
@@ -140,17 +210,21 @@ See the variable `sc-cite-frame-alist' for details.")
     ;; be sure when we're done that we fill the last cited paragraph.
     (end                        (sc-fill-if-different ""))
     )
-  "*Default REGI frame for citing a region.")
+  "*Default REGI frame for citing a region."
+  :type '(repeat (repeat sexp))
+  :group 'supercite-frames)
 
-(defvar sc-default-uncite-frame
+(defcustom sc-default-uncite-frame
   '(;; do nothing on a blank line
     ("^[ \t]*$"       nil)
     ;; if the line is cited, uncite it
     ((sc-cite-regexp) (sc-uncite-line))
     )
-  "*Default REGI frame for unciting a region.")
+  "*Default REGI frame for unciting a region."
+  :type '(repeat (repeat sexp))
+  :group 'supercite-frames)
 
-(defvar sc-default-recite-frame
+(defcustom sc-default-recite-frame
   '(;; initialize fill state when entering frame
     (begin            (sc-fill-if-different))
     ;; do nothing on a blank line
@@ -162,9 +236,11 @@ See the variable `sc-cite-frame-alist' for details.")
     ;; be sure when we're done that we fill the last cited paragraph.
     (end              (sc-fill-if-different ""))
     )
-  "*Default REGI frame for reciting a region.")
+  "*Default REGI frame for reciting a region."
+  :type '(repeat (repeat sexp))
+  :group 'supercite-frames)
 
-(defvar sc-cite-region-limit t
+(defcustom sc-cite-region-limit t
   "*This variable controls automatic citation of yanked text.
 Legal values are:
 
@@ -179,42 +255,72 @@ nil       -- do not cite the region at all
 The gathering of attribution information is not affected by the value
 of this variable.  The number of lines in the region is calculated
 *after* all mail headers are removed.  This variable is only consulted
-during the initial citing via `sc-cite-original'.")
-
-(defvar sc-confirm-always-p t
-  "*If non-nil, always confirm attribution string before citing text body.")
-
-(defvar sc-default-attribution "Anon"
-  "*String used when author's attribution cannot be determined.")
-(defvar sc-default-author-name "Anonymous"
-  "*String used when author's name cannot be determined.")
-
-(defvar sc-downcase-p nil
-  "*Non-nil means downcase the attribution and citation strings.")
-
-(defvar sc-electric-circular-p t
-  "*If non-nil, treat electric references as circular.")
-(defvar sc-electric-mode-hook nil
-  "*Hook for `sc-electric-mode' electric references mode.")
-(defvar sc-electric-references-p nil
-  "*Use electric references if non-nil.")
-
-(defvar sc-fixup-whitespace-p nil
-  "*If non-nil, delete all leading white space before citing.")
-
-(defvar sc-load-hook nil
-  "*Hook which gets run once after Supercite loads.")
-(defvar sc-pre-hook nil
-  "*Hook which gets run before each invocation of `sc-cite-original'.")
-(defvar sc-post-hook nil
-  "*Hook which gets run after each invocation of `sc-cite-original'.")
-
-(defvar sc-mail-warn-if-non-rfc822-p t
-  "*Warn if mail headers don't conform to RFC822.")
-(defvar sc-mumble ""
-  "*Value returned by `sc-mail-field' if field isn't in mail headers.")
-
-(defvar sc-name-filter-alist
+during the initial citing via `sc-cite-original'."
+  :type '(choice (const :tag "do not cite" nil)
+                (integer :tag "citation threshold")
+                (other :tag "always cite" t))
+  :group 'supercite-cite)
+
+(defcustom sc-confirm-always-p t
+  "*If non-nil, always confirm attribution string before citing text body."
+  :type 'boolean
+  :group 'supercite-attr)
+
+(defcustom sc-default-attribution "Anon"
+  "*String used when author's attribution cannot be determined."
+  :type 'string
+  :group 'supercite-attr)
+(defcustom sc-default-author-name "Anonymous"
+  "*String used when author's name cannot be determined."
+  :type 'string
+  :group 'supercite-attr)
+(defcustom sc-downcase-p nil
+  "*Non-nil means downcase the attribution and citation strings."
+  :type 'boolean
+  :group 'supercite-attr
+  :group 'supercite-cite)
+(defcustom sc-electric-circular-p t
+  "*If non-nil, treat electric references as circular."
+  :type 'boolean
+  :group 'supercite-attr)
+
+(defcustom sc-electric-mode-hook nil
+  "*Hook for `sc-electric-mode' electric references mode."
+  :type 'hook
+  :group 'supercite-hooks)
+(defcustom sc-electric-references-p nil
+  "*Use electric references if non-nil."
+  :type 'boolean
+  :group 'supercite)
+
+(defcustom sc-fixup-whitespace-p nil
+  "*If non-nil, delete all leading white space before citing."
+  :type 'boolean
+  :group 'supercite)
+
+(defcustom sc-load-hook nil
+  "*Hook which gets run once after Supercite loads."
+  :type 'hook
+  :group 'supercite-hooks)
+(defcustom sc-pre-hook nil
+  "*Hook which gets run before each invocation of `sc-cite-original'."
+  :type 'hook
+  :group 'supercite-hooks)
+(defcustom sc-post-hook nil
+  "*Hook which gets run after each invocation of `sc-cite-original'."
+  :type 'hook
+  :group 'supercite-hooks)
+
+(defcustom sc-mail-warn-if-non-rfc822-p t
+  "*Warn if mail headers don't conform to RFC822."
+  :type 'boolean
+  :group 'supercite-attr)
+(defcustom sc-mumble ""
+  "*Value returned by `sc-mail-field' if field isn't in mail headers."
+  :type 'string
+  :group 'supercite-attr)
+
+(defcustom sc-name-filter-alist
   '(("^\\(Mr\\|Mrs\\|Ms\\|Dr\\)[.]?$" . 0)
     ("^\\(Jr\\|Sr\\)[.]?$" . last)
     ("^ASTS$" . 0)
@@ -227,27 +333,37 @@ REGEXP is a regular expression which matches the name list component.
 Match is performed using `string-match'.  POSITION is the position in
 the name list which can match the regular expression, starting at zero
 for the first element.  Use `last' to match the last element in the
-list and `any' to match all elements.")
+list and `any' to match all elements."
+  :type '(repeat (cons regexp (choice (const last) (const any)
+                                     (integer :tag "position"))))
+  :group 'supercite-attr)
 
-(defvar sc-nested-citation-p nil
+(defcustom sc-nested-citation-p nil
   "*Controls whether to use nested or non-nested citation style.
-Non-nil uses nested citations, nil uses non-nested citations.")
+Non-nil uses nested citations, nil uses non-nested citations."
+  :type 'boolean
+  :group 'supercite)
 
-(defvar sc-nuke-mail-headers 'all
+(defcustom sc-nuke-mail-headers 'all
   "*Controls mail header nuking.
 Used in conjunction with `sc-nuke-mail-header-list'.  Legal values are:
 
 `all'       -- nuke all mail headers
 `none'      -- don't nuke any mail headers
 `specified' -- nuke headers specified in `sc-nuke-mail-header-list'
-`keep'      -- keep headers specified in `sc-nuke-mail-header-list'")
+`keep'      -- keep headers specified in `sc-nuke-mail-header-list'"
+  :type '(choice (const all) (const none)
+                (const specified) (const keep))
+  :group 'supercite)
 
-(defvar sc-nuke-mail-header-list nil
+(defcustom sc-nuke-mail-header-list nil
   "*List of mail header regexps to remove or keep in body of reply.
 This list contains regular expressions describing the mail headers to
-keep or nuke, depending on the value of `sc-nuke-mail-headers'.")
+keep or nuke, depending on the value of `sc-nuke-mail-headers'."
+  :type '(repeat regexp)
+  :group 'supercite)
 
-(defvar sc-preferred-attribution-list
+(defcustom sc-preferred-attribution-list
   '("sc-lastchoice" "x-attribution" "firstname" "initials" "lastname")
   "*Specifies what to use as the attribution string.
 Supercite creates a list of possible attributions when it scans the
@@ -285,9 +401,11 @@ in the attribution alist:
 Middle name indexes can be any positive integer greater than 0,
 although it is unlikely that many authors will supply more than one
 middle name, if that many.  The string of all middle names is
-associated with the key \"middlenames\".")
+associated with the key \"middlenames\"."
+  :type '(repeat string)
+  :group 'supercite-attr)
 
-(defvar sc-attrib-selection-list nil
+(defcustom sc-attrib-selection-list nil
   "*An alist for selecting preferred attribution based on mail headers.
 Each element of this list has the following form:
 
@@ -302,28 +420,52 @@ selected by `sc-select-attribution'.  If it is a list, it is `eval'd
 and the return value must be a string, which is used as the selected
 attribution.  Note that the variable `sc-preferred-attribution-list'
 must contain an element of the string \"sc-consult\" for this variable
-to be consulted during attribution selection.")
-
-(defvar sc-attribs-preselect-hook nil
-  "*Hook to run before selecting an attribution.")
-(defvar sc-attribs-postselect-hook nil
-  "*Hook to run after selecting an attribution, but before confirmation.")
-
-(defvar sc-pre-cite-hook nil
-  "*Hook to run before citing a region of text.")
-(defvar sc-pre-uncite-hook nil
-  "*Hook to run before unciting a region of text.")
-(defvar sc-pre-recite-hook nil
-  "*Hook to run before reciting a region of text.")
-
-(defvar sc-preferred-header-style 4
+to be consulted during attribution selection."
+  :type '(repeat (list string
+                      (repeat (cons regexp
+                                    (choice (sexp :tag "List to eval")
+                                            string)))))
+  :group 'supercite-attr)
+
+(defcustom sc-attribs-preselect-hook nil
+  "*Hook to run before selecting an attribution."
+  :type 'hook
+  :group 'supercite-attr
+  :group 'supercite-hooks)
+(defcustom sc-attribs-postselect-hook nil
+  "*Hook to run after selecting an attribution, but before confirmation."
+  :type 'hook
+  :group 'supercite-attr
+  :group 'supercite-hooks)
+
+(defcustom sc-pre-cite-hook nil
+  "*Hook to run before citing a region of text."
+  :type 'hook
+  :group 'supercite-cite
+  :group 'supercite-hooks)
+(defcustom sc-pre-uncite-hook nil
+  "*Hook to run before unciting a region of text."
+  :type 'hook
+  :group 'supercite-cite
+  :group 'supercite-hooks)
+(defcustom sc-pre-recite-hook nil
+  "*Hook to run before reciting a region of text."
+  :type 'hook
+  :group 'supercite-cite
+  :group 'supercite-hooks)
+
+(defcustom sc-preferred-header-style 4
   "*Index into `sc-rewrite-header-list' specifying preferred header style.
-Index zero accesses the first function in the list.")
+Index zero accesses the first function in the list."
+  :type 'integer
+  :group 'supercite)
 
-(defvar sc-reference-tag-string ">>>>> "
-  "*String used at the beginning of built-in reference headers.")
+(defcustom sc-reference-tag-string ">>>>> "
+  "*String used at the beginning of built-in reference headers."
+  :type 'string
+  :group 'supercite)
 
-(defvar sc-rewrite-header-list
+(defcustom sc-rewrite-header-list
   '((sc-no-header)
     (sc-header-on-said)
     (sc-header-inarticle-writes)
@@ -336,24 +478,31 @@ Index zero accesses the first function in the list.")
   "*List of reference header rewrite functions.
 The variable `sc-preferred-header-style' controls which function in
 this list is chosen for automatic reference header insertions.
-Electric reference mode will cycle through this list of functions.")
+Electric reference mode will cycle through this list of functions."
+  :type '(repeat sexp)
+  :group 'supercite)
 
-(defvar sc-titlecue-regexp "\\s +-+\\s +"
+(defcustom sc-titlecue-regexp "\\s +-+\\s +"
   "*Regular expression describing the separator between names and titles.
-Set to nil to treat entire field as a name.")
+Set to nil to treat entire field as a name."
+  :type '(choice (const :tag "entire field as name" nil)
+                regexp)
+  :group 'supercite-attr)
 
-(defvar sc-use-only-preference-p nil
+(defcustom sc-use-only-preference-p nil
   "*Controls what happens when the preferred attribution cannot be found.
 If non-nil, then `sc-default-attribution' will be used.  If nil, then
 some secondary scheme will be employed to find a suitable attribution
-string.")
+string."
+  :type 'boolean
+  :group 'supercite-attr)
 
 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ;; end user configuration variables
 \f
 (defconst sc-version "3.1"
   "Supercite version number.")
-(defconst sc-help-address "supercite-help@anthem.nlm.nih.gov"
+(defconst sc-help-address "bug-supercite@gnu.org"
   "Address accepting submissions of bug reports.")
 
 (defvar sc-mail-info nil
@@ -364,7 +513,8 @@ string.")
 (defconst sc-emacs-features
   (let ((version 'v18)
        (flavor  'GNU))
-    (if (string= (substring emacs-version 0 2) "19")
+    (if (not
+        (string= (substring emacs-version 0 2) "18"))
        (setq version 'v19))
     (if (string-match "Lucid" emacs-version)
        (setq flavor 'Lucid))
@@ -373,9 +523,9 @@ string.")
   "A list describing what version of Emacs we're running on.
 Known flavors are:
 
-All GNU18's: (v18 GNU)
-FSF19.x    : (v19 GNU)
-Lucid19.x  : (v19 Lucid)")
+Emacs 18           : (v18 GNU)
+Emacs 19 or later  : (v19 GNU)
+Lucid 19 or later  : (v19 Lucid)")
 
 
 (defvar sc-tmp-nested-regexp nil
@@ -462,6 +612,8 @@ If this is nil, Supercite keymap is not installed.")
   (define-key sc-electric-mode-map "g"    'sc-eref-goto)
   (define-key sc-electric-mode-map "?"    'describe-mode)
   (define-key sc-electric-mode-map "\C-h" 'describe-mode)
+  (define-key sc-electric-mode-map [f1]   'describe-mode)
+  (define-key sc-electric-mode-map [help] 'describe-mode)
   )
 
 (defvar sc-minibuffer-local-completion-map nil
@@ -499,30 +651,40 @@ In version 18, the HISTORY argument is ignored."
   "Compatibility between Emacs 18 and 19 `read-string'.
 In version 18, the HISTORY argument is ignored."
   (if (memq 'v19 sc-emacs-features)
-      ;; maybe future versions will take a `history' argument:
-      (read-string prompt initial-contents)
+      (read-string prompt initial-contents history)
     (read-string prompt initial-contents)))
 
-(defun sc-submatch (matchnum &optional string)
-  "Returns `match-beginning' and `match-end' sub-expression for MATCHNUM.
+(if (fboundp 'match-string)
+    (defalias 'sc-submatch 'match-string)
+  (defun sc-submatch (matchnum &optional string)
+    "Returns `match-beginning' and `match-end' sub-expression for MATCHNUM.
 If optional STRING is provided, take sub-expression using `substring'
 of argument, otherwise use `buffer-substring' on current buffer.  Note
 that `match-data' must have already been generated and no error
 checking is performed by this function."
-  (if string
-      (substring string (match-beginning matchnum) (match-end matchnum))
-    (buffer-substring (match-beginning matchnum) (match-end matchnum))))
-
-(defun sc-member (elt list)
-  "Like `memq', but uses `equal' instead of `eq'.
+    (if string
+       (substring string (match-beginning matchnum) (match-end matchnum))
+      (buffer-substring (match-beginning matchnum) (match-end matchnum)))))
+
+(if (fboundp 'member)
+    (defalias 'sc-member 'member)
+  (defun sc-member (elt list)
+    "Like `memq', but uses `equal' instead of `eq'.
 Emacs19 has a builtin function `member' which does exactly this."
-  (catch 'elt-is-member
-    (while list
-      (if (equal elt (car list))
-         (throw 'elt-is-member list))
-      (setq list (cdr list)))))
-(and (memq 'v19 sc-emacs-features)
-     (fset 'sc-member 'member))
+    (catch 'elt-is-member
+      (while list
+       (if (equal elt (car list))
+           (throw 'elt-is-member list))
+       (setq list (cdr list))))))
+
+;; One day maybe Emacs will have this...
+(if (fboundp 'string-text)
+    (defalias 'sc-string-text 'string-text)
+  (defun sc-string-text (string)
+    "Return STRING with all text properties removed."
+    (let ((string (copy-sequence string)))
+      (set-text-properties 0 (length string) nil string)
+      string)))
 
 (defun sc-ask (alist)
   "Ask a question in the minibuffer requiring a single character answer.
@@ -555,7 +717,7 @@ the list should be unique."
              (setq event (read-char)))
             ((memq 'Lucid sc-emacs-features)
              (next-command-event event))
-            (t                         ; must be FSF19
+            (t                         ; must be Emacs 19
              (setq event (read-event))))
            (prog1 quit-flag (setq quit-flag nil)))
          (progn
@@ -639,14 +801,16 @@ the list should be unique."
     (end                          (setq sc-mail-headers-end (point))))
   "Regi frame for glomming mail header information.")
 
+(eval-when-compile (defvar curline))   ; dynamic bondage
+
 ;; regi functions
 (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
 `sc-attributions' too."
   (if (string-match "^\\(\\S *\\)\\s *:\\s +\\(.*\\)$" curline)
-      (let* ((key (downcase (sc-submatch 1 curline)))
-            (val (sc-submatch 2 curline))
+      (let* ((key (downcase (sc-string-text (sc-submatch 1 curline))))
+            (val (sc-string-text (sc-submatch 2 curline)))
             (keyval (cons key val)))
        (setq sc-mail-info (cons keyval sc-mail-info))
        (if attribs-p
@@ -658,7 +822,8 @@ If optional ATTRIBS-P is non-nil, the key/value pair is placed in
   "Append a continuation line onto the last fetched mail field's info."
   (let ((keyval (car sc-mail-info)))
     (if (and keyval (string-match "^\\s *\\(.*\\)$" curline))
-       (setcdr keyval (concat (cdr keyval) " " (sc-submatch 1 curline)))))
+       (setcdr keyval (concat (cdr keyval) " "
+                              (sc-string-text (sc-submatch 1 curline))))))
   nil)
 
 (defun sc-mail-error-in-mail-field ()
@@ -848,7 +1013,7 @@ AUTHOR is the author's name (which is removed from the address)."
                   (= (aref address (1- (length address))) ?>))
              (substring address 1 (1- (length address)))
            address))
-      (if (string-match "[-a-zA-Z0-9!@%._]+" from 0)
+      (if (string-match "[-[:alnum:]!@%._]+" from 0)
          (sc-submatch 0 from)
        "")
       )))
@@ -879,12 +1044,23 @@ substring."
 This should be the author's full name minus an optional title."
   (let ((namestring
         (or
+         ;; If there is a <...> in the name,
+         ;; treat everything before that as the full name.
+         ;; Even if it contains parens, use the whole thing.
+         ;; On the other hand, we do look for quotes in the usual way.
+         (and (string-match " *<.*>" from 0)
+              (let ((before-angles
+                     (sc-name-substring from 0 (match-beginning 0) 0)))
+                (if (string-match "\".*\"" before-angles 0)
+                    (sc-name-substring
+                     before-angles (match-beginning 0) (match-end 0) 1)
+                  before-angles)))
          (sc-name-substring
           from (string-match "(.*)" from 0) (match-end 0) 1)
          (sc-name-substring
           from (string-match "\".*\"" from 0) (match-end 0) 1)
          (sc-name-substring
-          from (string-match "\\([-.a-zA-Z0-9_]+\\s +\\)+<" from 0)
+          from (string-match "\\([-.[:alnum:]_]+\\s +\\)+<" from 0)
           (match-end 1) 0)
          (sc-attribs-emailname from))))
     ;; strip off any leading or trailing whitespace
@@ -1146,18 +1322,20 @@ to the auto-selected attribution string."
          (setq sc-attrib-or-cite nil)  ; nil==attribution, t==citation
          (while
              (catch 'sc-reconfirm
-               (string= "" (setq choice
-                                 (if sc-attrib-or-cite
-                                     (sc-read-string
-                                      "Enter citation prefix: "
-                                      citation
-                                      'sc-citation-confirmation-history)
-                                   (sc-completing-read
-                                    "Complete attribution name: "
-                                    query-alist nil nil
-                                    (cons initial 0)
-                                    'sc-attribution-confirmation-history)
-                                   )))))
+               (progn
+                 (setq choice
+                       (if sc-attrib-or-cite
+                           (sc-read-string
+                            "Enter citation prefix: "
+                            citation
+                            'sc-citation-confirmation-history)
+                         (sc-completing-read
+                          "Complete attribution name: "
+                          query-alist nil nil
+                          (cons initial 0)
+                          'sc-attribution-confirmation-history)
+                         ))
+                 nil)))
          (if sc-attrib-or-cite
              ;; since the citation was chosen, we have to guess at
              ;; the attribution
@@ -1301,7 +1479,7 @@ buffer."
      nesting)))
 
 (defun sc-add-citation-level ()
-  "Add a citation level for nested citation style w/ coersion."
+  "Add a citation level for nested citation style w/ coercion."
   (let* ((nesting (sc-guess-nesting))
         (citation (make-string (1+ (length nesting))
                                (string-to-char sc-citation-delimiter)))
@@ -1403,11 +1581,11 @@ non-nil."
   ())
 
 (defun sc-no-blank-line-or-header()
-  "Similar to `sc-no-header' except it removes the preceeding blank line."
+  "Similar to `sc-no-header' except it removes the preceding blank line."
   (if (not (bobp))
       (if (and (eolp)
               (progn (forward-line -1)
-                     (or (looking-at mail-header-separator)
+                     (or (= (point) (mail-header-end))
                          (and (eq major-mode 'mh-letter-mode)
                               (mh-in-header-p)))))
          (progn (forward-line)
@@ -1686,15 +1864,15 @@ entered, regardless of the value of `sc-electric-references-p'.  See
   (setq sc-fixup-whitespace-p (not sc-fixup-whitespace-p)
        sc-auto-fill-region-p (not sc-auto-fill-region-p))
   (sc-set-mode-string)
-  (set-buffer-modified-p (buffer-modified-p)))
+  (force-mode-line-update))
 
 (defun sc-toggle-var (variable)
   "Boolean toggle VARIABLE's value.
-VARIABLE must be a bound symbol.  Nil values change to t, non-nil
+VARIABLE must be a bound symbol.  nil values change to t, non-nil
 values are changed to nil."
   (message "%s changed from %s to %s"
           variable (symbol-value variable)
-          (set-variable variable (not (eval-expression variable))))
+          (set variable (not (symbol-value variable))))
   (sc-set-mode-string))
 
 (defun sc-set-variable (var)
@@ -1725,6 +1903,9 @@ help window."
                                  var
                                  'variable-documentation)
                                  1))
+              (save-excursion
+                (set-buffer standard-output)
+                (help-mode))
               nil)))))
     (set var (eval-minibuffer (format "Set %s to value: " var))))
   (sc-set-mode-string))
@@ -1836,7 +2017,7 @@ before, and `sc-post-hook' is run after the guts of this function."
   ;; this function gets automatically called. we want point to be a
   ;; mark so any deleting before point works properly
   (let* ((zmacs-regions nil)           ; for Lemacs
-        (mark-active t)                ; for FSFmacs
+        (mark-active t)                ; for Emacs
         (point (point-marker))
         (mark  (copy-marker (mark-marker))))
   
@@ -1918,7 +2099,7 @@ cited."
            (looking-at "^[ \t]*$")
            (consp arg))
        (insert (sc-mail-field "sc-citation"))
-      (error "Line is already cited."))))
+      (error "Line is already cited"))))
 
 (defun sc-version (arg)
   "Echo the current version of Supercite in the minibuffer.