(sc-version): Use emacs-version rather than sc-version.
[bpt/emacs.git] / lisp / mail / supercite.el
index 0f59250..c0e581c 100644 (file)
@@ -1,20 +1,18 @@
 ;;; supercite.el --- minor mode for citing mail and news replies
 
-;; Copyright (C) 1993, 1997, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1997, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: 1993 Barry A. Warsaw <bwarsaw@python.org>
-;; Maintainer:    FSF
+;; Maintainer:    Glenn Morris <rgm@gnu.org>
 ;; Created:       February 1993
-;; Last Modified: 1993/09/22 18:58:46
 ;; Keywords: mail, news
 
-;; supercite.el revision: 3.54
-
 ;; This file is part of GNU Emacs.
 
 ;; 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,
@@ -24,8 +22,8 @@
 
 ;; 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, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;; LCD Archive Entry
 ;; supercite|Barry A. Warsaw|supercite-help@python.org
 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 
 (defgroup supercite nil
-  "Supercite package"
+  "Supercite package."
   :prefix "sc-"
   :group 'mail
   :group 'news)
 
 (defgroup supercite-frames nil
-  "Supercite (regi) frames"
+  "Supercite (regi) frames."
   :prefix "sc-"
   :group 'supercite)
 
 (defgroup supercite-attr nil
-  "Supercite attributions"
+  "Supercite attributions."
   :prefix "sc-"
   :group 'supercite)
 
 (defgroup supercite-cite nil
-  "Supercite citings"
+  "Supercite citings."
   :prefix "sc-"
   :group 'supercite)
 
 (defgroup supercite-hooks nil
-  "Hooking into supercite"
+  "Hooking into supercite."
   :prefix "sc-"
   :group 'supercite)
 
@@ -146,12 +144,14 @@ Each element of this list has the following form:
              (...)))
 
 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."
+expression to match against the INFOKEY's value.  FRAME is
+a citation frame, or a symbol that represents the name of
+a variable whose value is a citation frame."
   :type '(repeat (list symbol (repeat (cons regexp
                                            (choice (repeat (repeat sexp))
                                                    symbol)))))
   :group 'supercite-frames)
+(put 'sc-cite-frame-alist 'risky-local-variable t)
 
 (defcustom sc-uncite-frame-alist '()
   "*Alist for frame selection during unciting.
@@ -160,6 +160,7 @@ See the variable `sc-cite-frame-alist' for details."
                                            (choice (repeat (repeat sexp))
                                                    symbol)))))
   :group 'supercite-frames)
+(put 'sc-uncite-frame-alist 'risky-local-variable t)
 
 (defcustom sc-recite-frame-alist '()
   "*Alist for frame selection during reciting.
@@ -168,6 +169,7 @@ See the variable `sc-cite-frame-alist' for details."
                                            (choice (repeat (repeat sexp))
                                                    symbol)))))
   :group 'supercite-frames)
+(put 'sc-recite-frame-alist 'risky-local-variable t)
 
 (defcustom sc-default-cite-frame
   '(;; initialize fill state and temporary variables when entering
@@ -213,6 +215,7 @@ See the variable `sc-cite-frame-alist' for details."
   "*Default REGI frame for citing a region."
   :type '(repeat (repeat sexp))
   :group 'supercite-frames)
+(put 'sc-default-cite-frame 'risky-local-variable t)
 
 (defcustom sc-default-uncite-frame
   '(;; do nothing on a blank line
@@ -223,6 +226,7 @@ See the variable `sc-cite-frame-alist' for details."
   "*Default REGI frame for unciting a region."
   :type '(repeat (repeat sexp))
   :group 'supercite-frames)
+(put 'sc-default-uncite-frame 'risky-local-variable t)
 
 (defcustom sc-default-recite-frame
   '(;; initialize fill state when entering frame
@@ -239,10 +243,11 @@ See the variable `sc-cite-frame-alist' for details."
   "*Default REGI frame for reciting a region."
   :type '(repeat (repeat sexp))
   :group 'supercite-frames)
+(put 'sc-default-recite-frame 'risky-local-variable t)
 
 (defcustom sc-cite-region-limit t
   "*This variable controls automatic citation of yanked text.
-Legal values are:
+Valid values are:
 
 non-nil   -- cite the entire region, regardless of its size
 nil       -- do not cite the region at all
@@ -346,7 +351,7 @@ Non-nil uses nested citations, nil uses non-nested citations."
 
 (defcustom sc-nuke-mail-headers 'all
   "*Controls mail header nuking.
-Used in conjunction with `sc-nuke-mail-header-list'.  Legal values are:
+Used in conjunction with `sc-nuke-mail-header-list'.  Valid values are:
 
 `all'       -- nuke all mail headers
 `none'      -- don't nuke any mail headers
@@ -414,8 +419,8 @@ Each element of this list has the following form:
              (...)))
 
 Where INFOKEY is a key for `sc-mail-field', REGEXP is a regular
-expression to match against the INFOKEY's value. ATTRIBUTION can be a
-string or a list.  If its a string, then it is the attribution that is
+expression to match against the INFOKEY's value.  ATTRIBUTION can be a
+string or a list.  If it's a string, then it is the attribution that is
 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'
@@ -426,6 +431,7 @@ to be consulted during attribution selection."
                                     (choice (sexp :tag "List to eval")
                                             string)))))
   :group 'supercite-attr)
+(put 'sc-attrib-selection-list 'risky-local-variable t)
 
 (defcustom sc-attribs-preselect-hook nil
   "*Hook to run before selecting an attribution."
@@ -481,6 +487,7 @@ this list is chosen for automatic reference header insertions.
 Electric reference mode will cycle through this list of functions."
   :type '(repeat sexp)
   :group 'supercite)
+(put 'sc-rewrite-header-list 'risky-local-variable t)
 
 (defcustom sc-titlecue-regexp "\\s +-+\\s +"
   "*Regular expression describing the separator between names and titles.
@@ -500,10 +507,7 @@ string."
 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ;; end user configuration variables
 \f
-(defconst sc-version "3.1"
-  "Supercite version number.")
-(defconst sc-help-address "bug-supercite@gnu.org"
-  "Address accepting submissions of bug reports.")
+(define-obsolete-variable-alias 'sc-version 'emacs-version "23.1")
 
 (defvar sc-mail-info nil
   "Alist of mail header information gleaned from reply buffer.")
@@ -633,8 +637,8 @@ the list should be unique."
            (prog1 quit-flag (setq quit-flag nil)))
          (progn
            (message "%s%s" p (single-key-description event))
-           (and (fboundp 'deallocate-event)
-                (deallocate-event event))
+           (if (fboundp 'deallocate-event)
+               (deallocate-event event))
            (setq quit-flag nil)
            (signal 'quit '())))
       (let ((char
@@ -649,8 +653,8 @@ the list should be unique."
         ((setq elt (rassq char alist))
          (message "%s%s" p (car elt))
          (setq p (cdr elt)))
-        ((and (fboundp 'button-release-event-p)
-              (button-release-event-p event)) ; ignore them
+        ((if (fboundp 'button-release-event-p)
+             (button-release-event-p event)) ; ignore them
          nil)
         (t
          (message "%s%s" p (single-key-description event))
@@ -660,8 +664,8 @@ the list should be unique."
          (discard-input)
          (if (eq p prompt)
              (setq p (concat "Try again.  " prompt)))))))
-    (and (fboundp 'deallocate-event)
-        (deallocate-event event))
+    (if (fboundp 'deallocate-event)
+       (deallocate-event event))
     p))
 
 (defun sc-scan-info-alist (alist)
@@ -711,6 +715,7 @@ the list should be unique."
     (sc-mail-warn-if-non-rfc822-p (sc-mail-error-in-mail-field))
     (end                          (setq sc-mail-headers-end (point))))
   "Regi frame for glomming mail header information.")
+(put 'sc-mail-glom-frame 'risky-local-variable t)
 
 (defvar curline)                       ; dynamic bondage
 
@@ -795,7 +800,7 @@ The number of lines left is specified by `sc-blank-lines-after-headers'."
            nonentry-func '(sc-mail-nuke-header-line)))
      ;; we never get far enough to interpret a frame if s-n-m-h == 'none
      ((eq sc-nuke-mail-headers 'none))
-     (t (error "Illegal value for sc-nuke-mail-headers: %s"
+     (t (error "Invalid value for sc-nuke-mail-headers: %s"
               sc-nuke-mail-headers))
      )                                 ; end-cond
     (append
@@ -837,7 +842,7 @@ error occurs."
   "Return the mail header field value associated with FIELD.
 If there was no mail header with FIELD as its key, return the value of
 `sc-mumble'.  FIELD is case insensitive."
-  (or (cdr (assoc (downcase field) sc-mail-info)) sc-mumble))
+  (or (cdr (assoc-string field sc-mail-info 'case-fold)) sc-mumble))
 
 (defun sc-mail-field-query (arg)
   "View the value of a mail field.
@@ -915,8 +920,8 @@ Match addresses of the style ``<name[stuff]>.''"
   "Get the full email address path from FROM.
 AUTHOR is the author's name (which is removed from the address)."
   (let ((eos (length from)))
-    (if (string-match (concat "\\(^\\|^\"\\)" author
-                             "\\(\\s +\\|\"\\s +\\)") from 0)
+    (if (string-match (concat "\\`\"?" (regexp-quote author)
+                             "\"?\\s +") from 0)
        (let ((address (substring from (match-end 0) eos)))
          (if (and (= (aref address 0) ?<)
                   (= (aref address (1- (length address))) ?>))
@@ -1027,12 +1032,12 @@ supplied, is used instead of the line point is on in the current buffer."
   (let ((elements (length namelist))
        (position -1)
        keepers filtered-list)
-    (mapcar
+    (mapc
      (function
       (lambda (name)
        (setq position (1+ position))
        (let ((keep-p t))
-         (mapcar
+         (mapc
           (function
            (lambda (filter)
              (let ((regexp (car filter))
@@ -1050,7 +1055,7 @@ supplied, is used instead of the line point is on in the current buffer."
              (setq keepers (cons position keepers)))
          )))
      namelist)
-    (mapcar
+    (mapc
      (function
       (lambda (position)
        (setq filtered-list (cons (nth position namelist) filtered-list))
@@ -1173,8 +1178,11 @@ to the auto-selected attribution string."
              (setq attribution attrib
                    attriblist nil))
             ((listp attrib)
-             (setq attribution (eval attrib)
-                   attriblist nil))
+             (setq attribution (eval attrib))
+              (if (stringp attribution)
+                  (setq attriblist nil)
+                (setq attribution nil
+                      attriblist (cdr attriblist))))
             (t (error "%s did not evaluate to a string or list!"
                       "sc-attrib-selection-list"))
             )))
@@ -1304,6 +1312,8 @@ use it instead of `sc-citation-root-regexp'."
          sc-citation-delimiter
          sc-citation-separator))
 
+(defvar filladapt-prefix-table)
+
 (defun sc-setup-filladapt ()
   "Setup `filladapt-prefix-table' to handle Supercited paragraphs."
   (let* ((fa-sc-elt 'filladapt-supercite-included-text)
@@ -1434,9 +1444,11 @@ When called interactively, the optional arg INTERACTIVE is non-nil,
 and that means call `sc-select-attribution' too."
   (interactive "r\nP\np")
   (undo-boundary)
-  (let ((frame (or (sc-scan-info-alist sc-cite-frame-alist)
-                  sc-default-cite-frame))
+  (let ((frame (sc-scan-info-alist sc-cite-frame-alist))
        (sc-confirm-always-p (if confirm-p t sc-confirm-always-p)))
+    (if (and frame (symbolp frame))
+       (setq frame (symbol-value frame)))
+    (or frame (setq frame sc-default-cite-frame))
     (run-hooks 'sc-pre-cite-hook)
     (if interactive
        (sc-select-attribution))
@@ -1447,8 +1459,10 @@ and that means call `sc-select-attribution' too."
 First runs `sc-pre-uncite-hook'."
   (interactive "r")
   (undo-boundary)
-  (let ((frame (or (sc-scan-info-alist sc-uncite-frame-alist)
-                  sc-default-uncite-frame)))
+  (let ((frame (sc-scan-info-alist sc-uncite-frame-alist)))
+    (if (and frame (symbolp frame))
+       (setq frame (symbol-value frame)))
+    (or frame (setq frame sc-default-uncite-frame))
     (run-hooks 'sc-pre-uncite-hook)
     (regi-interpret frame start end)))
 
@@ -1459,8 +1473,10 @@ First runs `sc-pre-recite-hook'."
   (let ((sc-confirm-always-p t))
     (sc-select-attribution))
   (undo-boundary)
-  (let ((frame (or (sc-scan-info-alist sc-recite-frame-alist)
-                  sc-default-recite-frame)))
+  (let ((frame (sc-scan-info-alist sc-recite-frame-alist)))
+    (if (and frame (symbolp frame))
+       (setq frame (symbol-value frame)))
+    (or frame (setq frame sc-default-recite-frame))
     (run-hooks 'sc-pre-recite-hook)
     (regi-interpret frame start end)))
 
@@ -1495,7 +1511,8 @@ non-nil."
               (progn (forward-line -1)
                      (or (= (point) (mail-header-end))
                          (and (eq major-mode 'mh-letter-mode)
-                              (mh-in-header-p)))))
+                              (with-no-warnings
+                                (mh-in-header-p))))))
          (progn (forward-line)
                 (let ((kill-lines-magic t))
                   (kill-line))))))
@@ -1652,7 +1669,7 @@ header style to use, unless not supplied or invalid, in which case
              (major-mode 'sc-electric-mode))
          (use-local-map sc-electric-mode-map)
          (sc-eref-show sc-eref-style)
-         (run-hooks 'sc-electric-mode-hook)
+         (run-mode-hooks 'sc-electric-mode-hook)
          (recursive-edit)
          )))
 
@@ -1859,10 +1876,11 @@ Note on function names in this list: all functions of the form
 
 (define-minor-mode sc-minor-mode
   "Supercite minor mode."
-  nil (" SC" (sc-auto-fill-region-p
-             (":f" (sc-fixup-whitespace-p "w"))
-             (sc-fixup-whitespace-p ":w")))
-  `((,sc-mode-map-prefix . ,sc-mode-map)))
+  :group 'supercite
+  :lighter (" SC" (sc-auto-fill-region-p
+                  (":f" (sc-fixup-whitespace-p "w"))
+                  (sc-fixup-whitespace-p ":w")))
+  :keymap `((,sc-mode-map-prefix . ,sc-mode-map)))
 
 ;;;###autoload
 (defun sc-cite-original ()
@@ -1986,7 +2004,7 @@ cited."
 If MESSAGE is non-nil (interactively, with no prefix argument),
 inserts the version string in the current buffer instead."
   (interactive (not current-prefix-arg))
-  (let ((verstr (format "Using Supercite.el %s" sc-version)))
+  (let ((verstr (format "Using Supercite.el %s" emacs-version)))
     (if message
        (message verstr)
       (insert "`sc-version' says: " verstr))))
@@ -1999,53 +2017,12 @@ more information.  Info node `(SC)Top'."
   (interactive)
   (describe-function 'sc-describe))
 
-(defun sc-submit-bug-report ()
-  "Submit a bug report on Supercite via mail."
-  (interactive)
-  (require 'reporter)
-  (and
-   (y-or-n-p "Do you want to submit a report on Supercite? ")
-   (reporter-submit-bug-report
-    sc-help-address
-    (concat "Supercite version " sc-version)
-    (list
-     'sc-attrib-selection-list
-     'sc-auto-fill-region-p
-     'sc-blank-lines-after-headers
-     'sc-citation-leader
-     'sc-citation-delimiter
-     'sc-citation-separator
-     'sc-citation-leader-regexp
-     'sc-citation-root-regexp
-     'sc-citation-nonnested-root-regexp
-     'sc-citation-delimiter-regexp
-     'sc-citation-separator-regexp
-     'sc-cite-region-limit
-     'sc-confirm-always-p
-     'sc-default-attribution
-     'sc-default-author-name
-     'sc-downcase-p
-     'sc-electric-circular-p
-     'sc-electric-references-p
-     'sc-fixup-whitespace-p
-     'sc-mail-warn-if-non-rfc822-p
-     'sc-mumble
-     'sc-name-filter-alist
-     'sc-nested-citation-p
-     'sc-nuke-mail-headers
-     'sc-nuke-mail-header-list
-     'sc-preferred-attribution-list
-     'sc-preferred-header-style
-     'sc-reference-tag-string
-     'sc-rewrite-header-list
-     'sc-titlecue-regexp
-     'sc-use-only-preference-p
-     ))))
+(define-obsolete-function-alias 'sc-submit-bug-report 'report-emacs-bug "23.1")
 
 \f
 ;; useful stuff
 (provide 'supercite)
 (run-hooks 'sc-load-hook)
 
-;;; arch-tag: a5d5bfa6-3bd5-4414-8c65-0afc83e45cd3
+;; arch-tag: a5d5bfa6-3bd5-4414-8c65-0afc83e45cd3
 ;;; supercite.el ends here