07041212f7782a2036c3cef97db2d2e96713e800
[syinit] / 15-supercite-sy.el
1 ;; 15-supercite-sy.el --- Mail citing Settings   -*- Emacs-Lisp -*-
2
3 ;; Copyright (C) 2007 - 2012 Steve Youngs
4
5 ;;     Author: Steve Youngs <steve@sxemacs.org>
6 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
7 ;;    Created: <2007-12-02>
8 ;; Time-stamp: <Sunday Jun 10, 2012 11:00:07 steve>
9 ;;   Download: <http://bastard.steveyoungs.com/~steve/SXEmacs/inits/>
10 ;;   HTMLised: <http://bastard.steveyoungs.com/~steve/SXEmacs/htmlinits/15-supercite-sy.html>
11 ;;   Git Repo: git clone http://git.sxemacs.org/syinit
12 ;;   Keywords: init, compile
13
14 ;; This file is part of SYinit
15
16 ;; Redistribution and use in source and binary forms, with or without
17 ;; modification, are permitted provided that the following conditions
18 ;; are met:
19 ;;
20 ;; 1. Redistributions of source code must retain the above copyright
21 ;;    notice, this list of conditions and the following disclaimer.
22 ;;
23 ;; 2. Redistributions in binary form must reproduce the above copyright
24 ;;    notice, this list of conditions and the following disclaimer in the
25 ;;    documentation and/or other materials provided with the distribution.
26 ;;
27 ;; 3. Neither the name of the author nor the names of any contributors
28 ;;    may be used to endorse or promote products derived from this
29 ;;    software without specific prior written permission.
30 ;;
31 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
32 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 ;; DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
38 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
40 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
41 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 ;;; Commentary:
44 ;;
45 ;;   Setting up citing in Gnus with Supercite.
46 ;;
47
48 ;;; Credits:
49 ;;
50 ;;   The HTML version of this file was created with Hrvoje Niksic's
51 ;;   htmlize.el which is part of the XEmacs "text-modes" package.
52 ;;
53
54 ;;; Todo:
55 ;;
56 ;;     
57
58 ;;; Code:
59 (require 'supercite)
60 (require 'time-date)
61
62 (defun sy-september-citation-line ()
63   (let ((sc-mumble "")
64         (whofrom (sc-whofrom)))
65     (if whofrom
66         (insert sc-reference-tag-string
67                 (sc-hdr "On "
68                         (int-to-string
69                          (-
70                           (time-to-days (mail-header-parse-date
71                                          (sc-mail-field "date")))
72                           (time-to-days (encode-time 0 0 0 01 09 1993))))
73                         " September 1993, ")
74                 (sc-mail-field "sc-author")
75                 " wrote:\n"))))
76
77 (setq sc-rewrite-header-list 
78       '((sc-no-header) 
79         (sc-header-on-said) 
80         (sc-header-inarticle-writes) 
81         (sc-header-regarding-adds) 
82         (sc-header-attributed-writes) 
83         (sc-header-author-writes) 
84         (sc-header-verbose) 
85         (sc-no-blank-line-or-header)
86         (sc-header-author-email-writes)
87         (sy-september-citation-line)))
88
89 (setq sc-preferred-attribution-list
90       (list
91        '"sc-lastchoice"
92        "x-attribution"
93        "sc-consult"
94        "initials"
95        "firstname"
96        "emailname" 
97        "lastname"))
98
99 (setq 
100  message-cite-function 'sc-cite-original
101  sc-confirm-always-p nil
102  sc-preferred-header-style 8
103  sc-auto-fill-region-p nil
104  sc-fixup-whitespace-p nil
105  sc-electric-references-p t
106  sc-cite-blank-lines-p nil
107  sc-nested-citation-p t
108  sc-citation-leader "  "
109  sc-citation-separator " "
110  sc-reference-tag-string "* "
111  sc-citation-delimiter "> "
112  sc-extract-address-components 'gnus-extract-address-components)
113
114 (defun sy-sc-remove-signature ()
115   "Removes the signature from the original message.
116
117 To use, hang it off the appropriate hook such as `sc-pre-hook' so
118 you're not citing useless stuff."
119   (save-excursion
120     (let ((start (point))
121           (end (mark t))
122           (sig-sep gnus-signature-separator)
123           mark)
124       (while sig-sep
125         (goto-char end)
126         (when (re-search-backward (car sig-sep) start t)
127           (forward-line -1)
128           (while (looking-at "[ \t]*$")
129             (forward-line -1))
130           (forward-line 1)
131           (setq mark (set-marker (make-marker) (point)))
132           (delete-region mark (mark t)))
133         (setq sig-sep (cdr sig-sep))))))
134
135 (add-hook 'sc-load-hook 'sc-setup-filladapt)
136 (add-hook 'sc-pre-hook 'sy-sc-remove-signature)
137 (add-hook 'mail-citation-hook 'sc-cite-original)
138
139 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
140 (message "Supercite settings loaded successfully")
141