;;; 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-2014 Free Software Foundation, Inc.
;; Author: 1993 Barry A. Warsaw <bwarsaw@python.org>
-;; Maintainer: Glenn Morris <rgm@gnu.org>
-;; Created: February 1993
+;; Maintainer: emacs-devel@gnu.org
+;; Created: February 1993
;; Keywords: mail, news
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; 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, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;; LCD Archive Entry
;; supercite|Barry A. Warsaw|supercite-help@python.org
\f
(require 'regi)
-(require 'sendmail) ;; For mail-header-end.
;; start user configuration variables
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
;; paragraph, unless sc-cite-blank-lines-p is non-nil, in which
;; case we treat blank lines just like any other line.
("^[ \t]*$" (if sc-cite-blank-lines-p
- (sc-cite-line)
+ (if sc-nested-citation-p
+ (sc-add-citation-level)
+ (sc-cite-line))
(sc-fill-if-different "")))
;; do nothing if looking at a reference tag. make sure that the
;; tag string isn't the empty string since this will match every
;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; end user configuration variables
\f
-(define-obsolete-variable-alias 'sc-version 'emacs-version "23.1")
-
(defvar sc-mail-info nil
"Alist of mail header information gleaned from reply buffer.")
(defvar sc-attributions nil
(define-key map "r" 'sc-recite-region)
(define-key map "\C-p" 'sc-raw-mode-toggle)
(define-key map "u" 'sc-uncite-region)
- (define-key map "v" 'sc-version)
(define-key map "w" 'sc-insert-reference)
(define-key map "\C-t" sc-T-keymap)
- (define-key map "\C-b" 'sc-submit-bug-report)
(define-key map "?" 'sc-describe)
map)
"Keymap for Supercite quasi-mode.")
"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)))
(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
"Does nothing. Use this instead of nil to get a blank header."
())
-(defun sc-no-blank-line-or-header()
+(declare-function mh-in-header-p "mh-utils" ())
+
+(defun sc-no-blank-line-or-header ()
"Similar to `sc-no-header' except it removes the preceding blank line."
- (if (not (bobp))
- (if (and (eolp)
- (progn (forward-line -1)
- (or (= (point) (mail-header-end))
- (and (eq major-mode 'mh-letter-mode)
- (with-no-warnings
- (mh-in-header-p))))))
- (progn (forward-line)
- (let ((kill-lines-magic t))
- (kill-line))))))
+ (and (not (bobp))
+ (eolp)
+ (progn (forward-line -1)
+ (or (= (point)
+ (save-excursion
+ (rfc822-goto-eoh)
+ (line-beginning-position 2)))
+ (and (eq major-mode 'mh-letter-mode)
+ (mh-in-header-p))))
+ (progn
+ (forward-line)
+ (kill-line))))
(defun sc-header-on-said ()
"\"On <date>, <from> said:\" unless:
(cadr err) sc-eref-style)
(beep))))))
-(defun sc-electric-mode (&optional arg)
- "
-Mode for viewing Supercite reference headers. Commands are:
+(defun sc-electric-mode (&optional style)
+ "Mode for viewing Supercite reference headers. Commands are:
\n\\{sc-electric-mode-map}
`sc-electric-mode' is not intended to be run interactively, but rather
accessed through Supercite's electric reference feature. See
-`sc-insert-reference' for more details. Optional ARG is the initial
+`sc-insert-reference' for more details. Optional STYLE is the initial
header style to use, unless not supplied or invalid, in which case
`sc-preferred-header-style' is used."
(let ((info sc-mail-info))
(setq sc-eref-style
- (or (sc-valid-index-p arg)
+ (or (sc-valid-index-p style)
(sc-valid-index-p sc-preferred-header-style)
0))
(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."
;; ======================================================================
;; published interface to mail and news readers
-(define-minor-mode sc-minor-mode
- "Supercite minor mode."
+(define-minor-mode sc-minor-mode nil
:group 'supercite
:lighter (" SC" (sc-auto-fill-region-p
(":f" (sc-fixup-whitespace-p "w"))
(insert (sc-mail-field "sc-citation"))
(error "Line is already cited"))))
-(defun sc-version (message)
- "Echo the current version of Supercite in the minibuffer.
-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" emacs-version)))
- (if message
- (message verstr)
- (insert "`sc-version' says: " verstr))))
-
-(make-obsolete 'sc-version 'emacs-version "23.1")
-
(defun sc-describe ()
"Read the Supercite info node."
(interactive)
(info "(SC)top"))
-(make-obsolete 'sc-describe "read the SC manual using `info'." "23.1")
-
-(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
;;; supercite.el ends here