bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16733: messed up unicode chars in package description


From: Juanma Barranquero
Subject: bug#16733: messed up unicode chars in package description
Date: Tue, 25 Mar 2014 10:54:29 +0100

On Tue, Mar 25, 2014 at 4:35 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:

> The old package.el code included (buffer-substring-no-properties (point)
> (line-end-position)) in the message.  Would it make sense to put it here
> as well?

It's the HTTP error description. As the "no buffer" case doesn't have
such a description, I've modified url-insert-file-contents so in tha
case it returns "No Data", to match "Not Found" and other HTTP errors.

That's the resulting url-i-f-c:

(defun url-insert-file-contents (url &optional visit beg end replace)
  (let ((buffer (url-retrieve-synchronously url)))
    (unless buffer (signal 'file-error (list url "No Data")))
    (with-current-buffer buffer
      (let ((response (url-http-parse-response)))
        (if (and (>= response 200) (< response 300))
            (goto-char (point-min))
          (let ((desc (buffer-substring-no-properties (1+ (point))
                                                      (line-end-position))))
            (kill-buffer buffer)
            (signal 'file-error (list url desc))))))
    (if visit (setq buffer-file-name url))
    (save-excursion
      (let* ((start (point))
             (size-and-charset (url-insert buffer beg end)))
        (kill-buffer buffer)
        (when replace
          (delete-region (point-min) start)
          (delete-region (point) (point-max)))
        (unless (cadr size-and-charset)
          ;; If the headers don't specify any particular charset, use the
          ;; usual heuristic/rules that we apply to files.
          (decode-coding-inserted-region start (point) url visit beg
end replace))
        (list url (car size-and-charset))))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]