all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Contributing & lisp/image-mode.el patch
@ 2010-10-10 20:45 Benjamin R. White
  2010-10-11  5:00 ` Chong Yidong
  2010-10-11  6:09 ` David Kastrup
  0 siblings, 2 replies; 3+ messages in thread
From: Benjamin R. White @ 2010-10-10 20:45 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]

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


[-- Attachment #2: ChangeLog entry --]
[-- Type: text/plain, Size: 131 bytes --]

2010-10-10  Benjamin R. White  <benrwhite@gmail.com>

	* image-mode.el: Function and mapping for image-dragging
	within a window.


[-- Attachment #3: image-mode-drag patch --]
[-- Type: text/plain, Size: 8210 bytes --]

# 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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97Rr60W3/gckeUXi2V/ipza+WrKJ++aYwRt9WKOwmoJYcGJwKN6vfEmAZiCAUVCULgbzZZFSSe
jkQwwnh5SBfsQN5SJkiQSjvfnRnmUiZLIX3d0idiLCY0qlZ/CPkiuGzjMEckakTrm4WWZSX0rKrF
4dv7onmnXh4o5MvNG+W7UfVF44I//F3JFOFCQX4hrGg=

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Contributing & lisp/image-mode.el patch
  2010-10-10 20:45 Contributing & lisp/image-mode.el patch Benjamin R. White
@ 2010-10-11  5:00 ` Chong Yidong
  2010-10-11  6:09 ` David Kastrup
  1 sibling, 0 replies; 3+ messages in thread
From: Chong Yidong @ 2010-10-11  5:00 UTC (permalink / raw)
  To: Benjamin R. White; +Cc: emacs-devel

> 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.

Hi Ben,

Thanks for posting your code.  It certainly sounds interesting, but I
don't have time to review it right this moment.  Maybe one of the other
developers will help (but if none of us replies in a week or two, don't
hesitate to ping emacs-devel again).

I'll send you the instructions for getting a copyright assignment
off-list.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Contributing & lisp/image-mode.el patch
  2010-10-10 20:45 Contributing & lisp/image-mode.el patch Benjamin R. White
  2010-10-11  5:00 ` Chong Yidong
@ 2010-10-11  6:09 ` David Kastrup
  1 sibling, 0 replies; 3+ messages in thread
From: David Kastrup @ 2010-10-11  6:09 UTC (permalink / raw)
  To: emacs-devel

benrwhite@gmail.com (Benjamin R. White) writes:

> 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.

Developers feel strong enough about what they consider important that
they'll get up and do something about it.  If one of them thinks his
arguments don't register, he turns up the volume.  After all, his
arguments are good and important, so it must be a fault at the receiving
end.  Others turn down their receivers for certain sources.  The results
are somewhat working, but a newcomer does not yet have his sensors tuned
to the various sources.

It would be easier for new entrees if the atmosphere here were less
off-color with regard to standard communication habits.  Looking around
at other developer lists, this list does not appear all too bad in the
order of things.  Closed social circles can often become peculiar.  The
best you can hope to do is set a better example.  Admonishments don't
work much.

-- 
David Kastrup




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-11  6:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-10 20:45 Contributing & lisp/image-mode.el patch Benjamin R. White
2010-10-11  5:00 ` Chong Yidong
2010-10-11  6:09 ` David Kastrup

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.