;; 15-supercite.el --- Mail citing Settings

;; Copyright (C) 2007 - 2020 Steve Youngs

;;     Author: Steve Youngs <steve@sxemacs.org>
;; Maintainer: Steve Youngs <steve@sxemacs.org>
;;    Created: <2007-12-02>
;; Time-stamp: <Thursday Apr  9, 2020 19:00:53 steve>
;;   Download: <https://downloads.sxemacs.org/SYinits>
;;   HTMLised: <https://www.sxemacs.org/SYinits/15-supercite.html>
;;   Git Repo: git clone https://git.sxemacs.org/syinit
;;   Keywords: init, compile

;; This file is part of SYinit

;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;; 1. Redistributions of source code must retain the above copyright
;;    notice, this list of conditions and the following disclaimer.
;;
;; 2. Redistributions in binary form must reproduce the above copyright
;;    notice, this list of conditions and the following disclaimer in the
;;    documentation and/or other materials provided with the distribution.
;;
;; 3. Neither the name of the author nor the names of any contributors
;;    may be used to endorse or promote products derived from this
;;    software without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

;;; Commentary:
;;
;;   Setting up citing in Gnus with Supercite.
;;

;;; Credits:
;;
;;   The HTML version of this file was created with Hrvoje Niksic's
;;   htmlize.el which is part of the XEmacs "text-modes" package.
;;

;;; Todo:
;;
;;     

;;; Code:
(require 'supercite)
(require 'time-date)
;; Warning: This triggers a bug that has been fixed in an as yet to be
;; released SXEmacs Gnus package.  Sorry.  I will get the packages out
;; as soon as I can.  This was as of: [2020-04-09]
(defun sy-september-citation-line ()
  (let ((sc-mumble "")
        (whofrom (sc-whofrom)))
    (when whofrom
      (insert
       sc-reference-tag-string
       (sc-hdr "On "
               (int-to-string
                (- (time-to-days (mail-header-parse-date
                                  (sc-mail-field "date")))
                   (time-to-days (encode-time 0 0 0 01 09 1993))))
               " September 1993, ")
       (sc-mail-field "sc-author")
       " wrote:\n"))))

(setq sc-rewrite-header-list 
      '((sc-no-header) 
        (sc-header-on-said) 
        (sc-header-inarticle-writes) 
        (sc-header-regarding-adds) 
        (sc-header-attributed-writes) 
        (sc-header-author-writes) 
        (sc-header-verbose) 
        (sc-no-blank-line-or-header)
        (sc-header-author-email-writes)
        (sy-september-citation-line)))

(setq sc-preferred-attribution-list
      '("sc-lastchoice"
        "x-attribution"
        "sc-consult"
        "initials"
        "firstname"
        "emailname"
        "lastname"))

(setq 
 message-cite-function 'sc-cite-original
 sc-confirm-always-p nil
 sc-preferred-header-style 4
 sc-auto-fill-region-p t
 sc-fixup-whitespace-p t
 sc-electric-references-p t
 sc-cite-blank-lines-p nil
 sc-nested-citation-p nil
 sc-citation-separator " "
 sc-reference-tag-string "|--> "
 sc-citation-delimiter ">"
 sc-extract-address-components 'gnus-extract-address-components)

(defun sy-sc-remove-signature ()
  "Removes the signature from the original message.

To use, hang it off the appropriate hook such as `sc-pre-hook' so
you're not citing useless stuff."
  (save-excursion
    (let ((start (point))
          (end (mark t))
          (sig-sep gnus-signature-separator)
          mark)
      (while sig-sep
        (goto-char end)
        (when (re-search-backward (car sig-sep) start t)
          (forward-line -1)
          (while (looking-at "[ \t]*$")
            (forward-line -1))
          (forward-line 1)
          (setq mark (set-marker (make-marker) (point)))
          (delete-region mark (mark t)))
        (setq sig-sep (cdr sig-sep))))))

(add-hook 'sc-load-hook 'sc-setup-filladapt)
(add-hook 'sc-pre-hook 'sy-sc-remove-signature)
(add-hook 'mail-citation-hook 'sc-cite-original)

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
(message "Supercite settings loaded successfully")

Created with SXEmacs Valid XHTML 1.0 Transitional!
Copyright © 2020 Steve Youngs
Verbatim copying and distribution is permitted in any medium, providing this notice is preserved.
Last modified: Wed Apr 15 18:15:32 AEST 2020