comparison lisp/gnus/message.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 8fc7fe29b841
children 1917ad0d78d7
comparison
equal deleted inserted replaced
23:0edd3412f124 24:4103f0995bd7
725 "Alist used for formatting headers.") 725 "Alist used for formatting headers.")
726 726
727 (eval-and-compile 727 (eval-and-compile
728 (autoload 'message-setup-toolbar "messagexmas") 728 (autoload 'message-setup-toolbar "messagexmas")
729 (autoload 'mh-send-letter "mh-comp") 729 (autoload 'mh-send-letter "mh-comp")
730 (autoload 'gnus-point-at-eol "gnus-util")
731 (autoload 'gnus-point-at-bol "gnus-util")
730 (autoload 'gnus-output-to-mail "gnus-util") 732 (autoload 'gnus-output-to-mail "gnus-util")
731 (autoload 'gnus-output-to-rmail "gnus-util")) 733 (autoload 'gnus-output-to-rmail "gnus-util"))
732 734
733 735
734 736
735 ;;; 737 ;;;
736 ;;; Utility functions. 738 ;;; Utility functions.
737 ;;; 739 ;;;
738
739 (defun message-point-at-bol ()
740 "Return point at the beginning of the line."
741 (let ((p (point)))
742 (beginning-of-line)
743 (prog1
744 (point)
745 (goto-char p))))
746
747 (defun message-point-at-eol ()
748 "Return point at the end of the line."
749 (let ((p (point)))
750 (end-of-line)
751 (prog1
752 (point)
753 (goto-char p))))
754 740
755 (defmacro message-y-or-n-p (question show &rest text) 741 (defmacro message-y-or-n-p (question show &rest text)
756 "Ask QUESTION, displaying the rest of the arguments in a temp. buffer if SHOW" 742 "Ask QUESTION, displaying the rest of the arguments in a temp. buffer if SHOW"
757 `(message-talkative-question 'y-or-n-p ,question ,show ,@text)) 743 `(message-talkative-question 'y-or-n-p ,question ,show ,@text))
758 744
1275 (unless (or (zerop n) ; no action needed for a rot of 0 1261 (unless (or (zerop n) ; no action needed for a rot of 0
1276 (= b e)) ; no region to rotate 1262 (= b e)) ; no region to rotate
1277 ;; We build the table, if necessary. 1263 ;; We build the table, if necessary.
1278 (when (or (not message-caesar-translation-table) 1264 (when (or (not message-caesar-translation-table)
1279 (/= (aref message-caesar-translation-table ?a) (+ ?a n))) 1265 (/= (aref message-caesar-translation-table ?a) (+ ?a n)))
1280 (let ((i -1) 1266 (setq message-caesar-translation-table
1281 (table (make-string 256 0))) 1267 (message-make-caesar-translation-table n)))
1282 (while (< (incf i) 256)
1283 (aset table i i))
1284 (setq table
1285 (concat
1286 (substring table 0 ?A)
1287 (substring table (+ ?A n) (+ ?A n (- 26 n)))
1288 (substring table ?A (+ ?A n))
1289 (substring table (+ ?A 26) ?a)
1290 (substring table (+ ?a n) (+ ?a n (- 26 n)))
1291 (substring table ?a (+ ?a n))
1292 (substring table (+ ?a 26) 255)))
1293 (setq message-caesar-translation-table table)))
1294 ;; Then we translate the region. Do it this way to retain 1268 ;; Then we translate the region. Do it this way to retain
1295 ;; text properties. 1269 ;; text properties.
1296 (while (< b e) 1270 (while (< b e)
1297 (subst-char-in-region 1271 (subst-char-in-region
1298 b (1+ b) (char-after b) 1272 b (1+ b) (char-after b)
1299 (aref message-caesar-translation-table (char-after b))) 1273 (aref message-caesar-translation-table (char-after b)))
1300 (incf b)))) 1274 (incf b))))
1275
1276 (defun message-make-caesar-translation-table (n)
1277 "Create a rot table with offset N."
1278 (let ((i -1)
1279 (table (make-string 256 0)))
1280 (while (< (incf i) 256)
1281 (aset table i i))
1282 (concat
1283 (substring table 0 ?A)
1284 (substring table (+ ?A n) (+ ?A n (- 26 n)))
1285 (substring table ?A (+ ?A n))
1286 (substring table (+ ?A 26) ?a)
1287 (substring table (+ ?a n) (+ ?a n (- 26 n)))
1288 (substring table ?a (+ ?a n))
1289 (substring table (+ ?a 26) 255))))
1301 1290
1302 (defun message-caesar-buffer-body (&optional rotnum) 1291 (defun message-caesar-buffer-body (&optional rotnum)
1303 "Caesar rotates all letters in the current buffer by 13 places. 1292 "Caesar rotates all letters in the current buffer by 13 places.
1304 Used to encode/decode possibly offensive messages (commonly in net.jokes). 1293 Used to encode/decode possibly offensive messages (commonly in net.jokes).
1305 With prefix arg, specifies the number of places to rotate each letter forward. 1294 With prefix arg, specifies the number of places to rotate each letter forward.
2521 (goto-char (point-max)) 2510 (goto-char (point-max))
2522 (insert (symbol-name header) ": " value "\n") 2511 (insert (symbol-name header) ": " value "\n")
2523 (forward-line -1)) 2512 (forward-line -1))
2524 ;; The value of this header was empty, so we clear 2513 ;; The value of this header was empty, so we clear
2525 ;; totally and insert the new value. 2514 ;; totally and insert the new value.
2526 (delete-region (point) (message-point-at-eol)) 2515 (delete-region (point) (gnus-point-at-eol))
2527 (insert value)) 2516 (insert value))
2528 ;; Add the deletable property to the headers that require it. 2517 ;; Add the deletable property to the headers that require it.
2529 (and (memq header message-deletable-headers) 2518 (and (memq header message-deletable-headers)
2530 (progn (beginning-of-line) (looking-at "[^:]+: ")) 2519 (progn (beginning-of-line) (looking-at "[^:]+: "))
2531 (add-text-properties 2520 (add-text-properties
2926 (let ((cur (current-buffer)) 2915 (let ((cur (current-buffer))
2927 from subject date reply-to mct 2916 from subject date reply-to mct
2928 references message-id follow-to 2917 references message-id follow-to
2929 (inhibit-point-motion-hooks t) 2918 (inhibit-point-motion-hooks t)
2930 (message-this-is-news t) 2919 (message-this-is-news t)
2931 followup-to distribution newsgroups gnus-warning) 2920 followup-to distribution newsgroups gnus-warning posted-to)
2932 (save-restriction 2921 (save-restriction
2933 (narrow-to-region 2922 (narrow-to-region
2934 (goto-char (point-min)) 2923 (goto-char (point-min))
2935 (if (search-forward "\n\n" nil t) 2924 (if (search-forward "\n\n" nil t)
2936 (1- (point)) 2925 (1- (point))
2943 subject (or (message-fetch-field "subject") "none") 2932 subject (or (message-fetch-field "subject") "none")
2944 references (message-fetch-field "references") 2933 references (message-fetch-field "references")
2945 message-id (message-fetch-field "message-id" t) 2934 message-id (message-fetch-field "message-id" t)
2946 followup-to (message-fetch-field "followup-to") 2935 followup-to (message-fetch-field "followup-to")
2947 newsgroups (message-fetch-field "newsgroups") 2936 newsgroups (message-fetch-field "newsgroups")
2937 posted-to (message-fetch-field "posted-to")
2948 reply-to (message-fetch-field "reply-to") 2938 reply-to (message-fetch-field "reply-to")
2949 distribution (message-fetch-field "distribution") 2939 distribution (message-fetch-field "distribution")
2950 mct (message-fetch-field "mail-copies-to")) 2940 mct (message-fetch-field "mail-copies-to"))
2951 (when (and (setq gnus-warning (message-fetch-field "gnus-warning")) 2941 (when (and (setq gnus-warning (message-fetch-field "gnus-warning"))
2952 (string-match "<[^>]+>" gnus-warning)) 2942 (string-match "<[^>]+>" gnus-warning))
2981 2971
2982 `Followup-To: poster' sends your response via e-mail instead of news. 2972 `Followup-To: poster' sends your response via e-mail instead of news.
2983 2973
2984 A typical situation where `Followup-To: poster' is used is when the poster 2974 A typical situation where `Followup-To: poster' is used is when the poster
2985 does not read the newsgroup, so he wouldn't see any replies sent to it.")) 2975 does not read the newsgroup, so he wouldn't see any replies sent to it."))
2986 (cons 'To (or reply-to from "")) 2976 (progn
2977 (setq message-this-is-news nil)
2978 (cons 'To (or reply-to from "")))
2987 (cons 'Newsgroups newsgroups))) 2979 (cons 'Newsgroups newsgroups)))
2988 (t 2980 (t
2989 (if (or (equal followup-to newsgroups) 2981 (if (or (equal followup-to newsgroups)
2990 (not (eq message-use-followup-to 'ask)) 2982 (not (eq message-use-followup-to 'ask))
2991 (message-y-or-n-p 2983 (message-y-or-n-p
3004 2996
3005 Also, some source/announcement newsgroups are not indented for discussion; 2997 Also, some source/announcement newsgroups are not indented for discussion;
3006 responses here are directed to other newsgroups.")) 2998 responses here are directed to other newsgroups."))
3007 (cons 'Newsgroups followup-to) 2999 (cons 'Newsgroups followup-to)
3008 (cons 'Newsgroups newsgroups)))))) 3000 (cons 'Newsgroups newsgroups))))))
3001 (posted-to
3002 `((Newsgroups . ,posted-to)))
3009 (t 3003 (t
3010 `((Newsgroups . ,newsgroups)))) 3004 `((Newsgroups . ,newsgroups))))
3011 ,@(and distribution (list (cons 'Distribution distribution))) 3005 ,@(and distribution (list (cons 'Distribution distribution)))
3012 ,@(if (or references message-id) 3006 ,@(if (or references message-id)
3013 `((References . ,(concat (or references "") (and references " ") 3007 `((References . ,(concat (or references "") (and references " ")