Re: supercite
Alex Kicelew -> debian-russian@lists.debian.org @ 03 Dec 2005 23:22:16 +0300:
AK> А в сабже как-то можно изобразить традиционный фидошный квотинг? Инфо
AK> прочитал, но этого не нашел (допускаю, что плохо читал). Или, может,
AK> для этого применяются другие средства?
Ходят слухи, что можно, но неудобно. Проще без него.
(defun Ran:citation-line ()
(let ((name-to
(or
(message-fetch-reply-field "X-Comment-To")
(message-fetch-reply-field "To"))))
(insert (SNP:email->stripped-full-name (mail-header-from message-reply-headers)))
(when name-to
(insert " -> " (SNP:email->stripped-full-name name-to)))
(insert " @ " (mail-header-date message-reply-headers) ":\n\n")))
(setq message-citation-line-function 'Ran:citation-line)
(defun Ran:citation ()
(let ((beg (point))
(end (mark t))
(initials (SNP:full-name->initials
(SNP:email->stripped-full-name
(message-fetch-reply-field "From")))))
(save-excursion
(narrow-to-region beg end)
(while (not (eobp))
(beginning-of-line)
(unless (eolp)
(if (re-search-forward "^ *\\(\\w*\\)\\(>\\)" (point-at-eol) t)
(replace-match " \\1>\\2")
(insert " " initials "> ")))
(forward-line 1))
(widen))))
(setq mail-citation-hook
'(lambda ()
(Ran:citation)
(Ran:citation-line)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Разные полезные функции из gnus-snp
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Удалить пробелы в начале и в конце строки
;;
(defun SNP:strip-string (str)
(let ((s str))
(when (string-match "^[ \"]+" s)
(setq s (substring s (match-end 0))))
(when (string-match "[ \"]+$" s)
(setq s (substring s 0 (match-beginning 0))))
(symbol-value 's)))
;;
;; Получить имя из e-mail'а
;;
(defun SNP:email->full-name (from)
(if from
(let ((s))
(if (cdr (setq s (split-string from "<\\|>")))
(car s)
(if (cdr (setq s (split-string from "\(\\|\)")))
(cadr s)
from)))
""))
(defun SNP:email->stripped-full-name (from)
(SNP:strip-string (SNP:email->full-name from)))
;;
;; Получить начало имени из полного имени
;;
(defun SNP:full-name->first-name (name)
(when (string-match "[^ ]*" name)
(substring name (match-beginning 0) (match-end 0))))
;;
;; Получить инициалы из имени
;;
(defun SNP:full-name->initials (name)
(let ((lst (split-string name " +"))
(out ""))
(while lst
(setq out (concat out (char-to-string (car (string-to-list (car lst))))))
(setq lst (cdr lst))
)
(symbol-value 'out)))
;;
;; Разрыв строки, сохраняющий квотинг
;;
(defun Ran:break-cited-line ()
(interactive)
(if (or (bolp) (eolp))
(insert "\n")
(let ((quote-string nil))
(save-excursion
(beginning-of-line)
(when (re-search-forward "^ *\\w*>+" (point-at-eol) t)
(setq quote-string (match-string 0))))
(if quote-string
(insert (concat "\n" quote-string))
(insert "\n")))))
--
Artem Chuprina
RFC2822: <ran{}ran.pp.ru> Jabber: ran@jabber.ran.pp.ru
Win-юзеры - это типа Win-модемов и Win-принтеров: такие же юзеры, но попроще,
без мозгов и памяти на борту.
http://www.livejournal.com/~dottedmag/158509.html
Reply to:
- References:
- supercite
- From: Alex Kicelew <ark@mir.icsmir.ru>