merge from trunk

This commit is contained in:
Joakim Verona 2013-08-13 20:16:27 +02:00
commit f0a5c7bd7d
7 changed files with 53 additions and 14 deletions

View file

@ -1,5 +1,11 @@
2013-08-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-parse-image-data): New function to grab both the
data itself and the Content-Type.
(shr-put-image): Use it.
* net/eww.el (eww-display-image): Ditto.
* image.el (image-content-type-suffixes): New variable.
2013-08-13 Fabián Ezequiel Gallina <fgallina@gnu.org>

View file

@ -304,7 +304,7 @@ word(s) will be searched for via `eww-search-prefix'."
(goto-char (point-min))))
(defun eww-display-image ()
(let ((data (buffer-substring (point) (point-max))))
(let ((data (shr-parse-image-data)))
(eww-setup-buffer)
(let ((inhibit-read-only t))
(shr-put-image data nil))

View file

@ -705,7 +705,7 @@ If EXTERNAL, browse the URL using `shr-external-browser'."
(url-store-in-cache image-buffer)
(when (or (search-forward "\n\n" nil t)
(search-forward "\r\n\r\n" nil t))
(let ((data (buffer-substring (point) (point-max))))
(let ((data (shr-parse-image-data)))
(with-current-buffer buffer
(save-excursion
(let ((alt (buffer-substring start end))
@ -732,20 +732,28 @@ If EXTERNAL, browse the URL using `shr-external-browser'."
(setq payload (base64-decode-string payload)))
payload)))
(defun shr-put-image (data alt &optional flags)
"Put image DATA with a string ALT. Return image."
(defun shr-put-image (spec alt &optional flags)
"Insert image SPEC with a string ALT. Return image.
SPEC is either an image data blob, or a list where the first
element is the data blob and the second element is the content-type."
(if (display-graphic-p)
(let* ((size (cdr (assq 'size flags)))
(data (if (consp spec)
(car spec)
spec))
(content-type (and (consp spec)
(cadr spec)))
(start (point))
(image (cond
((eq size 'original)
(create-image data nil t :ascent 100))
(create-image data nil t :ascent 100
:content-type content-type))
((eq size 'full)
(ignore-errors
(shr-rescale-image data t)))
(shr-rescale-image data t content-type)))
(t
(ignore-errors
(shr-rescale-image data))))))
(shr-rescale-image data nil content-type))))))
(when image
;; When inserting big-ish pictures, put them at the
;; beginning of the line.
@ -767,7 +775,7 @@ If EXTERNAL, browse the URL using `shr-external-browser'."
image)
(insert alt)))
(defun shr-rescale-image (data &optional force)
(defun shr-rescale-image (data &optional force content-type)
"Rescale DATA, if too big, to fit the current buffer.
If FORCE, rescale the image anyway."
(if (or (not (fboundp 'imagemagick-types))
@ -782,7 +790,8 @@ If FORCE, rescale the image anyway."
:max-width (truncate (* shr-max-image-proportion
(- (nth 2 edges) (nth 0 edges))))
:max-height (truncate (* shr-max-image-proportion
(- (nth 3 edges) (nth 1 edges))))))))
(- (nth 3 edges) (nth 1 edges))))
:content-type content-type))))
;; url-cache-extract autoloads url-cache.
(declare-function url-cache-create-filename "url-cache" (url))
@ -799,7 +808,17 @@ Return a string with image data."
t)
(when (or (search-forward "\n\n" nil t)
(search-forward "\r\n\r\n" nil t))
(buffer-substring (point) (point-max))))))
(shr-parse-image-data)))))
(defun shr-parse-image-data ()
(list
(buffer-substring (point) (point-max))
(save-excursion
(save-restriction
(narrow-to-region (point-min) (point))
(let ((content-type (mail-fetch-field "content-type")))
(and content-type
(intern content-type obarray)))))))
(defun shr-image-displayer (content-function)
"Return a function to display an image.

View file

@ -1,3 +1,15 @@
2013-08-13 Eli Zaretskii <eliz@gnu.org>
* window.c (Fwindow_margins): Return nil when there's no marginal
area, as per the documented API.
* w32term.c (x_scroll_bar_create): Use ALLOCATE_PSEUDOVECTOR, not
Fmake_vector, as scroll bar's struct members are not all Lisp
objects now. This avoids crashes in GC.
* w32term.h (struct scroll_bar): Convert fringe_extended_p to a
bool, so its address could be taken.
2013-08-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
* image.c (imagemagick_filename_hint): New function to possibly

View file

@ -3757,7 +3757,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
HWND hwnd;
SCROLLINFO si;
struct scroll_bar *bar
= XSCROLL_BAR (Fmake_vector (make_number (VECSIZE (struct scroll_bar)), Qnil));
= ALLOCATE_PSEUDOVECTOR (struct scroll_bar, fringe_extended_p, PVEC_OTHER);
Lisp_Object barobj;
block_input ();

View file

@ -453,7 +453,9 @@ struct scroll_bar {
/* 1 if the background of the fringe that is adjacent to a scroll
bar is extended to the gap between the fringe and the bar. */
unsigned fringe_extended_p : 1;
/* Note: this could be a bit field, but we need to take its address
in ALLOCATE_PSEUDOVECTOR (see x_scroll_bar_create). */
bool fringe_extended_p;
};
/* Turning a lisp vector value into a pointer to a struct scroll_bar. */

View file

@ -6177,8 +6177,8 @@ as nil. */)
(Lisp_Object window)
{
struct window *w = decode_live_window (window);
return Fcons (make_number (w->left_margin_cols),
make_number (w->right_margin_cols));
return Fcons (w->left_margin_cols ? make_number (w->left_margin_cols) : Qnil,
w->right_margin_cols ? make_number (w->right_margin_cols) : Qnil);
}