(regexp-quote address)
"\\(?:\\'\\|[ ,>]\\)"))
(delim (concat "^" message-unix-mail-delimiter)))
- (let ((coding-system-for-write 'binary)
- (coding-system-for-read 'binary))
- (with-temp-file tmpfile
- (mm-disable-multibyte)
- (dolist (id ids)
- (let ((file (expand-file-name id (locate-user-emacs-file
- "debbugs-cache"))))
- (if (and (not gnus-plugged)
- (file-exists-p file))
- (insert-file-contents file)
- ;; Pass non-nil VISIT to avoid errors with non-nil
- ;; `url-automatic-caching' (bug#26063, bug#29008)
- ;; and immediately unvisit.
- ;; FIXME: This masks real errors!
- (url-insert-file-contents (format mbox-url id) t)
- (setq buffer-file-name nil))))
- (goto-char (point-min))
- ;; Throw an informative error early instead of passing nonsense
- ;; to `gnus-group-read-ephemeral-group' (bug#36433).
- (unless (save-excursion (re-search-forward delim nil t))
- (error "Invalid mbox format for bug IDs: %s"
- (string-join ids ", ")))
- (while (re-search-forward delim nil t)
- (narrow-to-region (point)
- (if (search-forward "\n\n" nil t)
- (1- (point))
- (point-max)))
- (unless (string-match-p address-re
- (concat (message-fetch-field "to") " "
- (message-fetch-field "cc")))
- (goto-char (point-min))
- (if (not (re-search-forward "^To:" nil t))
- (insert "To: " address "\n")
- (message-next-header)
- (skip-chars-backward "\t\n ")
- (insert ", " address)))
- (goto-char (point-max))
- (widen))))
+ (with-temp-file tmpfile
+ (mm-disable-multibyte)
+ (dolist (id ids)
+ (let ((file (expand-file-name id (locate-user-emacs-file
+ "debbugs-cache"))))
+ (if (and (not gnus-plugged)
+ (file-exists-p file))
+ (insert-file-contents-literally file)
+ (url-insert-file-contents-literally (format mbox-url id)))))
+ (goto-char (point-min))
+ ;; Throw an informative error early instead of passing nonsense
+ ;; to `gnus-group-read-ephemeral-group' (bug#36433).
+ (unless (save-excursion (re-search-forward delim nil t))
+ (error "Invalid mbox format for bug IDs: %s"
+ (string-join ids ", ")))
+ (while (re-search-forward delim nil t)
+ (narrow-to-region (point)
+ (if (search-forward "\n\n" nil t)
+ (1- (point))
+ (point-max)))
+ (unless (string-match-p address-re
+ (concat (message-fetch-field "to") " "
+ (message-fetch-field "cc")))
+ (goto-char (point-min))
+ (if (not (re-search-forward "^To:" nil t))
+ (insert "To: " address "\n")
+ (message-next-header)
+ (skip-chars-backward "\t\n ")
+ (insert ", " address)))
+ (goto-char (point-max))
+ (widen)))
(gnus-group-read-ephemeral-group
(concat "nndoc+ephemeral:bug#" (string-join ids ","))
`(nndoc ,tmpfile
filename))
(put 'file-local-copy 'url-file-handlers #'url-file-local-copy)
-(defun url-insert (buffer &optional beg end)
+(defun url-insert (buffer &optional beg end inhibit-decode)
"Insert the body of a URL object.
BUFFER should be a complete URL buffer as returned by `url-retrieve'.
If the headers specify a coding-system (and current buffer is multibyte),
-it is applied to the body before it is inserted.
+it is applied to the body before it is inserted. If INHIBIT-DECODE is
+non-nil, don't do any coding system decoding even in multibyte buffers.
+
Returns a list of the form (SIZE CHARSET), where SIZE is the size in bytes
of the inserted text and CHARSET is the charset that was specified in the
header, or nil if none was found.
(buffer-substring (+ (point-min) beg)
(if end (+ (point-min) end) (point-max)))
(buffer-string))))
- (charset (if enable-multibyte-characters
+ (charset (if (and enable-multibyte-characters
+ (not inhibit-decode))
(mail-content-type-get (mm-handle-type handle)
'charset))))
(mm-destroy-parts handle)
(url-insert-buffer-contents buffer url visit beg end replace)))
(put 'insert-file-contents 'url-file-handlers #'url-insert-file-contents)
+;;;###autoload
+(defun url-insert-file-contents-literally (url)
+ "Insert the data retrieved from URL literally in the current buffer."
+ (let ((buffer (url-retrieve-synchronously url)))
+ (unless buffer
+ (signal 'file-error (list url "No Data")))
+ (url-insert buffer nil nil t)))
+
(defun url-file-name-completion (url _directory &optional _predicate)
;; Even if it's not implemented, it's not an error to ask for completion,
;; in case it's available (bug#14806).