From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: benrwhite@gmail.com (Benjamin R. White) Newsgroups: gmane.emacs.devel Subject: Contributing & lisp/image-mode.el patch Date: Sun, 10 Oct 2010 21:45:08 +0100 Message-ID: <87k4lphj57.fsf@asuka.nibjib.dyndns.info> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1286744311 15546 80.91.229.12 (10 Oct 2010 20:58:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 10 Oct 2010 20:58:31 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 10 22:58:30 2010 Return-path: Envelope-to: ged-emacs-devel@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 1P52yT-0001Ku-0w for ged-emacs-devel@m.gmane.org; Sun, 10 Oct 2010 22:58:29 +0200 Original-Received: from localhost ([127.0.0.1]:50490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P52yS-0000Yw-7V for ged-emacs-devel@m.gmane.org; Sun, 10 Oct 2010 16:58:28 -0400 Original-Received: from [140.186.70.92] (port=59673 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P52wD-0007ku-JG for emacs-devel@gnu.org; Sun, 10 Oct 2010 16:56:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P52lf-0001xf-Jm for emacs-devel@gnu.org; Sun, 10 Oct 2010 16:45:16 -0400 Original-Received: from mail-ww0-f49.google.com ([74.125.82.49]:38017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P52lf-0001xZ-Ax for emacs-devel@gnu.org; Sun, 10 Oct 2010 16:45:15 -0400 Original-Received: by wwd20 with SMTP id 20so2587092wwd.30 for ; Sun, 10 Oct 2010 13:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:user-agent:mime-version:content-type; bh=NqD0rTtc4w7lGjeyeKchyD13WcPsvJyPDyxeuvJf4xI=; b=x5fofJoZP/W6RcFaeS61a/pHqYKZloJE/5tucwb6f55u0ObpQO2LRJHHkrQsrGpAN/ Y5vnhXVW/iaYUK477/ZU91rsM6EOygrRSIMyr6w6XeTFiMfarF9B5L20JFOuiD2u+41w 8glHxd9nktzVLfhGBQn1R5Y8Vity52rIeAjk8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:user-agent:mime-version :content-type; b=Sf1cDVkXEhHdH3/9ZQ3LPa+U5moWCd7g07KgECh3YWFrbBz6242h6egJxgkWoko3dJ QeDgcQt7ZssLAI9A9ELjZHvK4D2z6ifW8qPnB+w61hHSJtgsWMcoVOEzx3W7fq6Enm97 lp6V2kwOuAgyEaV+jQNRcKyFREw4K/q/9Raeo= Original-Received: by 10.216.164.199 with SMTP id c49mr4687722wel.107.1286743513146; Sun, 10 Oct 2010 13:45:13 -0700 (PDT) Original-Received: from asuka.nibjib.dyndns.info.asuka.nibjib.dyndns.info (93-96-220-43.zone4.bethere.co.uk [93.96.220.43]) by mx.google.com with ESMTPS id x3sm1987269weq.8.2010.10.10.13.45.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 10 Oct 2010 13:45:12 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:131592 Archived-At: --=-=-= Content-Type: text/plain Hello, I've been an Emacs user for a reasonable portion of my life and recently decided I'd like to start contributing to GNU/Emacs development. With the aim of starting off by scratching itches, I've thought before that in image mode there should be a way of navigating around an image within an *image-mode* buffer using the mouse. To this effect I've made the following (albeit, trivial) patch that allows you to use the mouse-2 button to drag around an image that is larger than the window displaying it. I'm a relative newcomer to Lisp so you may judge my code to not be worthwhile, however I'm always willing to receive constructive criticism where it is due, and suggestions on how I can improve my coding style. I read within etc/CONTRIBUTE that I needed to contact this list to obtain forms so that the GNU/Emacs project may benefit by my contributions, so to this effect I've been subscribed to the digest version of the list for about a week. It's a bit scary for a newbie to see all the arguments that go on around here. Cheers, Benjamin --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=image-mode-drag.log Content-Description: ChangeLog entry 2010-10-10 Benjamin R. White * image-mode.el: Function and mapping for image-dragging within a window. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=image-mode-drag.txt Content-Description: image-mode-drag patch # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: benrwhite@gmail.com-20101010140926-r6g5g6d7o9s85cgo # target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk # testament_sha1: be306a8c74d88c7c60c045fb1442688c981f4cdc # timestamp: 2010-10-10 21:06:34 +0100 # base_revision_id: dann@ics.uci.edu-20101010134422-ib3bgfpbqus51h0e # # Begin patch === modified file 'lisp/image-mode.el' --- lisp/image-mode.el 2010-09-24 03:06:33 +0000 +++ lisp/image-mode.el 2010-10-07 19:31:46 +0000 @@ -290,6 +290,48 @@ (set-frame-width (selected-frame) (car size)) (set-frame-height (selected-frame) (cdr size)))) +(defun image-mouse-scroll-position (start-event) + "When bound to a down-mouse-X input START-EVENT, will smoothly +drag the viewpoint on the image buffer that the window displays." + (interactive "e") + (let* ((echo-keystrokes 0) + (start-posn (event-start start-event)) + (x-offset (window-hscroll (car start-posn))) + (y-offset (window-vscroll (car start-posn) t)) + (imframe-cwidth (frame-char-width + (window-frame (car start-posn)))) + (startpos (nth 8 start-posn)) + event now-posn nowpos x-diff y-diff ) + (select-window (posn-window start-posn)) + (track-mouse + (while (progn + ;; as used in mouse.el:mouse-drag-track + (setq event (read-event)) + (or (mouse-movement-p event) + (memq (car-safe event) '(switch-frame select-window)))) + (setq now-posn (event-start event)) + ;; check if drag is within image on frame + (if (and (eq (nth 7 start-posn) (nth 7 now-posn)) + (eq (nth 1 start-posn) (nth 1 now-posn))) + (progn + (setq nowpos (nth 8 now-posn)) + (setq x-diff (- (car startpos) (car nowpos))) + (setq y-diff (- (cdr startpos) (cdr nowpos))) + + (set-window-vscroll (nth 0 start-posn) + (+ y-offset y-diff) t) + (if (< (/ imframe-cwidth 2) + (abs x-diff)) + (set-window-hscroll + (car start-posn) + (+ x-offset + (/ (if (> x-diff 0) + (+ x-diff (/ imframe-cwidth 2)) + (- x-diff (/ imframe-cwidth 2))) + imframe-cwidth)))) + (setq x-offset (window-hscroll (car now-posn))) + (setq y-offset (window-vscroll (car now-posn) t)))))))) + ;;; Image Mode setup (defvar image-type nil @@ -321,6 +363,7 @@ (define-key map [remap move-end-of-line] 'image-eol) (define-key map [remap beginning-of-buffer] 'image-bob) (define-key map [remap end-of-buffer] 'image-eob) + (define-key map [down-mouse-2] 'image-mouse-scroll-position) map) "Major mode keymap for viewing images in Image mode.") # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWV+IaxoADvPfgHwwUP///3sn ncq////wYBQc7c3Wxxphe3x9j4cgdaOvodPT0aAOp167ZbfZnJ7d2JZnQ9ADVaAGINsCUQTRNNoE xGhqbJTZNKDagyAA9R6mm1AJJAAIQTJE9MVPCNQyA0AAAACSnqNCmUZGmU8U8oZAA0AAaNAAAJNR RogKR+kanpqZM01MyIDQaaAAAAIqp5RkNQGjTT0aQGygADQAAAAFS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