From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: shyam@swathanthran.in (Shyam | =?UTF-8?Q?=E0=B4=B6=E0=B5=8D=E0=B4=AF=E0=B4=BE=E0=B4=82_?= =?UTF-8?Q?=E0=B4=95=E0=B4=BE=E0=B4=B0=E0=B4=A8=E0=B4=BE=E0=B4=9F=E0=B5=8D=E0=B4=9F=E0=B5=8D? Newsgroups: gmane.emacs.bugs Subject: bug#6639: [PATCH]image-mode: making image-mode functions to consider slice property Date: Fri, 16 Jul 2010 17:01:28 +0530 Message-ID: <87eif3hddb.fsf@shyam.laptop> References: <87r5j5ruzq.fsf@shyam.laptop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1279288854 8615 80.91.229.12 (16 Jul 2010 14:00:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Jul 2010 14:00:54 +0000 (UTC) To: 6639@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 16 16:00:42 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OZlSx-0007Bb-Dl for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Jul 2010 16:00:39 +0200 Original-Received: from localhost ([127.0.0.1]:54270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OZlSw-0001z6-SG for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Jul 2010 10:00:38 -0400 Original-Received: from [140.186.70.92] (port=34211 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OZlSk-0001wP-88 for bug-gnu-emacs@gnu.org; Fri, 16 Jul 2010 10:00:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OZlSi-0000kg-Rj for bug-gnu-emacs@gnu.org; Fri, 16 Jul 2010 10:00:26 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52001) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OZlSi-0000ka-QO for bug-gnu-emacs@gnu.org; Fri, 16 Jul 2010 10:00:24 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OZlPS-0005BY-8x; Fri, 16 Jul 2010 09:57:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87r5j5ruzq.fsf@shyam.laptop> Resent-From: shyam@swathanthran.in (Shyam | =?UTF-8?Q?=E0=B4=B6=E0=B5=8D=E0=B4=AF=E0=B4=BE=E0=B4=82_?= =?UTF-8?Q?=E0=B4=95=E0=B4=BE=E0=B4=B0=E0=B4=A8=E0=B4=BE=E0=B4=9F=E0=B5=8D=E0=B4=9F=E0=B5=8D?= | Karanatt) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Jul 2010 13:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6639 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 6639-submit@debbugs.gnu.org id=B6639.127928861719925 (code B ref 6639); Fri, 16 Jul 2010 13:57:02 +0000 Original-Received: (at 6639) by debbugs.gnu.org; 16 Jul 2010 13:56:57 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OZlPM-0005BK-Hg for submit@debbugs.gnu.org; Fri, 16 Jul 2010 09:56:57 -0400 Original-Received: from oakford.webserversystems.com ([74.54.107.139]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OZj8a-00047w-Rn for 6639@debbugs.gnu.org; Fri, 16 Jul 2010 07:31:29 -0400 Original-Received: from [117.204.80.23] (helo=shyam.laptop.shyam.laptop) by oakford.webserversystems.com with esmtpa (Exim 4.69) (envelope-from ) id 1OZj8m-00034c-DA for 6639@debbugs.gnu.org; Fri, 16 Jul 2010 06:31:41 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - oakford.webserversystems.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - swathanthran.in X-Source: X-Source-Args: X-Source-Dir: X-Mailman-Approved-At: Fri, 16 Jul 2010 09:56:54 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 16 Jul 2010 09:57:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:38603 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Transfer-Encoding: quoted-printable I forgot to look for other calls to image-size. Looking through the whole emacs code, only image-mode seems to be making calls to image-size, which can possibly be including slice property. So Now, I wrote a wrapper over image-size function which calculates size From=20slice property if available, or calls image-size if, only image property is available. The patch is attached. Happy Hacking Shyam K --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=image-mode_image-display-size.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch for making image-mode functions to consider slice property # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: shyam@swathanthran.in-20100716100307-6y92sw2p0xmgd7mj # author: Shyam Karanatt # testament_sha1: 71e9837d7961814d5fcb0f63955e2485584ea1e7 # timestamp: 2010-07-16 16:32:50 +0530 # base_revision_id: yamaoka@jpl.org-20100715005613-1hdb4741v79szq8v #=20 # Begin patch =3D=3D=3D modified file 'lisp/image-mode.el' =2D-- lisp/image-mode.el 2010-07-14 15:57:54 +0000 +++ lisp/image-mode.el 2010-07-16 10:03:07 +0000 @@ -128,6 +128,28 @@ =20 (declare-function image-size "image.c" (spec &optional pixels frame)) =20 +(defun image-display-size (spec &optional pixels frame) +"Wrapper around image-size to considers \(slice ..\) display property in S= PEC. +If SPEC is an image display property, call `image-size' with arguments. +If SPEC is list of properties having image and slice properties in it,=20 +calculate size from slice.=20 +If slice is not in the list but image is, call `image-size' with image. +If SPEC is a list without having image display property in it,=20 + error about invalid image specification." + (if (eq (car spec) 'image) + (image-size spec pixels frame) + (let ((image (assoc 'image spec)) + (slice (assoc 'slice spec))) + (cond ((and image slice) + (if pixels=20 + (cons (nth 3 slice) (nth 4 slice)) + (cons (/ (float (nth 3 slice)) (frame-char-width frame)) + (/ (float (nth 4 slice)) (frame-char-height frame))))) + (image + (image-size image pixels frame)) + (t + (error "Invalid image specification: %s" spec)))))) + (defun image-forward-hscroll (&optional n) "Scroll image in current window to the left by N character widths. Stop if the right edge of the image is reached." @@ -139,7 +161,7 @@ (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges))) =2D (img-width (ceiling (car (image-size image))))) + (img-width (ceiling (car (image-display-size image))))) (image-set-window-hscroll (min (max 0 (- img-width win-width)) (+ n (window-hscroll)))))))) =20 @@ -160,7 +182,7 @@ (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-height (- (nth 3 edges) (nth 1 edges))) =2D (img-height (ceiling (cdr (image-size image))))) + (img-height (ceiling (cdr (image-display-size image))))) (image-set-window-vscroll (min (max 0 (- img-height win-height)) (+ n (window-vscroll)))))))) =20 @@ -233,7 +255,7 @@ (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges))) =2D (img-width (ceiling (car (image-size image))))) + (img-width (ceiling (car (image-display-size image))))) (image-set-window-hscroll (max 0 (- img-width win-width))))) =20 (defun image-bob () @@ -248,9 +270,9 @@ (let* ((image (image-get-display-property)) (edges (window-inside-edges)) (win-width (- (nth 2 edges) (nth 0 edges))) =2D (img-width (ceiling (car (image-size image)))) + (img-width (ceiling (car (image-display-size image)))) (win-height (- (nth 3 edges) (nth 1 edges))) =2D (img-height (ceiling (cdr (image-size image))))) + (img-height (ceiling (cdr (image-display-size image))))) (image-set-window-hscroll (max 0 (- img-width win-width))) (image-set-window-vscroll (max 0 (- img-height win-height))))) =20 @@ -264,7 +286,7 @@ (interactive) (let* ((saved (frame-parameter nil 'image-mode-saved-size)) (display (image-get-display-property)) =2D (size (image-size display))) + (size (image-display-size display))) (if (and saved (eq (caar saved) (frame-width)) (eq (cdar saved) (frame-height))) --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJMQEMQAAoJEBatuUAvO6Tr+38H/1uokgEmu7xG91/ZRsLVzOWL 2fQzodWsq6jiUu8LNYgv8YK0mp356pUyAAzpnAO+mD6z3OsaN/dNFOwyi7knknle sH1pfxSaLQf648jzW7DslVcY5bT85I6xpl2iQAEZRFQ4aAdKrzxFiaQl4QrS5tHg 9YjISTMzo1OYD5s6AO6d8YLgW+BtfvTpcMKLj92/6nlxXBWfno9whEj3X3hUYhHm asmXcPYjdq9iDeiN9Tb71K2HBY5PvJxYeqDdgi7qTi531nuaLnFfwptd4VZ/BD9G MaT6vPGDCkwXHxiw6hCX0sM8oQqoEkxLZKqt3pIyO5yj6QLSXM2eF2NdxPYvw3Q= =Br2f -----END PGP SIGNATURE----- --==-=-=--