info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: citation line


From: Reiner Steib
Subject: Re: citation line
Date: Thu, 13 May 2004 18:17:13 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux)

On Thu, May 13 2004, Kamen TOMOV wrote:

> Can you tell me how can I write a function that generates line like
> the following when replying?
>
> On Mon, May 10 2004, F_NAME L_NAME wrote:

Here's some code that should get you started.  I use a more
complicated version lot of stuff that you won't need.  I've to cut it
down a little, but there are still some unused variables which I
didn't remove:

--8<---------------cut here---------------start------------->8---
(setq
 rs-message-citation-personal-attribution-line t
 rs-message-citation-use-only-real-name t;
 rs-message-citation-string-on         "On "              ; "On "
 ;; %a=dow, %b=MMM (month), %d=DD (day), %Y=YYYY
 rs-message-citation-string-date-mutt  "%a, %b %d, %Y at %R"
 rs-message-citation-string-date-pine  "%a, %b %d %Y"
 rs-message-citation-string-date rs-message-citation-string-date-pine
 rs-message-citation-string-after-date ", "               ; ", "
 rs-message-citation-string-wrote      " wrote:\n\n"      ; " said:\n\n"
 ;; for private mail:
 rs-message-citation-string-hello      "Hi "              ; "Hi "
 rs-message-citation-name-match        "[^A-z].*$"        ; "[^A-z].*$"
 rs-message-citation-name-replace      ""                 ; ""
 rs-message-citation-string-end-hello-line ",\n\n"        ; ",\n\n"
 ;;
 rs-message-citation-string-date-german " schrieb am %d.%m.%Y:\n\n"
 )

(defalias
  'rs-mail-extract-address-components 'gnus-extract-address-components)
;; mail-extr is not a clean RFC 2822 parser, it is a heuristic parser
;; <ilur8fjjb3y.fsf@latte.josefsson.org>.  `gnus-e-a-c' fails sometimes;
;; `mail-e-a-c' fails for "K.-H. Name". :-(

;;;###autoload
(defun rs-message-insert-citation-line-simple ()
  "Function that inserts a simple citation line. Uses the variables
   `rs-message-citation-string-*'"
  (when message-reply-headers
    (insert
     rs-message-citation-string-on      ; "On "
     (format-time-string
      rs-message-citation-string-date   ; "%a %b %d %Y at %R"
      (gnus-date-get-time (mail-header-date message-reply-headers)))
     rs-message-citation-string-after-date ; ", "
     ;; (mail-header-from message-reply-headers)
     ;; get real name <s02pu3weovk.fsf@wasabi.inria.fr>
     (if rs-message-citation-use-only-real-name
         (progn
           (let* ((email (mail-header-from message-reply-headers))
                  (data (condition-case ()
                            (rs-mail-extract-address-components email)
                          (error nil)))
                  (name (car data))
                  (net (car (cdr data)))
                  (real-name (or (car data) (car (cdr data)) email)
                             ))
             (when nil                 ; set this to `t' for debugging
               (gnus-message
                7 (concat
                   "email=" email
                   ;; "\ndata=" data
                   "\nname=" name
                   "\nnet=" net
                   "\nreal-name=" real-name
                   )))
             (or (car data) (car (cdr data)) email)))
       (progn (mail-header-from message-reply-headers)))
     ;; " wrote:\n\n"
     rs-message-citation-string-wrote)))

(setq message-citation-line-function 'rs-message-insert-citation-line-simple)
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]