aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2017-11-29 17:38:46 -0500
committerStefan Monnier2017-11-29 17:38:46 -0500
commit728d259243206136387b6b59c2efb7de8cd9f6ed (patch)
tree69ecb8ed2098f3105e0f21fcba40be6d1c2501ad
parent95369ac346d75a7b75bc2c5adf632cc4faa1241a (diff)
downloademacs-728d259243206136387b6b59c2efb7de8cd9f6ed.tar.gz
emacs-728d259243206136387b6b59c2efb7de8cd9f6ed.zip
* lisp/gnus/message.el: Use pcase and cl-lib
(message-check-news-body-syntax): Avoid string-to-multibyte.
-rw-r--r--lisp/gnus/message.el70
1 files changed, 36 insertions, 34 deletions
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 445911fc6d5..1f1302e3fc8 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -28,8 +28,7 @@
28 28
29;;; Code: 29;;; Code:
30 30
31(eval-when-compile 31(eval-when-compile (require 'cl-lib))
32 (require 'cl))
33 32
34(require 'mailheader) 33(require 'mailheader)
35(require 'gmm-utils) 34(require 'gmm-utils)
@@ -2444,7 +2443,7 @@ Return the number of headers removed."
2444 (not (looking-at regexp)) 2443 (not (looking-at regexp))
2445 (looking-at regexp)) 2444 (looking-at regexp))
2446 (progn 2445 (progn
2447 (incf number) 2446 (cl-incf number)
2448 (when first 2447 (when first
2449 (setq last t)) 2448 (setq last t))
2450 (delete-region 2449 (delete-region
@@ -2469,10 +2468,10 @@ Return the number of headers removed."
2469 (save-excursion 2468 (save-excursion
2470 (goto-char (point-min)) 2469 (goto-char (point-min))
2471 (while (re-search-forward regexp nil t) 2470 (while (re-search-forward regexp nil t)
2472 (incf count))) 2471 (cl-incf count)))
2473 (while (> count 1) 2472 (while (> count 1)
2474 (message-remove-header header nil t) 2473 (message-remove-header header nil t)
2475 (decf count)))) 2474 (cl-decf count))))
2476 2475
2477(defun message-narrow-to-headers () 2476(defun message-narrow-to-headers ()
2478 "Narrow the buffer to the head of the message." 2477 "Narrow the buffer to the head of the message."
@@ -3227,13 +3226,13 @@ or in the synonym headers, defined by `message-header-synonyms'."
3227 (dolist (header headers) 3226 (dolist (header headers)
3228 (let* ((header-name (symbol-name (car header))) 3227 (let* ((header-name (symbol-name (car header)))
3229 (new-header (cdr header)) 3228 (new-header (cdr header))
3230 (synonyms (loop for synonym in message-header-synonyms 3229 (synonyms (cl-loop for synonym in message-header-synonyms
3231 when (memq (car header) synonym) return synonym)) 3230 when (memq (car header) synonym) return synonym))
3232 (old-header 3231 (old-header
3233 (loop for synonym in synonyms 3232 (cl-loop for synonym in synonyms
3234 for old-header = (mail-fetch-field (symbol-name synonym)) 3233 for old-header = (mail-fetch-field (symbol-name synonym))
3235 when (and old-header (string-match new-header old-header)) 3234 when (and old-header (string-match new-header old-header))
3236 return synonym))) 3235 return synonym)))
3237 (if old-header 3236 (if old-header
3238 (message "already have `%s' in `%s'" new-header old-header) 3237 (message "already have `%s' in `%s'" new-header old-header)
3239 (when (and (message-position-on-field header-name) 3238 (when (and (message-position-on-field header-name)
@@ -3593,7 +3592,7 @@ text was killed."
3593 "Create a rot table with offset N." 3592 "Create a rot table with offset N."
3594 (let ((i -1) 3593 (let ((i -1)
3595 (table (make-string 256 0))) 3594 (table (make-string 256 0)))
3596 (while (< (incf i) 256) 3595 (while (< (cl-incf i) 256)
3597 (aset table i i)) 3596 (aset table i i))
3598 (concat 3597 (concat
3599 (substring table 0 ?A) 3598 (substring table 0 ?A)
@@ -3761,13 +3760,13 @@ To use this automatically, you may add this function to
3761 (goto-char (mark t)) 3760 (goto-char (mark t))
3762 (insert-before-markers ?\n) 3761 (insert-before-markers ?\n)
3763 (goto-char pt)))) 3762 (goto-char pt))))
3764 (case message-cite-reply-position 3763 (pcase message-cite-reply-position
3765 (above 3764 ('above
3766 (message-goto-body) 3765 (message-goto-body)
3767 (insert body-text) 3766 (insert body-text)
3768 (insert (if (bolp) "\n" "\n\n")) 3767 (insert (if (bolp) "\n" "\n\n"))
3769 (message-goto-body)) 3768 (message-goto-body))
3770 (below 3769 ('below
3771 (message-goto-signature))) 3770 (message-goto-signature)))
3772 ;; Add a `message-setup-very-last-hook' here? 3771 ;; Add a `message-setup-very-last-hook' here?
3773 ;; Add `gnus-article-highlight-citation' here? 3772 ;; Add `gnus-article-highlight-citation' here?
@@ -4612,9 +4611,9 @@ This function could be useful in `message-setup-hook'."
4612 (with-current-buffer mailbuf 4611 (with-current-buffer mailbuf
4613 message-courtesy-message))) 4612 message-courtesy-message)))
4614 ;; Let's make sure we encoded all the body. 4613 ;; Let's make sure we encoded all the body.
4615 (assert (save-excursion 4614 (cl-assert (save-excursion
4616 (goto-char (point-min)) 4615 (goto-char (point-min))
4617 (not (re-search-forward "[^\000-\377]" nil t)))) 4616 (not (re-search-forward "[^\000-\377]" nil t))))
4618 (mm-disable-multibyte) 4617 (mm-disable-multibyte)
4619 (if (or (not message-send-mail-partially-limit) 4618 (if (or (not message-send-mail-partially-limit)
4620 (< (buffer-size) message-send-mail-partially-limit) 4619 (< (buffer-size) message-send-mail-partially-limit)
@@ -4768,7 +4767,7 @@ to find out how to use this."
4768 (replace-match "\n") 4767 (replace-match "\n")
4769 (run-hooks 'message-send-mail-hook) 4768 (run-hooks 'message-send-mail-hook)
4770 ;; send the message 4769 ;; send the message
4771 (case 4770 (pcase
4772 (let ((coding-system-for-write message-send-coding-system)) 4771 (let ((coding-system-for-write message-send-coding-system))
4773 (apply 4772 (apply
4774 'call-process-region (point-min) (point-max) 4773 'call-process-region (point-min) (point-max)
@@ -4799,7 +4798,7 @@ to find out how to use this."
4799 (100 (error "qmail-inject reported permanent failure")) 4798 (100 (error "qmail-inject reported permanent failure"))
4800 (111 (error "qmail-inject reported transient failure")) 4799 (111 (error "qmail-inject reported transient failure"))
4801 ;; should never happen 4800 ;; should never happen
4802 (t (error "qmail-inject reported unknown failure")))) 4801 (_ (error "qmail-inject reported unknown failure"))))
4803 4802
4804(defvar mh-previous-window-config) 4803(defvar mh-previous-window-config)
4805 4804
@@ -5322,7 +5321,9 @@ Otherwise, generate and save a value for `canlock-password' first."
5322 ;; Check for control characters. 5321 ;; Check for control characters.
5323 (message-check 'control-chars 5322 (message-check 'control-chars
5324 (if (re-search-forward 5323 (if (re-search-forward
5325 (string-to-multibyte "[\000-\007\013\015-\032\034-\037\200-\237]") 5324 (eval-when-compile
5325 (decode-coding-string "[\000-\007\013\015-\032\034-\037\200-\237]"
5326 'binary))
5326 nil t) 5327 nil t)
5327 (y-or-n-p 5328 (y-or-n-p
5328 "The article contains control characters. Really post? ") 5329 "The article contains control characters. Really post? ")
@@ -5849,10 +5850,10 @@ subscribed address (and not the additional To and Cc header contents)."
5849 message-subscribed-address-functions)))) 5850 message-subscribed-address-functions))))
5850 (save-match-data 5851 (save-match-data
5851 (let ((list 5852 (let ((list
5852 (loop for recipient in recipients 5853 (cl-loop for recipient in recipients
5853 when (loop for regexp in mft-regexps 5854 when (cl-loop for regexp in mft-regexps
5854 thereis (string-match regexp recipient)) 5855 thereis (string-match regexp recipient))
5855 return recipient))) 5856 return recipient)))
5856 (when list 5857 (when list
5857 (if only-show-subscribed 5858 (if only-show-subscribed
5858 list 5859 list
@@ -6201,7 +6202,7 @@ they are."
6201 (when (> count maxcount) 6202 (when (> count maxcount)
6202 (let ((surplus (- count maxcount))) 6203 (let ((surplus (- count maxcount)))
6203 (message-shorten-1 refs cut surplus) 6204 (message-shorten-1 refs cut surplus)
6204 (decf count surplus))) 6205 (cl-decf count surplus)))
6205 6206
6206 ;; When sending via news, make sure the total folded length will 6207 ;; When sending via news, make sure the total folded length will
6207 ;; be less than 998 characters. This is to cater to broken INN 6208 ;; be less than 998 characters. This is to cater to broken INN
@@ -6726,9 +6727,9 @@ The function is called with one parameter, a cons cell ..."
6726 ;; Gmane renames "To". Look at "Original-To", too, if it is present in 6727 ;; Gmane renames "To". Look at "Original-To", too, if it is present in
6727 ;; message-header-synonyms. 6728 ;; message-header-synonyms.
6728 (setq to (or (message-fetch-field "to") 6729 (setq to (or (message-fetch-field "to")
6729 (and (loop for synonym in message-header-synonyms 6730 (and (cl-loop for synonym in message-header-synonyms
6730 when (memq 'Original-To synonym) 6731 when (memq 'Original-To synonym)
6731 return t) 6732 return t)
6732 (message-fetch-field "original-to"))) 6733 (message-fetch-field "original-to")))
6733 cc (message-fetch-field "cc") 6734 cc (message-fetch-field "cc")
6734 extra (when message-extra-wide-headers 6735 extra (when message-extra-wide-headers
@@ -8133,11 +8134,12 @@ From headers in the original article."
8133 (message-tokenize-header 8134 (message-tokenize-header
8134 (mail-strip-quoted-names 8135 (mail-strip-quoted-names
8135 (mapconcat 'message-fetch-reply-field fields ",")))) 8136 (mapconcat 'message-fetch-reply-field fields ","))))
8136 (email (cond ((functionp message-alternative-emails) 8137 (email
8137 (car (cl-remove-if-not message-alternative-emails emails))) 8138 (cond ((functionp message-alternative-emails)
8138 (t (loop for email in emails 8139 (car (cl-remove-if-not message-alternative-emails emails)))
8139 if (string-match-p message-alternative-emails email) 8140 (t (cl-loop for email in emails
8140 return email))))) 8141 if (string-match-p message-alternative-emails email)
8142 return email)))))
8141 (unless (or (not email) (equal email user-mail-address)) 8143 (unless (or (not email) (equal email user-mail-address))
8142 (message-remove-header "From") 8144 (message-remove-header "From")
8143 (goto-char (point-max)) 8145 (goto-char (point-max))