diff options
author | JSDurand <mmemmew@gmail.com> | 2021-12-31 20:50:52 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-12-31 20:50:52 +0800 |
commit | 8e52f0c296db9b70621d59ec1a5cb0a31c1af6a4 (patch) | |
tree | bc4802a907f464a4214bff930a7b6aa57ef32811 /mail.el | |
parent | f42ef8797db87a68aff253910361af88b718b7d0 (diff) |
mail: extending `durand-quote-message'
Diffstat (limited to 'mail.el')
-rw-r--r-- | mail.el | 88 |
1 files changed, 64 insertions, 24 deletions
@@ -124,12 +124,26 @@ ;;; Quote a message -(defun durand-quote-message () +(defvar durand-quote-history nil + "The history of names whom I have quoted.") + +(autoload 'durand-take "common") + +(defun durand-quote-message (&optional arg) "Quote the current message body, and add some meta-data. Actually this only saves the quote text in the `kill-ring', and -does not modify the buffer directly." +does not modify the buffer directly. + +If region is activated, only quote the text in the region. + +If ARG is (list 4), query for the time and the name to quote. + +If ARG is non-nil, and not equal to (list 4), omit the line about +the time and the one who says the quote; only query the author +and produce the quoted message." (interactive - nil gnus-summary-mode gnus-article-mode message-mode) + (list current-prefix-arg) + gnus-summary-mode gnus-article-mode message-mode) (cond ((apply #'provided-mode-derived-p major-mode (command-modes #'durand-quote-message))) @@ -144,20 +158,40 @@ does not modify the buffer directly." ((derived-mode-p 'gnus-summary-mode) (set-buffer gnus-article-buffer))) (let* ((date - (save-match-data - (save-restriction - (mail-narrow-to-head) - (mail-fetch-field "Date")))) + (cond + ((and (listp arg) + (null (cdr arg)) + (eq (car arg) 4)) + (read-string "Time of the quote: ")) + (arg nil) + ((save-match-data + (save-restriction + (mail-narrow-to-head) + (mail-fetch-field "Date")))))) (date - (format-time-string - "%a, %e %b %Y %H:%M:%S %z" - (encode-time (parse-time-string date)) - (current-time-zone))) + (cond + (date + (format-time-string + "%a, %e %b %Y %H:%M:%S %z" + (let* ((time (parse-time-string date)) + (first-six + (mapcar + (lambda (element) (or element 0)) + (durand-take 6 time))) + (remain (nthcdr 6 time))) + (encode-time (append first-six remain))) + (current-time-zone))))) (author - (save-match-data - (save-restriction - (mail-narrow-to-head) - (mail-fetch-field "From")))) + (cond + (arg + (read-string + "Author of the quote: " + nil 'durand-quote-history + durand-quote-history t)) + ((save-match-data + (save-restriction + (mail-narrow-to-head) + (mail-fetch-field "From")))))) (author-name (save-match-data (cond @@ -175,16 +209,22 @@ does not modify the buffer directly." (match-string 1 author)) (author)))) (body - (save-match-data - (save-restriction - (widen) - (article-goto-body) - (buffer-substring-no-properties - (point) (point-max)))))) + (cond + ((use-region-p) + (buffer-substring-no-properties + (region-beginning) (region-end))) + ((save-match-data + (save-restriction + (widen) + (article-goto-body) + (buffer-substring-no-properties + (point) (point-max)))))))) (kill-new - (format - ">>>>> Le %s, %s a dit:\n\n%s" - date author + (concat + (cond + (date + (format + ">>>>> Le %s, %s a dit:\n\n" date author))) (mapconcat (lambda (line) (cond |