]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/supercite.el
Update copyright years.
[gnu-emacs] / lisp / mail / supercite.el
index 0afab79e4fa57d46dfc64f8be5076d743cdb3ade..f7beef054b0511a084517ed82aafa1fa5fb29538 100644 (file)
@@ -1,9 +1,10 @@
 ;;; 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 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
@@ -24,8 +25,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 +147,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 +163,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 +172,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 +218,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 +229,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 +246,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 +354,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
@@ -426,6 +434,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 +490,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.
@@ -633,8 +643,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 +659,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 +670,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 +721,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 +806,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 +848,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 +926,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))) ?>))
@@ -1173,8 +1184,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 +1318,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,12 +1450,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
-                   (if (symbolp sc-cite-frame-alist)
-                       (symbol-value sc-cite-frame-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))
@@ -1450,11 +1465,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
-                   (if (symbolp sc-uncite-frame-alist)
-                       (symbol-value sc-uncite-frame-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)))
 
@@ -1465,11 +1479,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
-                   (if (symbolp sc-recite-frame-alist)
-                       (symbol-value sc-recite-frame-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)))
 
@@ -1504,7 +1517,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))))))
@@ -1661,7 +1675,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)
          )))
 
@@ -1868,10 +1882,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 ()
@@ -2056,5 +2071,5 @@ more information.  Info node `(SC)Top'."
 (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